openapi: 3.1.0
info:
  title: Timeliner API
  version: "1.233.1"
  summary: REST API for the Timeliner workspace, projects, tasks, and files.
  description: |
    The Timeliner API lets you read and write the same workspace, project,
    and task data you can see in the Timeliner web app, programmatically.

    ## Base URL

    ```
    https://timeliner.io
    ```

    Every endpoint below is prefixed with `/api/v1`.

    ## Authentication

    Every request must include a workspace API key in the `Authorization`
    header:

    ```
    Authorization: Bearer tlsk_<your-key>
    ```

    Keys are created in **Settings → Workspace → API Keys** inside the
    Timeliner app. Each key is scoped to a single workspace and is
    revealed only at creation time — store it somewhere safe. Revoked
    keys stop working immediately.

    ## Scopes

    Every key carries a set of scopes — `read:<resource>` and
    `write:<resource>` over ten resources (`tasks`, `projects`, `files`,
    `posts`, `chat`, `finance`, `automations`, `workspace`, `hq`,
    `webhooks`; see `ApiKeyScope`). `write` implies `read`. A call the key
    is not scoped for fails with **403** and a body of
    `{ "error": "…", "code": "insufficient_scope", "requiredScope": "write:tasks", "grantedScopes": [...] }`.
    Keys created before scopes existed hold every scope (or every read
    scope for read-only keys). `GET /api/v1/api-key` tells you what the
    key you hold can do; it needs no scope.

    ## Key expiry

    A key may carry an expiry date. Past it every call fails with **401**
    and `{ "error": "API key expired", "code": "api_key_expired", "expiresAt": "…" }`.
    A key is also revoked automatically when the member who created it
    leaves the workspace or loses manager access — create replacements
    for integrations that stop working.

    ## Rate limits

    Each key has a per-minute request ceiling (default 300, set per key in
    Settings). Above it every call fails with **429**, a body of
    `{ "error": "Rate limit exceeded", "code": "rate_limited", "limit": 300, "windowSeconds": 60, "retryAfterSeconds": 12 }`,
    and the headers `Retry-After`, `X-RateLimit-Limit`,
    `X-RateLimit-Remaining` and `X-RateLimit-Reset` (unix seconds). Back
    off for `Retry-After` seconds and retry.

    ## Key could not be verified

    If Timeliner cannot check your key at all for a moment (its database,
    or the network in front of it, did not answer), the call fails with
    **503**, a body of
    `{ "error": "The API key could not be verified right now. Please retry shortly.", "code": "service_unavailable", "retryAfterSeconds": 10 }`
    and a `Retry-After` header (since 1.114.1). Your key is fine: wait
    `Retry-After` seconds and send the same call again. Do not rotate the
    key — only a **401** means the key itself was refused. The MCP server
    (`/api/mcp`) answers the same 503 rather than asking the client to sign
    in again.

    ## Billing lock

    Every write (`POST`, `PATCH`, `PUT`, `DELETE`) on a workspace whose
    billing is locked — payment blocked, subscription canceled, or a first
    checkout never completed — fails with **403** and
    `{ "error": "…", "code": "billing_locked" }`, exactly as the app locks
    that workspace for its team. Reads keep working so an integration can
    still export its data. The one write that stays open is
    `POST /api/v1/files/uploads/{id}/abort`, which only frees an unfinished
    upload. Reactivating the subscription lifts the lock immediately; no key
    rotation is needed.

    ## Uploads paused

    The endpoints that take new uploaded bytes — `POST /api/v1/files/uploads`,
    `POST /api/v1/files/uploads/{id}/part-urls`,
    `POST /api/v1/files/uploads/{id}/complete` (unless that upload already
    completed), `POST /api/v1/files/upload-from-url`,
    `POST /api/v1/doc-attachments/upload-from-url`,
    `POST /api/v1/hq/items/{id}/files` (since 1.110.1) and
    `PUT /api/v1/brands/{id}/logo` (since 1.201.0) — are also refused with
    **403** and `{ "error": "…", "code": "UPLOADS_PAUSED" }` (since 1.109.0)
    while the workspace's uploads are paused: a workspace whose removal of
    uploaded media has been scheduled after its subscription ended, even when
    its other writes still work. A billing-locked workspace answers
    `billing_locked` first. Nothing is uploaded; reactivating the
    subscription resumes uploads.

    ## Removed media

    When a workspace stays cancelled, its uploaded files are eventually
    permanently deleted (the workspace admins are emailed the exact date at
    least 30 days before). The file's metadata survives: task and post
    `media` objects are still returned with every link `null` and
    `purgedAt` set, and `GET /api/v1/files/{id}/download` answers **404**
    `{ "code": "file_content_missing", "purgedAt": "…" }`. Reactivating the
    subscription before the deletion date keeps the content; once a file has
    been permanently deleted it cannot be restored, and it keeps answering
    404 `file_content_missing`. A removed video's transcript goes with it
    (since 1.109.0): `GET /api/v1/tasks/{id}/transcript` answers the same
    404 `file_content_missing` with `purgedAt`, and the AI endpoints
    (`POST /api/v1/posts/{taskId}/caption/generate`,
    `POST /api/v1/tasks/{id}/suggest-tags`,
    `GET /api/v1/analytics/social/insights`) work from the task's remaining
    text without it. Comment and request attachments, document images and
    files, and HQ board files are removed the same way. A removed comment
    attachment or HQ board file no longer counts toward `usedBytes` or its
    `GET /api/v1/storage` category, and a removed document attachment's
    `url` answers 404 — an image or video shows a placeholder in its place
    in the document.

    Keys always begin with the `tlsk_` prefix followed by 48 hexadecimal
    characters (192 bits of entropy).

    ## Pagination

    List endpoints (`GET /projects`, `GET /tasks`) use cursor-based
    pagination keyed on `created_at` (newest first):

    - `limit` — number of items per page. Default `50`, max `100`.
    - `before` — ISO 8601 timestamp from a previous response's
      `nextBefore` value. Omit to start from the most recent item.

    The response shape is always:

    ```json
    { "data": [ ... ], "nextBefore": "2026-05-01T12:34:56.000Z" | null }
    ```

    When `nextBefore` is `null`, you have reached the end of the list.

    ## Errors

    All non-2xx responses return a JSON envelope:

    ```json
    { "error": "Human-readable message" }
    ```

    Status codes follow the usual conventions:

    | Code | Meaning |
    |------|---------|
    | 400  | Invalid request body or query parameters |
    | 401  | Missing or invalid `Authorization` header |
    | 404  | Resource not found in this workspace |
    | 409  | Conflict (e.g. project at its task limit) |
    | 500  | Server error — please retry or contact support |
    | 503  | Temporarily unavailable — wait `Retry-After` seconds and retry (see *Key could not be verified*) |

    ## Versioning

    All endpoints are versioned under `/api/v1`. Breaking changes will
    ship as `/api/v2` with at least 90 days of overlap. Additive
    changes (new optional fields, new endpoints) ship in place.

    ## Webhooks

    Subscribe a workspace to server-sent events (`task.completed`,
    `post.status_changed`) and Timeliner will `POST` a signed JSON
    envelope to your HTTPS endpoint whenever they fire. Register and
    manage subscriptions under the **Webhooks** tag below, or in
    **Settings → Workspace → Webhooks** inside the app.

    Each delivery carries an `X-Timeliner-Signature: t=<unixSeconds>,v1=<hex>`
    header. Verify it by recomputing `HMAC-SHA256(secret, "<t>.<rawBody>")`
    over the **raw** request body and comparing with a constant-time check,
    then reject deliveries whose `t` is more than 300 seconds old. Delivery is
    at-least-once — dedupe on the envelope `id`. See the **Webhooks** section
    at the bottom of this reference for the exact event payloads.
  contact:
    name: Timeliner Support
    email: support@timeliner.io
    url: https://timeliner.io/help-center

servers:
  - url: https://timeliner.io
    description: Production
  - url: https://stg.timeliner.io
    description: Staging (test workspaces, requires staging password for the website itself; the API endpoints below are not gated)

tags:
  - name: Workspace
    description: Read metadata about the workspace owning the API key.
  - name: Members
    description: Read the workspace's team members, their roles (admin / supervisor / editor), and editor sub-roles; update per-member settings like weekly workload capacity.
  - name: Workload
    description: |
      Capacity planning (Agency plan or higher) — the per-member workload grid
      (task time estimates spread across working days vs weekly capacity) and
      the production / time-off blocks that shape it. Answers "who is
      available" and "who can take a new project".
  - name: Projects
    description: Create, list, and retrieve projects (with their folders) in the workspace.
  - name: Share Links
    description: Manage the public review links — a project's task board, a brand's client portal (every project of the brand), one task's review page, or a batch link that opens a hand-picked, ordered set of a project's tasks as one link.
  - name: Tasks
    description: Create, list, retrieve, and update tasks across the workspace's projects.
  - name: Posts
    description: Read the per-social-network captions and publish status of scheduled posts.
  - name: Trial Reels
    description: Instagram trial reels — hook tests (2-3 openings of one video posted as trial reels, the winner picked by the numbers), the "Repost as trial" rule, and their analytics.
  - name: Files
    description: Generate time-limited download URLs for files (originals, previews, thumbnails, transcoded variants), and move raw files between projects, brands and folders.
  - name: Storage
    description: |
      Storage management — see where the workspace's bytes live (per brand /
      project / category), list files with media metadata and lifecycle
      context, read rule-based cleanup suggestions, and move selections into
      Trash. Cleanup NEVER deletes permanently: everything lands in the
      standard Trash and is purged 30 days after trashing.
  - name: Brands
    description: Read and create brands and clients (with social accounts and the brand brief), attach named links of any kind (website, drive, social), and store arbitrary integration metadata.
  - name: HQ
    description: |
      Internal-only team boards (ops tasks, SOP docs, light CRM, asset shelves).
      Clients and guests never get a seat in HQ. A board manager can publish a
      read-only public link to one whole board in the app (1.102.0); this API
      has no endpoints for it. The workspace API key is an admin-equivalent
      credential, so it sees ALL boards — including `access: restricted` ones.
  - name: Chat
    description: |
      Read and post in the workspace's chat — the Discussions channels (the
      workspace-wide channel, per-brand and per-project channels, DMs, and
      standalone channels like `#marketing`). Separate from `/channels`, which
      is social posting accounts, and from a task's review thread.

      Chat access is per-person: standalone channels can be private, so these
      endpoints resolve what the API key's *creator* may read and write. A key
      with no associated user cannot use them.
  - name: Webhooks
    description: Register outbound webhook subscriptions, rotate signing secrets, and receive workspace event notifications.

security:
  - bearerAuth: []

paths:
  /api/v1/workspace:
    get:
      tags: [Workspace]
      operationId: getWorkspace
      summary: Get the authenticated workspace
      description: Returns metadata about the workspace the API key belongs to.
      responses:
        "200":
          description: Workspace metadata.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Workspace"
              examples:
                default:
                  value:
                    id: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
                    name: Acme Studio
                    picture: https://cdn.timeliner.io/ws/acme.png
                    defaultCurrency: USD
                    template: agency
                    timezone: America/New_York
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/members:
    get:
      tags: [Members]
      operationId: listMembers
      summary: List team members
      description: |
        Returns the workspace's team members — each with their team `role`
        (`admin`, `supervisor`, or `editor`), an optional free-form editor
        `subRole` label, and `deactivated` / `pending` lifecycle flags. Use
        this to answer "who is on the team", "who is available", or "what is
        each person's role", and to match a member's `id` to task assignees.

        By default only active team members are returned: people who accepted
        their invite and were not removed. Set `includeGuests=true` to also
        include external guest reviewers (role `guest`),
        `includeDeactivated=true` to include removed members, and
        `includePending=true` to include people invited who have not accepted
        yet (`pending: true`) — a task's assignee ids can name one of them.
        `PATCH /api/v1/members/{id}` refuses a pending or removed member.
        Not paginated — a workspace's team is bounded by its plan seats.

        To look up people you already hold ids for, send `ids`: the answer holds
        only those members, and an id that is no member of this workspace is
        simply absent. The `include…` flags still apply, so send all three to
        learn a person's state whatever it is.

        Compensation is full-scope only: with a **read-scope** API key the
        response omits `payModel` and `monthlySalary` entirely — the rest of
        the roster fields are unchanged.
      parameters:
        - name: includeGuests
          in: query
          description: Include external guest reviewers (role `guest`). Defaults to false.
          required: false
          schema:
            type: boolean
        - name: includeDeactivated
          in: query
          description: Include deactivated / removed members. Defaults to false.
          required: false
          schema:
            type: boolean
        - name: includePending
          in: query
          description: Include people invited who have not accepted yet (`pending` is true). Defaults to false.
          required: false
          schema:
            type: boolean
        - name: ids
          in: query
          description: Return only these members — up to 100 comma-separated member ids. Each must be a UUID; anything else is rejected with 400.
          required: false
          schema:
            type: string
      responses:
        "200":
          description: The workspace's members.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MemberPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/members/{id}:
    patch:
      tags: [Members]
      operationId: updateMember
      summary: Update a member
      description: |
        Update a team member's per-member settings:
        `weeklyCapacityMinutes` — the member's weekly workload capacity in
        minutes (`2400` = 40h; `null` = follow the workspace default
        `defaultWeeklyCapacityMinutes` from workspace settings) — and/or
        `payModel` — how the member is paid: `perTask` (per-deliverable pay
        rows, the default), `perProject` (a fixed fee per project, set per
        project via `PUT /api/v1/projects/{id}/billing` `team.feeUpdates`),
        or `monthly` (salary; `monthlySalary` required). Pay-model changes
        are effective-dated on `MemberCompensation` — history keeps
        counting; the new model applies from today. The member must belong
        to this workspace (cross-workspace ids return 404) **and be an
        active team member**: targeting a guest returns 400, and so does a
        deactivated or pending member. `weeklyCapacityMinutes` requires a
        workload-entitled plan (Agency or higher — 403 otherwise), and
        `payModel` writes require active billing (403 on a locked
        workspace), matching the in-app paths.
      parameters:
        - $ref: "#/components/parameters/MemberId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                weeklyCapacityMinutes:
                  type: integer
                  nullable: true
                  minimum: 0
                  maximum: 10080
                  description: Weekly workload capacity in minutes, or null to follow the workspace default.
                payModel:
                  type: string
                  enum: [perTask, perProject, monthly]
                  description: >-
                    The member's pay model; `monthly` requires `monthlySalary`.
                    `pod` is read-only here — pods (one monthly figure paid to
                    a lead for a group of members) are managed in the app
                    under Settings → Team → Pods. Setting any of these three
                    on a pod member takes them out of the pod.
                monthlySalary:
                  type: number
                  minimum: 0
                  exclusiveMinimum: true
                  description: Monthly salary amount — required when `payModel` is `monthly`.
            example:
              weeklyCapacityMinutes: 1920
      responses:
        "200":
          description: The updated member.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/Member"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/workload:
    get:
      tags: [Workload]
      operationId: getWorkload
      summary: Get the team workload grid
      description: |
        The capacity-planning grid behind the in-app Workload view — use it to
        answer "who is available", "who can take a new project", "is the team
        overloaded next week". Per active team member it returns per-day and
        per-week `scheduledMinutes` vs `capacityMinutes` (task time estimates
        spread evenly across the workspace's working days, plus
        production/time-off blocks), the task spans (`startDate` → `dueDate`
        with that member's share of the estimate), block spans, and the
        `unscheduledTaskIds` (assigned but missing dates) and `overdueTaskIds`
        buckets. A member has room when `scheduledMinutes` stays below
        `capacityMinutes` across the weeks in question.

        A task contributes hours when it has a start date, a deadline
        (`internalDeadline` when set, else `externalDeadline`), at least one
        assignee, and an estimate. With per-assignee estimate rows the
        breakdown is authoritative; otherwise the task total splits evenly
        across assignees. Overdue tasks keep their hours in the original
        window — the bucket is the signal.

        The range scopes the response: `tasks` and `blocks` list only spans
        overlapping `[from, to]`, and `overdueTaskIds` lists overdue tasks
        whose work window touches the range. `unscheduledTaskIds` is always
        complete (assigned open tasks missing a start date or any deadline),
        whatever range you ask for.

        Requires an Agency plan or higher (403 otherwise). Default
        range: the current week's start → +8 weeks (max 370 days). When only
        one bound is supplied, the other derives from it: `to` defaults to
        `from` + 8 weeks, `from` to `to` − 8 weeks.
      parameters:
        - name: from
          in: query
          required: false
          description: >-
            Range start (YYYY-MM-DD). Default — `to` − 8 weeks, or the current
            week's start when `to` is also omitted.
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: false
          description: >-
            Range end, inclusive (YYYY-MM-DD). Default — `from` + 8 weeks, or
            +8 weeks from the current week's start when `from` is also omitted.
          schema:
            type: string
            format: date
      responses:
        "200":
          description: The workload grid.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/WorkloadGrid"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/workload/blocks:
    get:
      tags: [Workload]
      operationId: listWorkloadBlocks
      summary: List workload blocks
      description: |
        Member-level date-range blocks: shoot days and location scouts
        (`production`), vacations/public holidays (`timeOff` — reduces the
        member's capacity), or `other`. Blocks apply to every calendar day in
        their range, weekends included. Optional `from`/`to` narrow the list to
        blocks overlapping the range. Requires an Agency plan or higher.

        Paginated oldest-first by `startDate`: pass `limit` (default 50, max
        200) and echo the response's `nextBefore` back as `before` for the next
        page. `nextBefore` is `null` on the last page.
      parameters:
        - name: from
          in: query
          required: false
          description: Only blocks ending on/after this date (YYYY-MM-DD).
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: false
          description: Only blocks starting on/before this date (YYYY-MM-DD).
          schema:
            type: string
            format: date
        - name: limit
          in: query
          required: false
          description: Page size. Values above 200 are clamped to 200.
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - name: before
          in: query
          required: false
          description: >-
            Opaque pagination cursor — pass the previous response's `nextBefore`
            value verbatim.
          schema:
            type: string
      responses:
        "200":
          description: One page of the workspace's blocks.
          content:
            application/json:
              schema:
                type: object
                required: [data, nextBefore]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/WorkloadBlock"
                  nextBefore:
                    type: string
                    nullable: true
                    description: Cursor for the next page; `null` on the last page.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Workload]
      operationId: createWorkloadBlock
      summary: Create a workload block
      description: |
        Create a block for a team member. `timeOff` reduces the member's daily
        capacity by `minutesPerDay` (floored at 0); `production`/`other` add
        `minutesPerDay` of scheduled load — every calendar day in the range,
        weekends included. Requires an Agency plan or higher.

        Dates must be real calendar dates (a shape-valid but non-existent date
        like `2026-13-01` is a 400). Omitting `kind` defaults it to
        `production`; an explicit `kind: null` is rejected with a 400.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [memberId, title, startDate, endDate, minutesPerDay]
              properties:
                memberId:
                  type: string
                  format: uuid
                  description: Team member id (from `GET /members`).
                title:
                  type: string
                  maxLength: 200
                kind:
                  type: string
                  enum: [production, timeOff, other]
                  default: production
                startDate:
                  type: string
                  format: date
                  description: Must be a real calendar date — impossible dates (e.g. `2026-02-30`, `2026-13-01`) are rejected with 400.
                endDate:
                  type: string
                  format: date
                  description: Inclusive; on/after `startDate` (max 365-day span). Must be a real calendar date — impossible dates are rejected with 400.
                minutesPerDay:
                  type: integer
                  minimum: 1
                  maximum: 1440
                  description: Minutes per day (480 = 8h).
                taskId:
                  type: string
                  format: uuid
                  nullable: true
                  description: Optional task this block serves — must be a task in this workspace.
                projectId:
                  type: string
                  format: uuid
                  nullable: true
                  description: Optional related project — must be a project in this workspace.
            example:
              memberId: "1c9dbe3f-2f6e-4c1e-9a3d-1f2e3d4c5b6a"
              title: Client shoot day
              kind: production
              startDate: "2026-08-01"
              endDate: "2026-08-02"
              minutesPerDay: 480
      responses:
        "201":
          description: The created block.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/WorkloadBlock"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/workload/blocks/{id}:
    patch:
      tags: [Workload]
      operationId: updateWorkloadBlock
      summary: Update a workload block
      description: |
        Update a block's `title`, `kind`, dates, or `minutesPerDay` — provide
        at least one. Requires an Agency plan or higher.

        Changing `startDate` or `endDate` counts as a deliberate reschedule and
        resets the block's workload-rule auto-roll history (roll count, rolled
        origin, escalation marker), exactly as moving the block in the app
        does. Updates that keep both dates unchanged leave that history intact.
      parameters:
        - $ref: "#/components/parameters/WorkloadBlockId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  maxLength: 200
                kind:
                  type: string
                  enum: [production, timeOff, other]
                startDate:
                  type: string
                  format: date
                endDate:
                  type: string
                  format: date
                minutesPerDay:
                  type: integer
                  minimum: 1
                  maximum: 1440
                taskId:
                  type: string
                  format: uuid
                  nullable: true
                  description: Link (or null to unlink) the task this block serves.
      responses:
        "200":
          description: The updated block.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/WorkloadBlock"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Workload]
      operationId: deleteWorkloadBlock
      summary: Delete a workload block
      description: |
        Delete a block (a cancelled shoot, removed time off). Requires an Agency plan or higher.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/WorkloadBlockId"
      responses:
        "200":
          description: Deletion confirmation.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [id, deleted]
                    properties:
                      id:
                        type: string
                        format: uuid
                      deleted:
                        type: boolean
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects:
    get:
      tags: [Projects]
      operationId: listProjects
      summary: List projects
      description: |
        Returns projects in the workspace, newest first. Cursor-paginated via
        `limit` and `before`.

        **Trashed projects are excluded by default.** `DELETE
        /api/v1/projects/{id}` is a soft delete, so a deleted project still
        exists with `status: "trashed"` — pass `includeTrashed=true` to see
        them and read `status` on each project to tell them apart.

        **Archived projects are included**, exactly as before, and carry
        `archived: true` (1.206.0). Pass `nodeId` to list only the projects
        directly inside one brand, client or sidebar folder.
      parameters:
        - $ref: "#/components/parameters/Limit"
        - $ref: "#/components/parameters/Before"
        - name: includeTrashed
          in: query
          required: false
          schema:
            type: string
            enum: ["true", "false"]
          description: |
            Include projects that have been moved to Trash. Defaults to
            `false`. Trashed projects are returned with `status: "trashed"`.
        - name: nodeId
          in: query
          required: false
          schema:
            type: string
            format: uuid
          description: |
            Only the projects DIRECTLY under this brand, client or sidebar
            folder (one level, like opening it in the Timeliner sidebar) —
            an id from `GET /api/v1/brands` (any `type`, `folder` included)
            or a project's `nodeId`. A sidebar folder usually holds brands
            rather than projects: the brands inside it are the
            `GET /api/v1/brands` rows whose `parentId` is its id. Omit to list
            every project. A malformed id is a 400; an id that is not a node
            of this workspace is a 404 (an unknown id and another workspace's
            node read the same; a mistake inside this workspace, such as a
            task or project id, is named with the id to send instead).
            (1.206.0)
      responses:
        "200":
          description: Page of projects.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Projects]
      operationId: createProject
      summary: Create a project
      description: |
        Create a project under a workspace node (a brand or sub-folder). The
        `nodeId` must belong to the same workspace as the API key.

        Optionally pre-create up to 20 top-level folders inside the project
        by passing their names in `folders`. Folder failures do not roll
        back the project.

        **Unrecognized fields are rejected with `400`**, and the error names
        both the offending key and the accepted set. Projects carry no date
        field of their own — a deadline belongs on a task
        (`internalDeadline` on `PATCH /api/v1/tasks/{id}`).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateProjectInput"
            examples:
              minimal:
                summary: Just the required fields
                value:
                  name: Q3 Campaign
                  nodeId: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
              withFolders:
                summary: Project with starter folders
                value:
                  name: Q3 Campaign
                  nodeId: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
                  description: Reels + carousels for the September push.
                  folders: [Briefs, Scripts, Cuts]
                  externalMetadata:
                    monday_id: "1234567890"
      responses:
        "201":
          description: |
            Project created. `folders` is the list of raw-file folders that
            were successfully created; `subFolders` (task groups) is always
            `[]` on create — add one with
            `POST /api/v1/projects/{id}/sub-folders`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectWithFolders"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          description: |
            `nodeId` is no brand, client or folder of your workspace, and
            nothing was created. When the id is something else of your own
            workspace — your workspace's own id, a project, a task, a
            sub-folder (task group), a folder inside a project's files, a
            folder in a brand's Raw files & Assets, an HQ item or a file — or
            a brand or folder id shortened and padded back out (its first 8
            characters matching a brand or folder of your workspace), `error`
            names which, and for a project, task or folder the brand or folder
            id to send instead. An unknown id, or a brand in another
            workspace, keeps the plain `Node not found` error: the two are
            deliberately indistinguishable, and no body echoes the id back.
            Since 1.204.0 that plain body also carries
            `"reason": "node_not_found"` (a named mistake has no `reason`).
            Get the brand's id again (`GET /api/v1/brands`, or an existing
            project's `nodeId`) and send all 36 characters.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectCreateNotFoundError"
              examples:
                unknownNode:
                  summary: Unknown node id, or a brand in another workspace
                  value:
                    error: Node not found
                    reason: node_not_found
                projectIdAsNodeId:
                  summary: A project's id was sent as the node id
                  value:
                    error: >-
                      Node not found. That id is a project in this workspace,
                      and a project cannot hold another project — its brand or
                      folder is 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01 — pass
                      that as `nodeId` to create the new project there. To add
                      a task to that project instead, use create_task with its
                      id as `projectId`; to group tasks inside it, use
                      create_sub_folder.
                shortenedNodeId:
                  summary: A brand id shortened and padded back out
                  value:
                    error: >-
                      Node not found. No brand or folder has that exact id, but
                      one in this workspace has an id starting with the same 8
                      characters: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01. The id
                      sent looks shortened and filled back out — a brand or
                      folder id is always the full 36 characters, exactly as
                      list_brands, create_brand or a project's nodeId returned
                      it, never shortened or padded. If that is the brand or
                      folder you meant, retry with its full id.
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}:
    get:
      tags: [Projects]
      operationId: getProject
      summary: Retrieve a project
      description: |
        Returns the project plus its active `folders` (the raw-FILE folder
        system, sorted by name) and its `subFolders` (the TASK grouping level,
        ordered by sortOrder then name). Tasks reference a sub-folder via
        their `subFolderId` field.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      responses:
        "200":
          description: Project with folders (files) and subFolders (task groups).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectWithFolders"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Projects]
      operationId: updateProject
      summary: Update a project
      description: |
        Update a project's allow-listed fields — `name`, `description`,
        `externalMetadata`. Provide at least one. Returns the updated project
        with its active folders and subFolders.

        **Unrecognized fields are rejected with `400`** that names the
        offending key, rather than being silently ignored.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateProjectInput"
            examples:
              rename:
                summary: Rename a project
                value:
                  name: Q3 Brand Refresh
      responses:
        "200":
          description: The updated project with its active folders.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectWithFolders"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Projects]
      operationId: deleteProject
      summary: Delete a project
      description: |
        Moves the project to Trash (soft-delete). **Cascades** — every active
        task in the project is trashed too, and the project, its tasks and
        their files leave the client's view immediately. Restorable from the
        app's Trash page, but a restore is a manual, workspace-wide operation,
        so treat this as irreversible when you design an integration.

        Idempotent; no notifications fire. A repeat `DELETE` on a project that
        is already in Trash changes nothing: it returns `204` again, writes no
        second Activity Log entry and sends no second `project.trashed` webhook.

        **The project is not destroyed and stays readable.** `GET
        /api/v1/projects/{id}` continues to return it with `status: "trashed"`;
        it simply drops out of `GET /api/v1/projects` (pass
        `includeTrashed=true` to see it). Confirm a deletion by reading
        `status`, not by expecting the project to disappear entirely.

        **The deletion is attributed to the API key's creator.** The app's Trash
        page shows them under "Deleted by", and the workspace Activity Log
        records a `deleted` entry naming them — so a deletion made through the
        API is auditable exactly like one made in the app.

        Rate limited — see the `429` response. Deletes share ONE budget across
        every `DELETE` endpoint on this API (about 20 per minute per key, plus
        daily ceilings per key and per workspace), and the budget counts
        attempts, so `404`s and idempotent repeats spend it too. **Never loop
        this endpoint over a list of ids**; that is what the budget exists to
        stop.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      responses:
        "204":
          description: Project (and its active tasks) moved to Trash.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/sub-folders:
    post:
      tags: [Projects]
      operationId: createSubFolder
      summary: Create a sub-folder
      description: |
        Creates a sub-folder — a TASK group inside the project (the
        `subFolders` of `GET /api/v1/projects/{id}`; never one of the
        project's file `folders`) — at the end of the project's sub-folder
        list, exactly like the app's **New sub-folder**. Put tasks into it
        with `subFolderId` on `POST /api/v1/tasks` or
        `PATCH /api/v1/tasks/{id}`. *(1.176.0)*

        `name` is trimmed and must be 1–120 characters; any other body field
        is a `400` naming it. A project in the Trash is a `400` (restore it in
        the app first). Names need not be unique — read `subFolders` first and
        reuse one that fits. No notification or webhook fires.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [name]
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                  description: The sub-folder's name (surrounding spaces are trimmed).
            examples:
              default:
                value:
                  name: Hook cuts
      responses:
        "201":
          description: The new sub-folder.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SubFolder"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/share-link:
    get:
      tags: [Share Links]
      operationId: getProjectShareLink
      summary: Get the project's task-board share link
      description: |
        Returns the project's existing public share link (the one that
        exposes the project's task board to external reviewers). Returns
        `null` if no share link has been created yet.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      responses:
        "200":
          description: |
            The share link if one exists, otherwise `null`.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/ShareLink"
                  - type: "null"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Share Links]
      operationId: createProjectShareLink
      summary: Create or refresh the project's share link
      description: |
        Idempotently ensures the project has an active public share link at the
        requested `accessLevel`. If an **active** link already exists at that
        level it is returned unchanged (same `token` and `url`).

        If the link at that level was previously **revoked** (deactivated), it
        is re-enabled with a **new `token` and `url`** — deactivating a share
        revokes the URL that was handed out, and that revoked URL never starts
        working again. Re-read `url` from the response after every reactivation
        instead of caching the one you saw before revoking; the share row `id`
        is stable across the flip, the token is not.

        A project that has been moved to the Trash returns `404` — trashing a
        project takes its public links offline, and this endpoint will not put
        one back online.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateShareLinkInput"
            examples:
              default:
                value:
                  accessLevel: commenter
                  duration: 30d
      responses:
        "200":
          description: An existing share link was reactivated or had its access level updated.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ShareLink"
        "201":
          description: A new share link was created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ShareLink"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/batch-links:
    get:
      tags: [Share Links]
      operationId: listProjectBatchLinks
      summary: List the project's batch share links
      description: |
        A **batch link** opens a hand-picked, ordered set of the project's tasks
        as ONE public URL — the Frame.io-style "here are this week's three cuts"
        link — under a `label` the client sees as the title and an optional
        `note`. Newest first; switched-off links are included (`isActive: false`)
        so a client can re-enable one with `PATCH … { "isActive": true }`.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      responses:
        "200":
          description: The project's batch links.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/BatchShareLink"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Share Links]
      operationId: createProjectBatchLink
      summary: Share a batch of the project's tasks as one link
      description: |
        Creates ONE public link that opens exactly the tasks in `taskIds`, in
        that order. **Not idempotent** — every call mints a new link with its
        own `token`/`url`; list first when one may already exist.

        Creating a link never changes a task's status and notifies nobody — the
        link is the handoff, like a single task's link. The client sees every
        listed task whatever stage it is in; an approver can only approve or
        request changes on one in client approval. Anyone holding the URL gets
        `accessLevel` (default `approver`) without signing in. Since 1.181.0 the
        former `moveToClientApproval` and `notifyClients` fields do nothing: a
        call that still sends them gets its link, and no task moves.

        Every id must be an active regular or parent task of **this** project
        (never a variant); a foreign, trashed or unknown id answers `400`
        naming it. A project in the Trash answers `404`.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateBatchShareLinkInput"
            examples:
              default:
                value:
                  taskIds:
                    - 6a1f3d2e-0b5c-4e8f-9a7d-1c2b3e4f5a6b
                    - 7b2a4e3f-1c6d-4f90-8b8e-2d3c4f5a6b7c
                    - 8c3b5f40-2d7e-4a01-9c9f-3e4d5a6b7c8d
                  label: Launch cut v2 — 3 videos
                  note: Please check the hook on the second one.
                  accessLevel: approver
                  duration: 7d
      responses:
        "201":
          description: The batch link was created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchShareLink"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/batch-links/{linkId}:
    get:
      tags: [Share Links]
      operationId: getProjectBatchLink
      summary: Get one batch share link
      parameters:
        - $ref: "#/components/parameters/ProjectId"
        - $ref: "#/components/parameters/BatchLinkId"
      responses:
        "200":
          description: The batch link.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchShareLink"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Share Links]
      operationId: updateProjectBatchLink
      summary: Edit a batch share link
      description: |
        Change any of `label`, `note`, `taskIds`, `accessLevel`, `duration`,
        `isActive` — at least one. `taskIds` replaces the **whole** set and its
        order, and no task changes status. `isActive: false` switches the
        link off; `isActive: true` on a switched-off link turns it back on with
        a **new `token`/`url`** (the old URL never works again — re-read `url`).
        `duration` resets the expiry from now.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
        - $ref: "#/components/parameters/BatchLinkId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateBatchShareLinkInput"
            examples:
              reorder:
                value:
                  taskIds:
                    - 8c3b5f40-2d7e-4a01-9c9f-3e4d5a6b7c8d
                    - 6a1f3d2e-0b5c-4e8f-9a7d-1c2b3e4f5a6b
                  note: null
      responses:
        "200":
          description: The updated batch link.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchShareLink"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Share Links]
      operationId: revokeProjectBatchLink
      summary: Switch a batch share link off
      description: |
        Revokes the link: its URL stops opening for everyone. The row stays
        listed with `isActive: false`, and `PATCH { "isActive": true }` turns it
        back on with a new URL. Idempotent — revoking an already-off link is
        `204`. Counts toward the key's destructive-call budget.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
        - $ref: "#/components/parameters/BatchLinkId"
      responses:
        "204":
          description: The link is switched off.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/share-link:
    get:
      tags: [Share Links]
      operationId: getBrandShareLink
      summary: Get the brand's client-portal share link
      description: |
        Returns the brand's public share link — ONE URL that shows the client
        every project of the brand (the brand's client portal), the same link
        the brand's **Share** dialog in the app shows. Returns `null` if the
        brand has never had one. Since 1.112.0.

        A brand can hold one link per access level. This returns the one the
        Share dialog shows: an active link first (preferring the access level
        last picked under General Access in the dialog, then the newest), else
        the newest switched-off link. Check `isActive` and `expiresAt` — a
        switched-off or expired link no longer opens. To get a working link at a
        specific access level, `POST` instead; to read only a working link, use
        `shareLink` on `GET /api/v1/brands/{id}`.

        Only brands and clients have share links: a folder id, or a brand that
        has been moved to the Trash, returns `404`.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: |
            The share link if one exists, otherwise `null`.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/ShareLink"
                  - type: "null"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Share Links]
      operationId: createBrandShareLink
      summary: Create or refresh the brand's client-portal share link
      description: |
        Idempotently ensures the brand has a working public share link at the
        requested `accessLevel` — one URL that opens **every project of the
        brand** to anyone holding it, at that access level. It is the same link
        the brand's **Share** dialog creates and shows, so a link made here
        appears in the dialog and a link made in the dialog is returned here.
        Since 1.112.0.

        - An **active, unexpired** link at that level is returned unchanged
          (`200`, same `token` and `url`).
        - A link at that level that was **switched off** or has **passed its
          expiry** is turned back on with a **new `token` and `url`** and a fresh
          expiry from `duration` (`200`). The old URL never starts working again;
          the share `id` stays the same. This differs from
          `POST /api/v1/projects/{id}/share-link`, which returns an expired link
          as-is — re-read `url` from the response every time instead of caching
          it, so an automation never sends a client a dead link.
        - Otherwise a new link is created (`201`).

        A folder id, or a brand that has been moved to the Trash, returns `404`
        — trashing a brand takes its links offline, and this endpoint will not
        put one back online. Creating a new link needs the API key's creator to
        still exist (`400` otherwise).
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateShareLinkInput"
            examples:
              default:
                value:
                  accessLevel: approver
                  duration: 30d
      responses:
        "200":
          description: The existing link was returned unchanged, or re-issued with a new `token`/`url`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ShareLink"
        "201":
          description: A new share link was created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ShareLink"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/approval:
    put:
      tags: [Tasks]
      operationId: setVariantApproval
      summary: Set a variant's approval
      description: |
        Sets a VARIANT's own status — the Pending / Approved / Changes
        requested pill the app shows on every variant (`approvalState`:
        `pending`, `approved`, or `rejected` = "Changes requested"). A
        variant's `statusGroup` always follows its parent's, so this is the
        one status a variant changes on its own; to move the work through the
        workflow, `PATCH` the PARENT's `statusGroup`. *(1.176.0)*

        It does what the pill does in the app: `rejected` counts a revision
        round on the variant; approving the last pending variant can move the
        parent to its next stage (the workspace's auto-advance); and the
        variant's assignees and the project's supervisors and admins are
        notified (in-app, email, WhatsApp where configured). The key acts with
        admin authority — any stage — and the key's creator is recorded as the
        reviewer. Setting the value it already has changes nothing but is not
        an error. `updatedAt` moves when the value changes.

        `400` when the task is not a variant (a parent's approval is set on
        each of its variants; a regular task has none), when the variant is in
        the Trash, or when the key's creator no longer exists.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [approvalState]
              properties:
                approvalState:
                  type: string
                  enum: [pending, approved, rejected]
                  description: "`rejected` is the app's \"Changes requested\"."
            examples:
              approve:
                value:
                  approvalState: approved
      responses:
        "200":
          description: The variant, with its new `approvalState`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Task"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/share-link:
    get:
      tags: [Share Links]
      operationId: getTaskShareLink
      summary: Get one task's share link
      description: |
        Returns ONE task's public review link — the link the task's **Share**
        button gives in the app, which opens only that task (its player and
        comments), never the project's board. Returns `null` if the task has
        never had one. Since 1.131.0.

        This returns the link the task's Share window shows: an active link
        first (preferring the access level last picked under General Access —
        which a `POST` sets — then the newest), else the newest switched-off
        link. Check `isActive` and `expiresAt` — a switched-off or expired link
        no longer opens. To get a working link at a specific access level,
        `POST` instead.

        A task that has been moved to the Trash (or whose project has) returns
        `404` — since 1.149.2 with `reason: "task_trashed"` and an `error`
        naming the Trash, instead of the bare `Task not found`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      responses:
        "200":
          description: |
            The share link if one exists, otherwise `null`.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/ShareLink"
                  - type: "null"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/TaskShareLinkNotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Share Links]
      operationId: createTaskShareLink
      summary: Create or refresh one task's share link
      description: |
        Idempotently ensures ONE task has a working public review link at the
        requested `accessLevel` — a URL that opens **only this task** (its
        player and comments) to anyone holding it, at that access level, never
        the project's board. It is the same link the task's **Share** button
        creates and shows, so a link made here appears in the task's Share
        window and a link made there is returned here. Since 1.131.0.

        - An **active, unexpired** link at that level is returned unchanged
          (`200`, same `token` and `url`).
        - A link at that level that was **switched off** or has **passed its
          expiry** is turned back on with a **new `token` and `url`** and a fresh
          expiry from `duration` (`200`). The old URL never starts working again;
          the share `id` stays the same. Like the brand endpoint, and unlike
          `POST /api/v1/projects/{id}/share-link` (which returns an expired link
          as-is) — re-read `url` from the response every time instead of caching
          it, so an automation never sends a client a dead link.
        - Otherwise a new link is created (`201`).

        **Changing the access level replaces the link (since 1.138.0).** When
        the task already has an active link at a DIFFERENT level than the one
        requested (the link `GET` returns), this call switches the task to the
        new level: every link to this task at any other level is switched off
        first — its URL stops opening, for good — and the requested level's
        link is returned and becomes the one the task's Share window shows. So
        after a level change the task has exactly ONE working link, the one in
        the response; never send an older URL after changing the level. A
        repeat at the SAME level changes nothing and switches nothing off.
        Before 1.138.0 a second level left the first link working beside it,
        where the Share window no longer showed it.

        A parent task's id shares all its variants; a variant's id shares just
        that variant (the Share window's "Share All Variants" / "Share This
        Variant"). A task that has been moved to the Trash (or whose project
        has) returns `404` — this endpoint never puts a trashed task online.
        Since 1.149.2 that `404` says so (`reason: "task_trashed"`) rather than
        reading like an unknown id: `GET /api/v1/tasks` lists trashed tasks
        too (`status: "trashed"`), so share only a task whose `status` is
        `active`. A project, file or other id of your workspace, or a
        shortened or (since 1.159.1) mistyped task id, is named in the `404`
        as well.
        The call needs the API key's creator to still exist (`400` otherwise).
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateShareLinkInput"
            examples:
              default:
                value:
                  accessLevel: commenter
                  duration: 7d
      responses:
        "200":
          description: |
            The existing link at that level was returned unchanged, or re-issued
            with a new `token`/`url` (on a level change, the task's links at
            other levels were switched off).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ShareLink"
        "201":
          description: |
            A new share link was created (on a level change, the task's links at
            other levels were switched off).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ShareLink"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/TaskShareLinkNotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks:
    get:
      tags: [Tasks]
      operationId: listTasks
      summary: List tasks
      description: |
        Returns tasks across the workspace's projects, newest first.
        Cursor-paginated. Optionally filter to a single project, or look a task
        up by its permanent human-readable handle (`taskId`, e.g. `TL-1042`).
        `statusGroup`, `status`, `assigneeId`, `kind` and `approvedFrom` /
        `approvedTo` narrow the list server-side and combine with AND. Tasks in
        the Trash are listed too, with `status: trashed`, unless you pass
        `status=active`.
      parameters:
        - $ref: "#/components/parameters/Limit"
        - $ref: "#/components/parameters/Before"
        - name: projectId
          in: query
          description: Restrict results to a single project (must belong to the same workspace).
          required: false
          schema:
            type: string
            format: uuid
        - name: taskId
          in: query
          description: |
            Exact lookup by the task's permanent handle (`TL-1042`), the
            identifier people quote in email and chat. Case-insensitive. Always
            scoped to your own workspace, so a handle that happens to match
            another workspace's prefix will not resolve. Returns an empty page
            when the workspace has task IDs switched off.
          required: false
          schema:
            type: string
            example: TL-1042
        - name: statusGroup
          in: query
          description: |
            One status group, or a comma-separated list matched as OR — e.g.
            `inProgress,inRevision` for the open editing work. An unknown value
            is a 400. *(1.99.0)*
          required: false
          schema:
            type: string
            example: inProgress,inRevision
        - name: status
          in: query
          description: |
            `active` leaves out tasks in the Trash; `trashed` returns only those.
            Omitted, both are listed. A trashed task keeps its `statusGroup`, so
            `statusGroup` alone does not leave it out. Use `active` when you will
            act on the results: a trashed task has no share link, for one. Any
            other value is a 400. *(1.167.0)*
          required: false
          schema:
            type: string
            enum: [active, trashed]
        - name: assigneeId
          in: query
          description: |
            Only tasks this team member (an id from `GET /members`) is assigned
            to, or the literal `none` for tasks with no assignee. Combine with
            `statusGroup` for "what is this editor working on". *(1.99.0)*
          required: false
          schema:
            type: string
            example: none
        - name: kind
          in: query
          description: Only tasks of this kind. *(1.99.0)*
          required: false
          schema:
            type: string
            enum: [regular, parent, variant]
        - name: approvedFrom
          in: query
          description: |
            Only tasks whose `approvedAt` falls on or after this UTC day. Tasks
            never approved are excluded. *(1.99.0)*
          required: false
          schema:
            type: string
            format: date
        - name: approvedTo
          in: query
          description: |
            Only tasks whose `approvedAt` falls on or before this UTC day
            (inclusive). Earlier than `approvedFrom` is a 400. *(1.99.0)*
          required: false
          schema:
            type: string
            format: date
      responses:
        "200":
          description: Page of tasks.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Tasks]
      operationId: createTask
      summary: Create a task
      description: |
        Create a task inside a project. Variants are created by setting
        `kind: variant` and providing the `parentTaskId` of an existing
        regular task in the same project. `parentTaskId` is only valid on a
        variant create — sending it while `kind` is `regular` (or omitted,
        which defaults to `regular`) returns 400.

        **Creating a variant turns the target into a parent task.** A regular
        task named as `parentTaskId` is promoted to `kind: parent` as part of
        the same call, which is what makes the new variant appear nested under
        it in the app; read the task back and it reports `kind: "parent"`.
        Promotion happens before the variant is inserted, and a task that is
        already a parent is simply added to, so several variant creates sent at
        the same moment for one task all succeed under that one parent. A
        variant create is refused with 400 when `parentTaskId` names a task that
        is in the trash, is itself a variant, or already has a file of its own
        (a parent task holds no file — upload to its variants instead), and with
        409 only when a file is attached to the target, or it is moved to the
        trash, between the check and the write (nothing is created — retry).
        When `statusGroup` is omitted on a variant create the variant
        inherits the parent's stage rather than defaulting to `toDo`; an
        explicit value still wins.

        **Variant order — a carousel's slide order (1.163.1).** A new variant
        goes after the parent's last one, so creating Slide 1 … Slide 6 in
        order gives them `position` 0 … 5 — the order the app lists them in
        and a carousel post publishes them in. Send `position` (variants
        only) to put it in another slot; a number past the end puts it last.
        Before 1.163.1 every variant the API created shared one rank, so a
        carousel built through the API showed and published in an arbitrary
        order; set `position` on any one of its variants
        (`PATCH /api/v1/tasks/{id}`) to fix the order of all of them.

        Place the task inside one of the project's sub-folders (task groups)
        with `subFolderId` — it must belong to the same project; omit it for
        the project root.

        **Text-first posts (LinkedIn / Facebook).** A `type: doc` task can be
        created together with its document: send `text` (a plain string — each
        line becomes a paragraph and each blank line stays a blank line, so a
        post publishes with exactly that spacing; markup is treated as literal
        text) or `contentHtml` (when the copy needs bold or lists). Send one
        or the other, never both, and only with `type: doc` (400 otherwise).
        The document is that task's post text: attach an optional image, video
        or PDF with `POST /files/upload-from-url` and the new task id, then
        `POST /posts/{taskId}/schedule`. Later text edits go through
        `PATCH /tasks/{id}/doc`.

        **Pricing at creation (1.125.0).** `pricingTemplateId` prices the new
        task with a pricing template, exactly as the app's pricing dialog does
        (pricing tag, default client price, editor pay). The response's
        `pricing` block shows the result. Needs the `write:finance` scope.

        The body must be a JSON object. Since 1.149.3 any other JSON value
        (`null`, an array, a string — e.g. a body that was JSON-encoded
        twice — or a number) returns 400 `Body must be a JSON object` and
        creates nothing; `null` used to return 500.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTaskInput"
            examples:
              minimal:
                value:
                  projectId: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
                  title: Hook variant — A
              textPost:
                summary: A text-first post, created with its text
                value:
                  projectId: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
                  title: Founder story — Tuesday
                  type: doc
                  text: "I got fired on a Tuesday.\n\nBest thing that ever happened to me.\n\nWhat would you add?"
              variant:
                summary: A variant of an existing task
                value:
                  projectId: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
                  title: Hook variant — B
                  kind: variant
                  parentTaskId: 92efb8d6-3b6c-4e9f-9c25-d2e7f4dc0a01
                  type: media
                  statusGroup: inProgress
              coverSlide:
                summary: A carousel's cover slide, put first among the parent's variants
                value:
                  projectId: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
                  title: Slide 0 — cover
                  kind: variant
                  parentTaskId: 92efb8d6-3b6c-4e9f-9c25-d2e7f4dc0a01
                  position: 0
              priced:
                summary: A task priced with a pricing template at creation
                value:
                  projectId: 8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01
                  title: Shoot recap — Reel 1
                  pricingTemplateId: 5f1c2a3b-4d5e-4f60-8a71-9b0c1d2e3f40
      responses:
        "201":
          description: Task created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Task"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The pricing fields need the `write:finance` scope on this API key.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          description: |
            `projectId` is no project of your workspace, and nothing was
            created. When the id is something else of your own workspace — a
            task, a sub-folder (task group), a folder inside a project's files,
            a brand or folder, an HQ item or a file — or a project id shortened
            and padded back out (its first 8 characters matching a project of
            your workspace), `error` names which and what to send instead. An
            unknown id, or a project in another workspace, keeps the plain
            `Project not found` error: the two are deliberately
            indistinguishable, and no body echoes the id back. Since 1.192.0
            that plain body also carries `"reason": "project_not_found"` (a
            named mistake has no `reason`), and a project lookup that FAILS on
            our side answers `500`, never this `404`. Get the project's id again
            (`GET /api/v1/projects`) and send all 36 characters.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskCreateNotFoundError"
              examples:
                unknownProject:
                  summary: Unknown project id, or a project in another workspace
                  value:
                    error: Project not found
                    reason: project_not_found
                taskIdAsProjectId:
                  summary: A task's id was sent as the project id
                  value:
                    error: >-
                      Project not found. That id is a task in this workspace —
                      pass its project's id,
                      8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01, as `projectId`. To
                      create a variant under that task, also send kind:
                      "variant" with the task's id as `parentTaskId`.
                subFolderIdAsProjectId:
                  summary: A sub-folder's id was sent as the project id
                  value:
                    error: >-
                      Project not found. That id is a sub-folder (task group) in
                      this workspace — pass its project's id,
                      8b2c4d2f-9a4d-4f7f-9b0b-2c2c1e9f1a01, as `projectId` and
                      the sub-folder's id as `subFolderId`.
        "409":
          description: |
            The task named by `parentTaskId` stopped being able to hold variants
            between the check and the write (a file was attached, or it was
            moved to the trash). Another variant create promoting the same task
            first is not this answer: that create and this one both succeed.
            Nothing was created — retry the request.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}:
    get:
      tags: [Tasks]
      operationId: getTask
      summary: Retrieve a task
      parameters:
        - $ref: "#/components/parameters/TaskId"
      responses:
        "200":
          description: The task, including its custom-column cell values.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskWithCustomValues"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Tasks]
      operationId: updateTask
      summary: Update a task
      description: |
        Updates one or more of the allow-listed fields. Any other fields
        in the body are silently ignored. When `statusGroup` changes, the
        same notification flow used by the UI is fired (in-app, email,
        and WhatsApp where configured), and the move is recorded in the
        task's status history (1.91.0) exactly like an in-app move — so it
        counts in the in-app editor throughput report (when work left the
        editor, how long it waited on client approval).

        `assigneeIds` assigns team members to the task. It is a **full
        replace** of the task's assignees (the `Task.editors` set): send the
        complete list you want, `[]` to clear all, and to add one person send
        the task's current `assigneeIds` (from the GET response) plus the new
        id. Every id must be a team member of this workspace — guests and
        members of other workspaces are rejected with 400. Newly-added members
        are notified the same way the UI assignment notifies them.

        **Reserved ids (1.136.0).** A few reserved system ids are not team
        members. They are rejected with the same 400 as any other non-member
        unless enabled for the workspace or for the person who created the
        API key (1.161.0); one already on the task is kept
        and can always be removed. A reserved id never takes a pay role in
        `assigneeRoles` (400). Nothing is written on a 400.

        `subFolderId` moves the task into a sub-folder (task group) of its
        project — it must belong to the task's project (400 otherwise) — or
        back to the project root with `null`.

        **Move to another project, folder or brand (1.221.0).** `projectId`
        moves the task to another project of this workspace — in the same
        brand, under another folder, or under **another brand** (a task
        always lives in a project, so the project names the folder and brand
        too). It lands at the project root, or in one of THAT project's
        sub-folders when `subFolderId` is in the same body (400 when the
        sub-folder belongs to any other project). The move keeps the task's
        status, puts it at the bottom of its status column, takes its files
        and versions along, and a parent takes every variant with it — a
        variant itself is refused with 400 (send `projectId` to its
        `parentTaskId`). Assignees without access to the new project are
        dropped, unless `assigneeIds` is in the same body. A custom status the
        new brand does not use falls back to its built-in status. Crossing
        brands hands the work to the other client: its pending scheduled posts
        lose their social account (status `manual`, so nothing auto-publishes
        to the old client's account) and its post drafts' accounts are
        cleared. An unknown `projectId` or another workspace's project returns
        404 (the body names a task, sub-folder, brand or folder id sent by
        mistake); the task's current project is a no-op. The move emits
        `task.updated` with `projectId` in `changed` (plus `brandId` when it
        crossed a brand and `assigneeIds` when assignees were dropped) — when
        the same request also changes `statusGroup` or `assigneeIds`, that
        change's `task.updated` carries the event instead.

        **Reorder a carousel (1.163.1).** `position` moves a variant to that
        0-based slot under its parent — `0` makes it the first slide — and the
        parent's other variants keep their order around it. The app's variant
        list, the post composer and the published carousel follow it, unless
        someone arranged that post's slides in the app's post composer and
        saved them there (the composer's saved slide order then wins). A
        number past the end puts it last. Refused with 400 on a regular or
        parent task and on a variant in the trash. A carousel whose variants
        were all created before 1.163.1 is put in a fixed order by the first
        `position` you set on any of its variants. A move alone does not
        change `updatedAt` and emits no `task.updated` webhook.

        **Pricing (1.125.0).** `pricingTemplateId` applies a pricing template
        and `assigneeRoles` says which template role each assignee fills —
        the same write as `PUT /api/v1/tasks/{id}/pricing`, recomputed by the
        in-app engine, so the assignee's pay appears in
        `GET /api/v1/pricing/payables`. Send them with `assigneeIds` to
        assign, tag and price in one call; every pricing check (unknown
        template or role, a member who is not an assignee after the request,
        the pricing lock) runs before anything is written, so a refused
        request changes nothing. Both need the `write:finance` scope (403).
        Refused with 409 once money has moved on the task. Changing
        `assigneeIds` on a priced task now recomputes its pay exactly as an
        in-app assignment does — a newly-assigned editor gets their pay row,
        a removed one loses theirs. A pricing change fires no webhook (the
        app's pricing dialog fires none either); it is recorded in the task's
        History like an in-app change.

        **The body must be a JSON object (1.149.3).** Any other JSON value —
        `null`, an array, a string (a body JSON-encoded twice arrives as one)
        or a number — returns 400 `Body must be a JSON object` and changes
        nothing; `null` and a string used to return 500. A task's document is
        not edited here: send `contentHtml` / `baseRev` to
        `PATCH /api/v1/tasks/{id}/doc`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateTaskInput"
            examples:
              statusOnly:
                summary: Move the task to "In progress"
                value:
                  statusGroup: inProgress
              renameAndSchedule:
                value:
                  title: New title
                  internalDeadline: "2026-06-30"
                  externalDeadline: "2026-07-07"
              assignMembers:
                summary: Assign two team members (full replace)
                value:
                  assigneeIds:
                    - "11111111-1111-1111-1111-111111111111"
                    - "22222222-2222-2222-2222-222222222222"
              clearAssignees:
                summary: Remove all assignees
                value:
                  assigneeIds: []
              moveSlideToFront:
                summary: Make this variant the first slide of its parent's carousel
                value:
                  position: 0
              assignTagAndPrice:
                summary: Assign an editor, tag their template role and price the task
                value:
                  assigneeIds:
                    - "11111111-1111-1111-1111-111111111111"
                  assigneeRoles:
                    - memberId: "11111111-1111-1111-1111-111111111111"
                      roleLabel: Online Editor
                  pricingTemplateId: 5f1c2a3b-4d5e-4f60-8a71-9b0c1d2e3f40
      responses:
        "200":
          description: The updated task.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Task"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The pricing fields need the `write:finance` scope on this API key.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          description: |
            No task with this id is in your workspace, and nothing was written.
            When the id is some OTHER row your own workspace owns — a project,
            a brand or folder, a custom column, an HQ item or a file — or a
            task id with one or two characters wrong or shortened (its first 8
            characters matching a task of your workspace), `error` names which
            and what to send instead. An unknown id, or a task in another
            workspace, keeps the plain `Task not found` error: the two are
            deliberately indistinguishable, and no body echoes the id back.
            Since 1.166.0 that plain body also carries
            `"reason": "task_not_found"` (a named mistake has no `reason`), and
            a task lookup that FAILS on our side answers `500`, never this
            `404`. Get the task's id again (`GET /api/v1/tasks`) and send all 36
            characters.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskUpdateNotFoundError"
              examples:
                unknownTask:
                  summary: Unknown task id, or a task in another workspace
                  value:
                    error: Task not found
                    reason: task_not_found
                projectIdAsTaskId:
                  summary: A project id was sent as the task id
                  value:
                    error: >-
                      Task not found. That id is a project in this workspace —
                      pass one of its task ids (from list_tasks, or GET
                      /api/v1/tasks?projectId=…) in the path.
        "409":
          description: |
            Pricing is locked — money has already moved on the task (a payout
            marked paid, the client price received, or a recorded payment).
            Nothing was written.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Tasks]
      operationId: deleteTask
      summary: Delete a task
      description: |
        Moves the task to Trash (soft-delete) — it and its files leave every
        active list and the client's view at once, and any running timer on it
        is stopped. Restorable from the app's Trash page, but treat it as
        irreversible when you design an integration.

        Idempotent; no notifications fire.

        **The deletion is attributed to the API key's creator.** The app's Trash
        page shows them under "Deleted by", and the workspace Activity Log
        records a `deleted` entry naming them — so a deletion made through the
        API is auditable exactly like one made in the app.

        Rate limited — see the `429` response. Deletes share ONE budget across
        every `DELETE` endpoint on this API (about 20 per minute per key, plus
        daily ceilings per key and per workspace), and the budget counts
        attempts, so `404`s and idempotent repeats spend it too. **Never loop
        this endpoint over a list of ids.**
      parameters:
        - $ref: "#/components/parameters/TaskId"
      responses:
        "204":
          description: Task moved to Trash.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/doc:
    get:
      tags: [Tasks]
      operationId: getTaskDoc
      summary: Read a task's document body / brief
      description: |
        Reads a task's rich-text content. For a `doc` task this is the document
        body; for a `media` task it is the brief/description (both are stored in
        the single `content_text` column). Returns `contentHtml` (raw HTML),
        `type` (doc | media), `rev` — a monotonic version counter to pass
        back as `baseRev` on the next write for conflict-safe saves — and
        `links` (since 1.148.0): every hyperlink in the content as
        `{ text, url }`, so a file the brief links to (a voice-over on
        Dropbox, a deck on Google Drive) can be fetched without parsing the
        HTML. The `url` is decoded (`&amp;` in a query string comes back as
        `&`), in document order; only `http(s)` and `mailto` targets are
        listed, a repeated identical link once, at most 200. Since 1.153.1 a
        link saved without a scheme (`www.dropbox.com/…`, `we.tl/…`) is
        listed with `https://` added instead of being left out. Since
        1.194.0 `docAttachments` lists every file uploaded INTO the content (a
        .docx chip in a brief, an inline image) with a 7-day `downloadUrl`
        (`null` without the `read:files` scope) — the chip's own
        `/api/brief-attachment/…` address needs a signed-in session. A
        variant has its own brief — read its parent's with this endpoint on
        the parent task's id.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      responses:
        "200":
          description: The task's document content.
          content:
            application/json:
              schema:
                type: object
                properties:
                  taskId:
                    type: string
                    format: uuid
                  type:
                    type: string
                    enum: [doc, media]
                  contentHtml:
                    type: string
                    description: The raw HTML of the document body / brief.
                  rev:
                    type: integer
                    description: Version counter — pass as `baseRev` on the next write.
                  links:
                    type: array
                    description: |
                      Every hyperlink in `contentHtml`, in document order (since
                      1.148.0). `[]` when the content has none.
                    items:
                      $ref: "#/components/schemas/DocLink"
                  docAttachments:
                    type: array
                    description: |
                      Every file uploaded into `contentHtml`, in document order
                      (since 1.194.0), at most 50. `[]` when it has none.
                    items:
                      $ref: "#/components/schemas/DocAttachment"
                required: [taskId, type, contentHtml, rev, links, docAttachments]
              example:
                taskId: "9b2f6a40-1c3e-4d8a-9f0b-3e5d7c2a1b64"
                type: media
                contentHtml: '<h1><a href="https://www.dropbox.com/s/abc123/lauren-vo.wav?dl=1&amp;raw=1">Lauren VO Download</a></h1><p>This is Lucky Ladd Farms!</p>'
                rev: 5
                links:
                  - text: Lauren VO Download
                    url: "https://www.dropbox.com/s/abc123/lauren-vo.wav?dl=1&raw=1"
                docAttachments: []
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Tasks]
      operationId: updateTaskDoc
      summary: Write a task's document body / brief
      description: |
        Writes the rich-text content of a task — the document body of a `doc`
        task, or the brief/description of a `media` task. `contentHtml` is a
        **full replace** of the existing content. The write routes through the
        same guarded save the in-app doc editor uses, so the version counter
        advances atomically. Supply `baseRev` (the `rev` from GET) for a
        conflict-safe write: a stale base answers **409** with
        `reason: "stale_base_rev"`, a short `error`, and the current server
        state (`currentRev`, `currentContent`) so you can refresh instead of
        clobbering a concurrent edit. Every successful write returns the new
        `rev` — use it as `baseRev` for your next write. Re-sending exactly the
        HTML the document already holds is not a conflict: it answers **200**
        with `unchanged: true` and writes nothing (no new `rev`, no restore
        point). To change only part of the content, prefer
        `POST /api/v1/tasks/{id}/doc/edits`, which needs no `baseRev`. Omit
        `baseRev` (or pass `null`) to force-overwrite. For `doc` tasks a
        restore point is captured in the document's version history on every
        successful write.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contentHtml:
                  type: string
                  maxLength: 1000000
                  description: The full new HTML content. Empty string clears it.
                baseRev:
                  type: [integer, "null"]
                  minimum: 0
                  description: The `rev` from GET, for a conflict-safe write. Omit or null to force-overwrite.
              required: [contentHtml]
            examples:
              writeDoc:
                summary: Write a document body
                value:
                  contentHtml: "<h2>Script</h2><p>Open on the product shot.</p>"
                  baseRev: 3
              forceWrite:
                summary: Force-overwrite (no base rev)
                value:
                  contentHtml: "<p>Updated brief.</p>"
      responses:
        "200":
          description: "The content was written — or, with `unchanged: true`, the document already held exactly this HTML and nothing was written."
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  rev:
                    type: integer
                    description: The document's version counter after the call — the new rev after a write, the current rev when `unchanged` is true.
                  versionCreated:
                    type: boolean
                    description: True when a restore point was saved (doc tasks with a resolvable author).
                  unchanged:
                    type: boolean
                    description: |
                      Present (true) only when `baseRev` was stale but the document
                      already held exactly the HTML sent — a re-send of a write that
                      landed. Nothing was written: `rev` is the current one and no
                      restore point was saved.
                required: [ok, rev, versionCreated]
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: |
            Optimistic-concurrency conflict — `baseRev` did not match the current
            server rev, and the document holds different content. Nothing was
            written. Body carries the current state to refresh from.
          content:
            application/json:
              schema:
                type: object
                properties:
                  conflict:
                    type: boolean
                  reason:
                    type: string
                    enum: [stale_base_rev]
                    description: Machine-readable cause — branch on this, not on `error`.
                  error:
                    type: string
                    description: |
                      Short explanation naming both revs and the two ways forward
                      (re-read and merge, or `POST /api/v1/tasks/{id}/doc/edits`).
                      Never carries document content.
                  currentRev:
                    type: integer
                  currentContent:
                    type: [string, "null"]
                required: [conflict, reason, error, currentRev]
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/doc/edits:
    post:
      tags: [Tasks]
      operationId: editTaskDoc
      summary: Edit part of a task's document body / brief
      description: |
        Changes PART of a task's rich-text content — the document body of a
        `doc` task, or the brief of a `media` task — without resending the
        whole thing. Since 1.114.0.

        Each edit names where it goes:

        - **`append`** (`html`) — adds `html` at the end of the document.
        - **`prepend`** (`html`) — adds `html` at the start of the document.
        - **`replaceSection`** (`heading`, `html`) — replaces the section: the
          heading AND everything after it up to the next top-level heading of
          the same or a higher level (or the end). Start `html` with the
          heading to keep it; `""` deletes the section.
        - **`appendToSection`** (`heading`, `html`) — adds `html` at the end
          of that section, before the next heading that ends it.
        - **`replaceText`** (`find`, `html`) — replaces `find`, a piece of the
          stored HTML (as `GET /tasks/{id}/doc` returns it) that occurs
          exactly once. `""` deletes it. Copying it exactly is safest; since
          1.134.2 a `find` that occurs nowhere verbatim is looked up once more
          ignoring how `&` / `"` / `'` / a hard space are spelled (`&amp;` vs
          `&`, `&nbsp;` vs a space), runs of whitespace, and line breaks or
          indents between tags. Tags and attributes still have to match, and
          `&lt;` / `&gt;` stay as written.

        `heading` matches a heading (`<h1>`–`<h6>`) on its visible text,
        case and spacing ignored. A top-level heading is looked up first;
        only when none matches, since 1.205.1, a heading inside a toggle
        (`<details>`), callout or quote anchors a section too, and that
        section ends where the block's content ends — an edit never moves
        content out of it. A heading inside a table or a list, or a toggle's
        title, is not a section anchor.

        Edits apply in order — each to the result of the one before — and all
        or nothing. They are applied to whatever the document holds when the
        request lands, so an edit someone makes elsewhere in the document in
        the app (which advances `rev`) does not make this request fail, and no
        fresh `rev` is needed. Every byte outside an edit's range is kept
        exactly as stored. Pass `baseRev` only to require that the document
        is still at that rev (a mismatch answers **409**).

        An anchor that is missing or matches more than once answers **422**
        with `code` and the failing edit's `index`; nothing is written. For
        `doc` tasks a restore point is captured in the document's version
        history on every successful request, as with `PATCH /tasks/{id}/doc`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                edits:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    $ref: "#/components/schemas/DocEdit"
                baseRev:
                  type: [integer, "null"]
                  minimum: 0
                  description: |
                    Optional. Apply only if the document is still at this
                    `rev` (from GET) — **409** otherwise. Omit it to apply the
                    edits to the current content.
              required: [edits]
            examples:
              replaceSection:
                summary: Rewrite one scene of a script
                value:
                  edits:
                    - op: replaceSection
                      heading: Scene 1
                      html: "<h2>Scene 1</h2><p>Open on the product shot, then cut to the founder.</p>"
              appendAndExtend:
                summary: Add a line to one section and credits at the end
                value:
                  edits:
                    - op: appendToSection
                      heading: Intro
                      html: "<p>Hook: three seconds of the reveal.</p>"
                    - op: append
                      html: "<p>Credits: Northwind Studio</p>"
              fixPassage:
                summary: Fix one passage
                value:
                  edits:
                    - op: replaceText
                      find: "<p>Shot on location in Lisbn.</p>"
                      html: "<p>Shot on location in Lisbon.</p>"
      responses:
        "200":
          description: The edits were applied and saved.
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  rev:
                    type: integer
                    description: The new version counter after the write.
                  versionCreated:
                    type: boolean
                    description: True when a restore point was saved (doc tasks with a resolvable author).
                  applied:
                    type: integer
                    description: How many edits were applied (always all of them on success).
                required: [ok, rev, versionCreated, applied]
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: |
            Nothing was written. With `reason: stale_base_rev`, `baseRev` was
            sent and the document is no longer at that rev: send the same edits
            again WITHOUT `baseRev` to apply them to what it holds now (with the
            same `baseRev` it fails the same way). With
            `reason: doc_still_changing` (rare), no `baseRev` was sent and other
            writers kept saving while the edits were being applied, more times
            than the request re-applies them: send the same edits again. The
            body never carries the document; read it with `GET /tasks/{id}/doc`
            only if your edits depend on what changed. `reason` and `error`
            since 1.193.0.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocEditConflict"
              example:
                conflict: true
                reason: stale_base_rev
                error: "Nothing was saved: the document is at rev 12, not the baseRev 9 you sent, so it changed after you read it (a successful write returns the new rev — your own earlier write counts too). Send the same edits again without baseRev to apply them to what it holds now; read it with GET /tasks/{id}/doc first only if they depend on what changed."
                currentRev: 12
        "422":
          description: |
            An edit could not be applied as sent; nothing was written.
            `anchorNotFound` — the heading or `find` text is not in the
            document; on a `replaceText` edit `reason` says why
            (`find_text_absent` or `find_markup_differs`, since 1.224.0).
            `anchorAmbiguous` — it occurs more than once (`matches`
            says how often). `docNotSectionable` — the stored HTML is
            malformed, so sections cannot be located safely (use
            `replaceText`, `append` or `prepend`). `docTooLarge` — the result
            would exceed 1,000,000 characters.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocEditError"
              example:
                error: 'edits[0]: no top-level heading reads "Scene 9" — headings match on their visible text (case and spacing ignored); read the document with GET /tasks/{id}/doc'
                code: anchorNotFound
                index: 0
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/custom-columns:
    patch:
      tags: [Tasks]
      operationId: setTaskCustomValues
      summary: Set a task's custom-column values
      description: |
        Sets one or more custom-column cell values on a task. The body is a map
        of `columnId` → value. Value by the column's kind: text/date/priority
        → a string (date = `YYYY-MM-DD`; priority = `critical|high|medium|low`);
        link → see below; dateRange → `{ start, end }`; select → an `optionId`; tag →
        an ARRAY of `tagId`s.

        **Link columns (1.124.0).** A link cell holds a URL AND linked raw
        files/folders (the app's *Paste a link* and *Choose raw files*). A
        plain URL string sets ONLY the URL — the linked files stay (before
        1.124.0 a URL write cleared them). `{ "url"?: string | null,
        "items"?: [{ "kind", "id" }] }` changes only the keys you send:
        `items` REPLACES the linked files/folders (send the full list; `[]`
        removes them all), `url: null` removes the URL. `null` clears the
        whole cell. `kind` is `projectFile` / `projectFolder` (from
        `GET /api/v1/projects/{id}/files` of the TASK'S project) or
        `brandFile` / `brandFolder` (from `GET /api/v1/brands/{id}/files` of
        that project's brand); any other id — another project's or brand's, a
        task's own file or version, a trashed file, another workspace's —
        is a 400 `link_item_not_allowed` naming it, and nothing is written.
        Since 1.152.2 the `error` also says what a refused id of YOUR
        workspace really is, and which `kind` to send when another one
        would be accepted (a brand raw file sent as `projectFile` → send it
        as `brandFile`; a raw file of another project; a file in the trash);
        an id found nowhere in your workspace keeps the plain sentence. At
        most 200 items per cell. Tag cells are multi-value and the array REPLACES the
        cell — send the full set you want it to end up with, not a delta; `[]`
        clears it. Pass `null` for any column to clear it. A single invalid entry
        rejects the whole request (no partial writes) — including a `tagId` that
        belongs to a different column, or a tag scoped to a brand the task is
        not under (tags are per brand — see `CustomColumn.tags[].brandId`).
        Returns the task's full resolved custom values.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              minProperties: 1
              additionalProperties: true
            examples:
              setLinkAndPriority:
                summary: Set a Dropbox link and a priority
                value:
                  "11111111-1111-1111-1111-111111111111": "https://dropbox.com/s/abc"
                  "22222222-2222-2222-2222-222222222222": "high"
              linkRawFiles:
                summary: Link two raw files to a link column (replaces its linked files, keeps its URL)
                value:
                  "11111111-1111-1111-1111-111111111111":
                    items:
                      - kind: projectFile
                        id: "66666666-6666-6666-6666-666666666666"
                      - kind: projectFile
                        id: "77777777-7777-7777-7777-777777777777"
              setTags:
                summary: Tag a task with two people (replaces the cell's tags)
                value:
                  "33333333-3333-3333-3333-333333333333":
                    - "44444444-4444-4444-4444-444444444444"
                    - "55555555-5555-5555-5555-555555555555"
      responses:
        "200":
          description: The task's custom values after the write.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskCustomValues"
        "400":
          description: |
            A value failed validation, and nothing was written. For a select
            column whose value is not one of THAT column's options, `error`
            starts with `<Column>: optionId does not belong to this column`
            (unchanged since v1), then names the mistake — the option's
            label sent instead of its id, an option of another select
            column, a tag, a column's own id, an id that is no option in
            your workspace, or text that is not an id — and lists the
            column's valid `label = optionId` pairs (the first 20, in the
            column's order; the rest are on `GET /api/v1/custom-columns`).
            The value you sent is never echoed back. An id from another
            workspace reads exactly like an unknown id.

            A KEY that is no custom column of your workspace: `error` starts
            with `Unknown custom column for this workspace: <key>` (unchanged
            since v1), then — since 1.202.1 — says what the id is when your
            workspace knows it (an option of a select column or a tag of a
            tag column sent as the key, with that column's id to send instead;
            the task's own id or its project's id; a column's id in another
            letter case or with one or two characters wrong) and lists your
            workspace's columns as `"Name" (kind) = id` (the first 20, in the
            board's order; the rest are on `GET /api/v1/custom-columns`). A
            deleted column, another workspace's column and an id that exists
            nowhere all read the same.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              examples:
                optionIdSentAsColumnKey:
                  summary: A select option's id was sent as the key (1.202.1)
                  value:
                    error: >-
                      Unknown custom column for this workspace:
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb — that id is an
                      option of the "Stage" select column, not a column — send
                      the column's id 22222222-2222-4222-8222-222222222222 as
                      the key and this option's id as its value. Custom
                      columns in this workspace: "Stage" (select) =
                      22222222-2222-4222-8222-222222222222, "Notes" (text) =
                      33333333-3333-4333-8333-333333333333.
                unknownColumnKey:
                  summary: A key that is no column of this workspace (1.202.1)
                  value:
                    error: >-
                      Unknown custom column for this workspace:
                      00000000-0000-0000-0000-000000000000 — no custom column
                      in this workspace has that id — it may have been deleted
                      or belong to another workspace. Custom columns in this
                      workspace: "Stage" (select) =
                      22222222-2222-4222-8222-222222222222, "Notes" (text) =
                      33333333-3333-4333-8333-333333333333.
                selectLabelInsteadOfId:
                  summary: A select option's label was sent instead of its id
                  value:
                    error: >-
                      Concept: optionId does not belong to this column — that
                      value is this column's option "Approved" — send exactly
                      its optionId bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb. Valid
                      optionIds for "Concept": Draft =
                      aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa, Approved =
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb.
                selectOptionOfAnotherColumn:
                  summary: An option of a different select column was sent
                  value:
                    error: >-
                      Concept: optionId does not belong to this column — that
                      id is an option of the "Stage" column, not this one.
                      Valid optionIds for "Concept": Draft =
                      aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa, Approved =
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb.
                wrongValueType:
                  summary: A value of the wrong shape for the column's kind
                  value:
                    error: "Priority: priority column value must be one of critical|high|medium|low, or null"
                linkItemNotAllowed:
                  summary: A linked file is not a raw file of the task's project
                  value:
                    error: >-
                      Raw footage: projectFile 66666666-6666-6666-6666-666666666666
                      is not a raw file of this task's project — link only raw
                      files and folders of this task's project
                      (list_project_raw_files) or of its brand
                      (list_brand_raw_files)
                    code: link_item_not_allowed
                linkItemWrongKind:
                  summary: A brand raw file sent as projectFile (1.152.2)
                  value:
                    error: >-
                      Raw footage: projectFile 77777777-7777-7777-7777-777777777777
                      is a raw file of this task's brand: send it as { kind:
                      "brandFile", id } — link only raw files and folders of
                      this task's project (list_project_raw_files) or of its
                      brand (list_brand_raw_files)
                    code: link_item_not_allowed
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          description: |
            No task with that id in your workspace, and nothing was written.
            When the id is instead another row your OWN workspace owns — a
            custom column, a project, a brand/folder, or (since 1.112.1) an HQ
            item or a file — `error` names which,
            because the commonest mistake here is sending the custom column's
            id in the path (it belongs in the body) rather than the task's.
            Since 1.159.1 an id that is one of your workspace's task ids with
            **one or two characters wrong** (mistyped — say two characters
            swapped) names that task's id when exactly one is that close, and
            an id that looks **shortened** — its first 8 characters match a
            task of your workspace, the rest padded or made up — names that
            task's full id when exactly one matches. Copy a task id exactly,
            all 36 characters as returned. An unknown id, or a task in another
            workspace (mistyped, padded or not), keeps the plain
            `{"error":"Task not found"}` body: the two are deliberately
            indistinguishable, and no body echoes the id back.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              examples:
                unknownTask:
                  summary: Unknown id, or a task in another workspace
                  value:
                    error: Task not found
                columnIdInPath:
                  summary: The custom column's id was sent in the path
                  value:
                    error: >-
                      Task not found. That id is a custom column in this
                      workspace — the path takes the TASK's id (from
                      list_tasks / search_tasks / create_task, or GET
                      /api/v1/tasks) and the column id belongs in the body, as
                      { "<columnId>": <value> }.
                mistypedTaskId:
                  summary: One of your task ids with two characters swapped
                  value:
                    error: >-
                      Task not found. No task has that exact id, but one task in
                      this workspace has an id that differs from it in only one
                      or two characters: 3f2a9c10-5b7e-4d21-9a8c-1e6f0b2d4c55.
                      The id sent looks mistyped — copy a task id exactly, all
                      36 characters as list_tasks, get_task or create_task
                      returned it, never retyped, shortened or padded. If that
                      is the task you meant, retry with that id.
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/transcript:
    get:
      tags: [Tasks]
      operationId: getTaskTranscript
      summary: Read a task's video transcript
      description: |
        Returns the transcript of a media task's current video as plain text —
        the spoken words, plus language, word count and duration — so an
        integration or agent can reason about what the video is about. `status`
        says what you got: `ready` (text present), `none` (never transcribed),
        `pending` / `extracting` / `processing` (in progress — retry in ~20s),
        `no_speech`, or `failed`. Read-only: this endpoint never starts a
        transcription (`POST /api/v1/posts/{taskId}/caption/generate` and
        `POST /api/v1/tasks/{id}/suggest-tags` do when they need one). 404 when
        the task has no media file, and 404 `file_content_missing` with
        `purgedAt` when the video was removed after the workspace's
        subscription ended — its transcript is hidden with it, and deleted
        with it once the file is permanently deleted (see *Removed media*).
        Requires the `read:tasks` scope.

        **Timings (since 1.206.0).** For *when* things are said, add
        `includeSegments=true` (the timed lines the task's Transcript tab
        shows) and/or `includeWords=true` (every spoken word with its own
        start and end). Times are seconds from the start of the video.
        `fromSeconds` / `toSeconds` narrow both lists to a stretch of the
        video — use a window on long videos, since a word list runs to
        thousands of entries. `text` is always the whole transcript, and
        without these parameters the response is unchanged. Each list is
        `null` while the transcript is not `ready`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
        - $ref: "#/components/parameters/TranscriptIncludeSegments"
        - $ref: "#/components/parameters/TranscriptIncludeWords"
        - $ref: "#/components/parameters/TranscriptFromSeconds"
        - $ref: "#/components/parameters/TranscriptToSeconds"
      responses:
        "200":
          description: The transcript, or its status when no text is available.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskTranscript"
              examples:
                ready:
                  summary: A transcribed video
                  value:
                    taskId: "11111111-1111-1111-1111-111111111111"
                    fileId: "22222222-2222-2222-2222-222222222222"
                    status: ready
                    language: en
                    text: "Hi, I'm Brian from the Sauna Place. Today we're looking at…"
                    wordCount: 812
                    durationSeconds: 271.4
                withTimings:
                  summary: "With timings: ?includeSegments=true&includeWords=true&toSeconds=5 (word list shortened here)"
                  value:
                    taskId: "11111111-1111-1111-1111-111111111111"
                    fileId: "22222222-2222-2222-2222-222222222222"
                    status: ready
                    language: en
                    text: "Hi, I'm Brian from the Sauna Place. Today we're looking at…"
                    wordCount: 812
                    durationSeconds: 271.4
                    segments:
                      - start: 0.12
                        end: 6.84
                        text: "Hi, I'm Brian from the Sauna Place."
                    words:
                      - text: "Hi,"
                        start: 0.12
                        end: 0.46
                      - text: "I'm"
                        start: 0.52
                        end: 0.7
                      - text: "Brian"
                        start: 0.74
                        end: 1.18
                notYet:
                  summary: Never transcribed
                  value:
                    taskId: "11111111-1111-1111-1111-111111111111"
                    fileId: "22222222-2222-2222-2222-222222222222"
                    status: none
                    language: null
                    text: null
                    wordCount: null
                    durationSeconds: null
        "400":
          description: |
            An invalid task id, or a timing parameter that is not valid: a
            flag other than `true` / `false`, a `fromSeconds` / `toSeconds`
            that is not a number of seconds of 0 or more, `fromSeconds` not
            less than `toSeconds`, or a window sent without
            `includeSegments` or `includeWords`. `error` names the parameter.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: Invalid `includeWords` parameter — use true or false
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          description: |
            The task does not exist in this workspace, has no media file, or
            its video was removed after the workspace's subscription ended
            (`code: file_content_missing`, with `purgedAt`) — a removed
            video's transcript is hidden with it, and deleted with it once the
            file is permanently deleted.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              examples:
                noMedia:
                  value:
                    error: Task has no media file
                purged:
                  value:
                    error: File content was removed after the workspace's subscription ended
                    code: file_content_missing
                    purgedAt: "2026-10-20T09:00:00.000Z"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/suggest-tags:
    post:
      tags: [Tasks]
      operationId: suggestTaskTags
      summary: AI — suggest (or apply) tags for a task from its content
      description: |
        Has Timeliner's AI read a task — its title, brief, post caption and the
        current video's transcript — and pick tags for ONE tag column from the
        brand's vocabulary (shared tags plus that brand's own), proposing new
        labels only when nothing existing fits. `instructions` steers what to
        look for ("only the speakers"). By default the call only PROPOSES;
        `apply: true` also creates the new labels scoped to the task's brand
        and sets the cell to existing ∪ suggested (never more than 30 tags).

        A video with no transcript is tagged from its title, brief and post
        caption unless `startTranscription: true`, which starts one and answers
        **202** `{ status: "transcribing" }` — retry after `retryAfterSeconds`.
        Since 1.228.4 a task's video is transcribed free — only raw footage
        costs credits to transcribe — so that transcription is never refused
        for credits (from 1.143.0 until 1.228.4 it could answer **402**
        `reason: out_of_credits`). Since 1.174.0 the suggestions themselves
        spend the workspace's credits — charged by the AI work they used, and
        only when they succeed (a 422 or 502 is never charged) — so a **402**
        `reason: out_of_credits` means the workspace's credits cannot cover the
        suggestions: nothing was generated or written; relay the message and
        stop calling until credits are available. A video removed after the
        workspace's subscription ended (see *Removed media*) is never read and
        never transcribed: its task is tagged from its title, brief and post
        caption. **422** `reason: insufficient_content` when there is nothing
        to read; **502** when the model call failed; **429** when the
        workspace's hourly budget (60 calls) is spent. Requires `write:tasks`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuggestTagsRequest"
            examples:
              propose:
                summary: Propose up to 5 tags for the People column
                value:
                  columnId: "33333333-3333-3333-3333-333333333333"
                  instructions: "Tag the people who speak or appear"
              applySpeakers:
                summary: Tag the speakers and write the cell
                value:
                  columnId: "33333333-3333-3333-3333-333333333333"
                  instructions: "only the speakers"
                  maxTags: 3
                  apply: true
                  startTranscription: true
      responses:
        "200":
          description: The proposals (and, with `apply`, the cell after the write).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TagSuggestions"
        "202":
          description: A transcription was started (or is running) — retry after `retryAfterSeconds`.
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                type: object
                required: [status, retryAfterSeconds]
                properties:
                  status:
                    type: string
                    enum: [transcribing]
                  retryAfterSeconds:
                    type: integer
        "400":
          description: |
            The body failed validation, or `columnId` is not a tag column. A
            column of any other kind answers `reason: not_tag_column` and an
            `error` that starts with `"<Column>" is not a tag column`
            (unchanged since v1), then names the column's kind and lists the
            workspace's tag columns as `"Name" = id` (the first 10; the rest
            are on `GET /api/v1/custom-columns`). Nothing is generated or
            written.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NotTagColumnError"
              examples:
                notTagColumn:
                  summary: columnId is a select column
                  value:
                    error: >-
                      "Concept" is not a tag column — it is a select column,
                      and tags can only be added to a column of kind tag. A
                      select column's options cannot be added through the API
                      (a person adds them in Timeliner), and a task's select
                      value can only be one of its existing options, set by
                      that option's id (set_task_custom_values, or PATCH
                      /api/v1/tasks/{id}/custom-columns). Tag columns in this
                      workspace: "People" = 33333333-3333-3333-3333-333333333333.
                    reason: not_tag_column
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/OutOfCredits"
        "403":
          description: The workspace's billing is locked.
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          description: Nothing usable to read, or the model returned an unusable answer.
          content:
            application/json:
              schema:
                type: object
                required: [status, reason, message]
                properties:
                  status:
                    type: string
                    enum: [failed]
                  reason:
                    type: string
                    enum: [insufficient_content, invalid_output, transcripts_unavailable]
                  message:
                    type: string
        "429":
          description: The workspace's hourly suggestion budget is spent (`Retry-After`).
        "502":
          description: "The model call failed (`reason` is `generation_failed`)."
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/custom-columns/{id}/tags:
    post:
      tags: [Tasks]
      operationId: createCustomColumnTags
      summary: Add tags to a tag column's vocabulary (per brand)
      description: |
        Adds tags to a tag-kind custom column — in ONE scope. With a `brandId`
        (a brand / client node id from `GET /api/v1/brands`) the tags belong to
        that brand only: they apply to tasks under it and are visible only to
        people who can see it. `brandId` omitted or `null` creates SHARED tags,
        usable on every brand. Idempotent — a label that already exists in that
        scope is returned with `created: false` and its existing id, so a list
        may be re-sent safely. Labels are trimmed, matched case-insensitively,
        1–40 characters, up to 50 per request, and each (column, brand) scope
        holds at most 200 tags. Requires the `write:tasks` scope.

        Only a column whose `kind` is `tag` takes tags. A column of any other
        kind is a **400** `reason: not_tag_column` and nothing is written — a
        select column's options in particular can never be added through the
        API (a person adds them in Timeliner); a select cell only takes one of
        its existing option ids.
      parameters:
        - $ref: "#/components/parameters/CustomColumnId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomColumnTagsRequest"
            examples:
              brandTags:
                summary: Add three speaker tags to one brand
                value:
                  labels: ["Brian Ellis", "Dr. Patel", "Front desk"]
                  brandId: "66666666-6666-6666-6666-666666666666"
              sharedTag:
                summary: Add a shared, cross-brand tag
                value:
                  labels: ["Talking head"]
                  brandId: null
      responses:
        "200":
          description: The resolved tags, in the order the labels were sent.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomColumnTagsCreated"
        "400":
          description: |
            The body failed validation, the brand is not one of the
            workspace's brands, the scope's 200-tag cap would be exceeded, or
            the column is not a tag column. That last one answers
            `reason: not_tag_column` and an `error` that starts with
            `"<Column>" is not a tag column` (unchanged since v1), then names
            the column's kind — for a select column, that its options cannot
            be added through the API — and lists the workspace's tag columns
            as `"Name" = id` (the first 10; the rest are on
            `GET /api/v1/custom-columns`), or says the workspace has none yet.
            Nothing is written. The other refusals carry `error` only.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NotTagColumnError"
              examples:
                selectColumn:
                  summary: The id of a select column was sent
                  value:
                    error: >-
                      "Concept" is not a tag column — it is a select column,
                      and tags can only be added to a column of kind tag. A
                      select column's options cannot be added through the API
                      (a person adds them in Timeliner), and a task's select
                      value can only be one of its existing options, set by
                      that option's id (set_task_custom_values, or PATCH
                      /api/v1/tasks/{id}/custom-columns). Tag columns in this
                      workspace: "People" = 33333333-3333-3333-3333-333333333333.
                    reason: not_tag_column
                folderBrand:
                  summary: brandId is a folder, not a brand
                  value:
                    error: "brandId must be a brand (client) node — tags cannot be scoped to a folder"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/custom-columns:
    get:
      tags: [Tasks]
      operationId: listCustomColumns
      summary: List the workspace's custom columns
      description: |
        Lists the workspace's custom-column definitions (the user-defined extra
        fields on tasks). Select-kind columns include their `options`; tag-kind
        columns include their `tags` (label only — tags carry no colour). Not
        paginated — lower plans cap at 10 custom columns; an Agency plan or
        higher is unlimited.
      responses:
        "200":
          description: The workspace's custom columns.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CustomColumn"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/custom-statuses:
    get:
      tags: [Tasks]
      operationId: listCustomStatuses
      summary: List the workspace's custom statuses
      description: |
        Lists the workspace's **custom statuses** — extra steps inside the
        workflow (e.g. "Legal sign-off" after In Progress). Each sits after one
        built-in `statusGroup` (its `baseStatus`) and behaves like it: a task in
        one still reports that base as its `statusGroup` and names the step in
        `customStatus`. Move a task into one with `PATCH /api/v1/tasks/{id}`
        (`customStatusId`).

        Pass `brandId` to list only the statuses a task under that brand can use
        (a brand-only status of another brand, and a workspace-wide one the
        brand switched off, are left out). Ordered as on the board: each base in
        workflow order, then that base's statuses. Not paginated — a workspace
        holds at most 15. Covered by the `tasks` scope.
      parameters:
        - name: brandId
          in: query
          required: false
          description: Only the statuses usable on this brand (a task's `brandId`).
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The workspace's custom statuses.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/CustomStatus"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Tasks]
      operationId: createCustomStatus
      summary: Create a custom status
      description: |
        **New in 1.199.0.** Adds a custom status after a built-in
        `baseStatus`. Omit `brandId` for a workspace-wide one (Settings →
        Statuses); pass it for a status only that brand's tasks use (Edit
        Brand → Workflow). `name` 1–24 characters, unique in its scope
        (`409`); at most 15 per workspace (`409`). `editorAccess` decides
        which editors may move tasks into it (`default` | `all` | `none` |
        `selected` with `editorIds`). Moves no task and notifies no one.

        **Changed in 1.201.0:** `baseStatus` must be on the workspace's
        board — a status its workflow template does not have, or one switched
        off in Settings → Statuses, is refused with `400` "That status is
        switched off in this workspace — pick one that's on the board" (the
        board hides a custom status whose base is off, so it would never show).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [name, color, baseStatus]
              properties:
                name: { type: string, minLength: 1, maxLength: 24 }
                color:
                  type: string
                  description: Palette token (slate, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose).
                baseStatus: { type: string, enum: [toDo, inProgress, inRevision, supervisorApproval, approved, posted] }
                brandId: { type: ["string", "null"], format: uuid }
                editorAccess: { type: string, enum: [default, all, none, selected] }
                editorIds:
                  type: array
                  items: { type: string, format: uuid }
            example:
              name: Legal sign-off
              color: violet
              baseStatus: inProgress
      responses:
        "201":
          description: The new custom status.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomStatus"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/custom-statuses/{id}:
    patch:
      tags: [Tasks]
      operationId: updateCustomStatus
      summary: Update a custom status
      description: |
        **New in 1.199.0.** Rename, recolor, reorder (`sortOrder`, lower
        first among the same base) or change who may move tasks into it.
        `baseStatus` and `brandId` never change (`400`) — delete and recreate.
      parameters:
        - $ref: "#/components/parameters/CustomStatusId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              minProperties: 1
              properties:
                name: { type: string, minLength: 1, maxLength: 24 }
                color: { type: string }
                sortOrder: { type: number }
                editorAccess: { type: string, enum: [default, all, none, selected] }
                editorIds:
                  type: array
                  items: { type: string, format: uuid }
      responses:
        "200":
          description: The custom status after the change.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomStatus"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Tasks]
      operationId: deleteCustomStatus
      summary: Delete a custom status
      description: |
        **New in 1.199.0.** Every task in it falls back to its base status
        (its `statusGroup` is unchanged, so nothing notifies), and an
        automation rule whose whole trigger was this status is switched off.
        Counts against the destructive budget.
      parameters:
        - $ref: "#/components/parameters/CustomStatusId"
      responses:
        "204":
          description: Deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/custom-statuses/{id}/hidden:
    put:
      tags: [Tasks]
      operationId: setCustomStatusHidden
      summary: Hide a workspace-wide custom status for one brand
      description: |
        **New in 1.199.0.** Edit Brand → Workflow: switch a WORKSPACE-WIDE
        custom status off (`hidden: true`) or back on for one brand. Hiding
        moves that brand's tasks in it back to the base status (nothing
        notifies); `movedTasks` says how many. A brand-only status cannot be
        hidden (`400`) — delete it instead.
      parameters:
        - $ref: "#/components/parameters/CustomStatusId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [brandId, hidden]
              properties:
                brandId: { type: string, format: uuid }
                hidden: { type: boolean }
      responses:
        "200":
          description: The new state.
          content:
            application/json:
              schema:
                type: object
                required: [id, brandId, hidden, movedTasks]
                properties:
                  id: { type: string, format: uuid }
                  brandId: { type: string, format: uuid }
                  hidden: { type: boolean }
                  movedTasks: { type: integer }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/pricing/templates:
    get:
      tags: [Pricing]
      operationId: listPricingTemplates
      summary: List pricing templates
      description: The workspace's reusable pricing models/templates.
      responses:
        "200":
          description: The workspace's pricing templates.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PricingTemplate"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/pricing/receivables:
    get:
      tags: [Pricing]
      operationId: getPricingReceivables
      summary: Client receivables (what brands owe)
      description: |
        What each brand/client owes the agency — approved vs pending, paid vs
        outstanding — per brand, plus workspace totals and net + projected
        margin. Includes project-level prices (retainer/package deals) both
        folded into the totals and itemized under `projects`. Workspace-wide.
        Optional `from`/`to` filter by `Task.created_at` (project prices filter
        by their `revenueDate`). Mirrors the in-app Analytics Financial Summary.

        `paid` / `outstanding` are LEDGER-DERIVED (1.77.0): the live money the
        Payment ledger holds against each task / project counts, so a deposit
        reads as partially paid instead of "0 collected" — the same answer the
        in-app Books give. Rows with no ledger entry fall back to the paid flag.
        Each `projects[]` entry now carries that same money (1.85.0):
        `paidAmount` + `outstanding` always sum to `amount`, and the boolean
        `paid` is true only once the project is settled — so a project holding
        a deposit can no longer read `paid: false` beside a brand row that
        already counted the deposit. Only money moving the owed row's own
        direction counts ('in' for client money), so an outgoing payout tagged
        with a project is never reported as revenue collected.
        A project's `status` follows its recognition rule: a fixed price set
        after 1.77.0 is `approved` (owed) the moment it is set; older rows keep
        the every-task-approved rule until a manager changes it.
        `outstanding` counts APPROVED money only (1.97.0): a `pending` row is
        not owed yet, so it reports `outstanding: 0` and its whole `amount`
        stays in `totals.pending`. Before 1.97.0 the same money was reported
        both as pending and as outstanding.

        **Archived tasks count as approved (1.104.0).** A task in the opt-in
        `archive` status (the cleanup column past Approved) is realized money
        exactly like `approved` / `posted`: its price is in `approved` (and in
        `outstanding` until the client pays), not `pending`. Before 1.104.0 an
        archived task's price was reported as `pending`.

        **Brand retainers (1.91.0).** A brand can carry a monthly retainer
        (set in the app: Edit brand → Billing). Each month is owed in full on
        its 1st, and one-off extra charges are owed from their date; both are
        itemized under `brandCharges`, folded into `totals`, `margins` and
        `brands[]`, and filtered by `from`/`to` on that date. The
        retainer replaces nothing — project and task prices on a retainer
        brand are billed on top of it. `brands[].billingBasis` now reads
        `retainer` only for a brand with a retainer in effect; a brand whose
        every priced project is on one fixed client price is `perProject`
        (it was `retainer` before 1.91.0).
      parameters:
        - name: from
          in: query
          required: false
          schema: { type: string }
          description: ISO date/datetime — include tasks created on/after this.
        - name: to
          in: query
          required: false
          schema: { type: string }
          description: >-
            ISO date/datetime — include tasks created on/before this. A
            date-only value (`YYYY-MM-DD`) covers the WHOLE UTC day, so a range
            ending on a given day includes the tasks created that day; pass a
            full datetime to bound the range at a specific instant instead.
      responses:
        "200":
          description: Client receivables.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PricingReceivables"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/pricing/payables:
    get:
      tags: [Pricing]
      operationId: getPricingPayables
      summary: Team payables (what's owed to editors)
      description: |
        What the agency owes its team (editors) — approved vs pending, paid vs
        unpaid — per editor, plus workspace totals. Members on a monthly salary
        are excluded from the per-task buckets for their salaried periods and
        reported under `salaries` (prorated window cost, delivered count, cost
        per video). Optional `from`/`to` filter by `Task.created_at`. Mirrors
        the in-app Payments Dashboard.

        `paid` / `unpaid` are LEDGER-DERIVED (1.77.0): live Payment rows against
        each pay row / fee count, so a partial payout reads as partially paid.
        Legacy equal-split rows carry no ledger link and are never paid.

        `unpaid` counts APPROVED pay only (1.135.0): pay on a task that is not
        approved yet is reported in `pending` alone and contributes 0 to
        `unpaid` — the same rule `outstanding` follows on
        `/api/v1/pricing/receivables` since 1.92.0. Before 1.135.0 the same pay
        was reported both as `pending` and as `unpaid`. Cash is untouched: a
        payout already made on unapproved work still counts in `paid`. Member
        fees carry no approval lifecycle, so an unpaid fee is always `unpaid`.

        Archived tasks (the opt-in `archive` status) count in `approved`, like
        `approved` / `posted`, and as delivered work in `salaries` (1.104.0);
        before that their pay was reported as `pending`.
      parameters:
        - name: from
          in: query
          required: false
          schema: { type: string }
          description: ISO date/datetime — include tasks created on/after this.
        - name: to
          in: query
          required: false
          schema: { type: string }
          description: >-
            ISO date/datetime — include tasks created on/before this. A
            date-only value (`YYYY-MM-DD`) covers the WHOLE UTC day, so a range
            ending on a given day includes the tasks created that day; pass a
            full datetime to bound the range at a specific instant instead.
      responses:
        "200":
          description: Team payables.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PricingPayables"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/pricing/member-profitability:
    get:
      tags: [Pricing]
      operationId: getMemberProfitability
      summary: Per-member profitability (any pay type)
      description: |
        The "was this hire/freelancer worth it?" dataset per member: total
        cost (per-task pay + fixed project fees + prorated salary), what has
        actually been paid out (LEDGER-derived since 1.85.0 — the same number
        `GET /api/v1/pricing/payables` reports for that member, so a partial
        payout reads as partially paid on both), BOOKED client revenue
        attributed to them
        (billing-mode aware — task prices split evenly across a task's
        editors; fixed/legacy project prices allocated by delivered share),
        delivered + in-progress counts, cost per video, and a
        strong/thin/underwater ROI verdict. Optional `from`/`to` filter by
        `Task.created_at`; optional `memberId` narrows to one member. Archived
        tasks count as delivered (and their pay as approved cost) since
        1.104.0, like approved/posted ones.

        **Attributed views leave YouTube out (v1.231.0 — compliance-driven
        behaviour change).** `viewsAttributed` / `engagementAttributed` are
        combined across networks, and under the YouTube API Services Developer
        Policies YouTube data is never combined with another network's, so
        they cover every network EXCEPT YouTube; `pooledExcludes`
        (`["youtube"]`) says so. A member whose published videos all went to
        YouTube reads `0` — say the figure leaves YouTube out, never that
        their videos got no views.
      parameters:
        - name: from
          in: query
          required: false
          schema: { type: string }
          description: ISO date/datetime — include tasks created on/after this.
        - name: to
          in: query
          required: false
          schema: { type: string }
          description: >-
            ISO date/datetime — include tasks created on/before this. A
            date-only value (`YYYY-MM-DD`) covers the WHOLE UTC day, so a range
            ending on a given day includes the tasks created that day; pass a
            full datetime to bound the range at a specific instant instead.
        - name: memberId
          in: query
          required: false
          schema: { type: string }
          description: Limit the result to one member id.
        - name: includeProjects
          in: query
          required: false
          schema: { type: string, enum: ["true", "false"] }
          description: >-
            `true` appends the per-(member, project) breakdown under
            `members[].projects[]`.
      responses:
        "200":
          description: Per-member profitability rows.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MemberProfitability"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/pnl:
    get:
      tags: [Pricing]
      operationId: getProjectPnl
      summary: Project profit & loss
      description: |
        One project's P&L — billing-mode-aware revenue (a fixed project price
        IS the revenue; per-task/legacy projects bill task prices, with the
        project amount as an additive extra where present), team cost
        (per-task pay or fixed member fees, plus salary allocated by delivered
        share), realized margin and margin %. `unpricedTasks` > 0 means the
        margin is an "at least" figure. Optional `from`/`to` filter by
        `Task.created_at`. Matches the in-app Project Profitability card.
        Archived tasks (the opt-in `archive` status) are realized like
        approved/posted ones since 1.104.0 — their price is approved revenue,
        their team pay is cost and they count in `delivered`; before that an
        archived task read as pending revenue with no cost.

        Cost note: salary cost is allocated by workspace-wide delivered
        share, so each call computes over the whole workspace's tasks — the
        response is one project, but the work is O(workspace). Poll modestly
        (cache per period on your side) rather than calling once per project
        per page load.
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
          description: Project id.
        - name: from
          in: query
          required: false
          schema: { type: string }
          description: ISO date/datetime — include tasks created on/after this.
        - name: to
          in: query
          required: false
          schema: { type: string }
          description: >-
            ISO date/datetime — include tasks created on/before this. A
            date-only value (`YYYY-MM-DD`) covers the WHOLE UTC day, so a range
            ending on a given day includes the tasks created that day; pass a
            full datetime to bound the range at a specific instant instead.
      responses:
        "200":
          description: The project's P&L.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectPnl"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/billing:
    put:
      tags: [Pricing]
      operationId: setProjectBilling
      summary: Configure project billing
      description: |
        Configure the project's two independent billing axes. Client side:
        `perTask` (task prices bill) or `fixedPrice` (one project price IS the
        revenue — `amount` required, optional `label`). Team side: `perTask`
        (per-task pay rows) or `fixedProject` (one fee per member —
        `memberFees` REPLACES the fee list; absent unpaid rows are removed,
        rows already marked paid are payment records: they survive deletion
        AND keep their settled amount — a paid member's new amount in the
        list is ignored; mark the fee unpaid first to re-price it). For
        SINGLE-member fee changes use `team.feeUpdates` instead — a MERGE
        that upserts each listed member's fee (`amount: null` removes it),
        valid on ANY team mode: the fee becomes that member's pay of record
        in this project ("most specific wins" — their per-task pay there
        stops counting; other members are untouched). `feeUpdates` is
        mutually exclusive with `memberFees`; updates targeting a paid fee
        return 409. Any combination is valid; omit an axis to leave it
        untouched. Existing task prices/pay rows are KEPT but stop counting
        per the mode — switching back restores them; nothing is destroyed.
        Requires a full-access API key.
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
          description: Project id.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProjectBillingInput"
      responses:
        "200":
          description: The project's resulting billing configuration.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectBillingResult"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: A feeUpdates entry targets a fee already marked paid (a payment record).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/pricing:
    put:
      tags: [Pricing]
      operationId: setTaskPricing
      summary: Set a task's pricing template and editor roles
      description: |
        Apply a pricing template to ONE task and/or set which template split
        role each assigned editor fills, then recompute the task's prices with
        the same engine as the in-app pricing dialog. Example: two editors on
        a task, only the one tagged `Online Editor` is paid — send
        `editorRoles: [{memberId: A, role: "Online Editor"}, {memberId: B, role: null}]`.
        Profit share pays only editors holding one of the template's roles on
        the task. An editor with no role is tagged automatically from their
        workspace sub-role only when no other editor holds that role yet; a
        role you send, or `role: null`, always wins over that, and a matching
        sub-role never adds a second payee to a role someone already holds (a
        role you send takes it off an editor who only had it automatically).
        Editors you tag with the same profit-share role split that role's
        share; on a profit-share template only those paid role holders earn
        the version bonus or a share of the performance bonus. Flat-pay-split
        amounts and hourly sub-role rates are matched by the editor's task
        role, else their workspace sub-role. `role: null` is saved as "No role
        (not paid)" (since 1.103.4): automatic role assignment never re-tags
        that editor, and they earn nothing on the task in any pricing mode — no
        split, rate, default pay or bonus. It is an opt-out, NOT a clear: to
        return an editor to untagged send `{memberId, role: null, untag: true}`.
        Send a role to tag and pay them again. On a template with no roles,
        `role: null` has no effect: the editor is paid like an untagged one and
        no opt-out is stored. Each `editorPays[]` entry carries `roleSource`
        (`manual` | `auto` | `optOut` | null), so an untagged editor (null) can
        be told from an opted-out one (`optOut`) — both read `role: null`. To
        undo a change, re-send only the editors you changed: their previous
        role, or `untag: true` where their previous `roleSource` was null —
        never `role: null` for them, which opts them out and zeroes their pay.
        `templateId` omitted keeps the task's current template; switching
        templates clears role tags the new template does not define, and every
        recalculation drops a tag the task's template does not define. Roles
        match the template's roles case-insensitively. Refused with 409 once
        money has moved on the task (a payout marked paid, the client price
        received, or a live recorded payment). Requires the finance write scope.
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string, format: uuid }
          description: Task id.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskPricingInput"
      responses:
        "200":
          description: The task's resulting pricing.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/TaskPricingResult"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: Pricing is locked because money has already moved on this task.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/payments:
    get:
      tags: [Pricing]
      operationId: listPayments
      summary: List ledger payments
      description: |
        The append-only payment ledger — what money actually moved, with real
        business dates (including backdates). Each row carries `voided` (true
        when a reversal cancelled it); reversal rows carry `reverses` with the
        cancelled payment's id. Newest business date first. Matches the
        in-app Payment history blocks.
      parameters:
        - name: direction
          in: query
          required: false
          schema: { type: string, enum: [in, out] }
          description: "'out' = payouts to members; 'in' = client money received."
        - name: editor
          in: query
          required: false
          schema: { type: string }
          description: Filter by member profile id.
        - name: node
          in: query
          required: false
          schema: { type: string }
          description: Filter by brand node id.
        - name: project
          in: query
          required: false
          schema: { type: string }
          description: Filter by linked project id.
        - name: from
          in: query
          required: false
          schema: { type: string }
          description: ISO date — payments on/after this business date.
        - name: to
          in: query
          required: false
          schema: { type: string }
          description: >-
            ISO date — payments on/before this business date. A date-only value
            (`YYYY-MM-DD`) covers the WHOLE UTC day; pass a full datetime to
            bound the range at a specific instant instead.
        - name: limit
          in: query
          required: false
          schema: { type: integer, minimum: 1, maximum: 200, default: 100 }
          description: Max rows returned.
      responses:
        "200":
          description: Ledger rows, newest business date first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Payment"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Pricing]
      operationId: recordPayment
      summary: Record a ledger payment
      description: |
        Record ONE free-form payment in the append-only ledger — money paid
        OUT to a team member (`memberId` required) or received IN from a
        brand/client (`nodeId` required). Partial amounts are fine; backdate
        with `paidAt` when the money moved earlier. This does NOT mark owed
        tasks/prices as settled. Pass `idempotencyKey` to make retries safe —
        a replay returns the original row with `duplicate: true` (200 instead
        of 201). Corrections go through the void endpoint, never edits.
        Requires a full-access API key.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaymentInput"
      responses:
        "201":
          description: The recorded payment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Payment"
        "200":
          description: Idempotent replay — the original payment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/Payment"
                  duplicate:
                    type: boolean
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/payments/{id}/void:
    post:
      tags: [Pricing]
      operationId: voidPayment
      summary: Void a ledger payment
      description: |
        Cancel one ledger payment by recording its reversal row — the ledger
        is append-only, so nothing is deleted and the history keeps both
        entries. Voiding an already-voided payment returns 409; reversal rows
        themselves cannot be voided (400). Settlement payments (rows created
        by mark-paid / mark-received, carrying a task / editor-pay /
        member-fee link) also return 400 — void those by calling the matching
        mark endpoint with `paid: false`, which reverses the ledger AND
        clears the owed row's paid flag together. Free-form payments
        (including ones linked to a project) stay voidable here. Requires a
        full-access API key.
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
          description: The payment id to void.
      responses:
        "200":
          description: The payment was voided.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id: { type: string }
                      voided: { type: boolean }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/pricing/payables/mark-paid:
    post:
      tags: [Pricing]
      operationId: markPayablesPaid
      summary: Mark team payouts paid / unpaid
      description: |
        Settle team money: flip per-task pay rows (`editorPayIds` —
        TaskEditorPay ids from the payables endpoint) and/or per-member
        project fees (`memberFeeIds`) paid or unpaid. Marking paid writes
        dated `out` entries in the append-only ledger (backdate with
        `paidAt`); marking unpaid voids them by reversal. Idempotent — a link
        already covered by a live payment is skipped on retry (same `paidAt`,
        or none). Re-marking a covered link with a DIFFERENT explicit `paidAt`
        is treated as a paid-date correction: the stale entry is voided by
        reversal and a new entry is written at the corrected date, so the call
        emits one `payment.voided` plus one `payment.recorded`. Validation is
        all-or-nothing: every id in BOTH lists must resolve in the workspace
        before anything is flipped, so a 404 means no row changed, no ledger
        entry was written, and no webhook fired. Same engine as the in-app
        checkboxes and Janet's mark_payouts_paid. Requires a full-access API
        key.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MarkPayablesInput"
      responses:
        "200":
          description: How many rows were flipped.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      paid: { type: boolean }
                      editorPaysUpdated: { type: integer }
                      memberFeesUpdated: { type: integer }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/pricing/receivables/mark-received:
    post:
      tags: [Pricing]
      operationId: markReceivablesReceived
      summary: Mark client money received / outstanding
      description: |
        Settle client money: either specific tasks' client prices (`taskIds`)
        or one project's PROJECT-LEVEL price (`projectId` — retainers / fixed
        billing). Exactly one of the two. Marking received writes dated `in`
        ledger entries with the brand counterparty (backdate with `paidAt`);
        marking outstanding voids them by reversal. Re-marking an already
        settled row with a DIFFERENT explicit `paidAt` records a paid-date
        correction — the stale entry is voided by reversal and a new entry is
        written at the corrected date. Same engine as the in-app brand tab and
        Janet's mark_client_paid. Requires a full-access API key.

        Marking received requires a price to settle: a `taskIds` batch
        containing any task with no client price (or a non-positive one) is
        refused whole with `400` naming those ids — nothing is flipped and no
        ledger entry is written — mirroring the `projectId` path's "no
        project-level price" `400`. Marking outstanding (`paid: false`) is
        never refused on that ground.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MarkReceivablesInput"
      responses:
        "200":
          description: How many rows were flipped.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      paid: { type: boolean }
                      updated: { type: integer }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/analytics:
    get:
      tags: [Analytics]
      operationId: getAnalytics
      summary: Read workspace analytics
      description: |
        The workspace's analytics in one response — status counts, monthly
        financial trend, per-editor performance, revision stats (internal +
        external, per editor + per brand + trend), production momentum, and top
        editors/clients by revisions. The financial trend's client revenue
        also includes brand retainer months and one-off extra charges since
        1.95.0 (approved revenue in the month they are owed; excluded when
        `memberId` is set, narrowed to the brand when `brandId` is). Optional
        `from`/`to` (on
        `Task.created_at`), `brandId`, `projectId`, `memberId` filters. Numbers
        mirror the in-app Analytics view. Workspace-wide (the api key is
        workspace-scoped).

        **Filters narrow every dataset, `timeTracking` included (1.158.0).**
        `brandId` keeps the tasks of projects directly under that brand,
        `projectId` (new in 1.158.0) the tasks of that one project — the
        in-app sidebar's project view — and the two combine. `timeTracking`
        follows the same brand and project scope, and under `memberId` it keeps
        the time that member TRACKED (the Time Tracking card's rule), not the
        time tracked on tasks assigned to them. Before 1.158.0 `timeTracking`
        ignored `brandId` and `memberId` and always returned the whole
        workspace's tracked time. Under `projectId` the money follows the
        project too: its own project price and per-member fees, and the
        retainer / extra-charge lines of the brand it belongs to (resolved up
        through folders), exactly as the app's project view counts them. A
        malformed `brandId`, `projectId` or `memberId` is a 400 since 1.158.0
        (before, a malformed `brandId` / `memberId` silently returned empty
        datasets); an empty value is ignored. A well-formed id from another
        workspace matches nothing and returns empty datasets.

        **Task basis.** Every task-count dataset (`statusCounts`,
        `editorPerformance`, `productionMomentum`, `topEditors`/`topClients`,
        `teamWorkload`) counts TOP-LEVEL tasks — regular tasks and parents. A
        parent's variants are deliverables of that parent, not tasks of their
        own, exactly as the board column headers and the in-app Analytics
        screen count them. `revisionStats` and `financialTrend` still reach
        into variants, because their own rules are defined over them.

        **Money basis.** `financialTrend`'s client revenue includes
        project-level prices (bucketed by the project's start date, falling
        back to creation date; excluded when `memberId` is set) and applies the
        same per-project billing rules as the app: on a project billed at a
        FIXED client price the project amount is the price and the tasks' own
        prices are excluded, and on a project billed at a FIXED per-member team
        rate the per-task team pay is replaced by the per-member fees, each
        folded into `editorApproved` at the month it was created (a fee raised
        while that member was on a monthly salary is excluded — salary already
        covers them). Fees are scoped by project, so `brandId` and `projectId`
        narrow them and `memberId` deliberately does not — a fee belongs to a
        project, not to the member selected in a filter.
        A task in the opt-in `archive` status counts as approved money in
        `financialTrend` since 1.104.0 (before, it read as pending); the
        delivery datasets (`editorPerformance`, `revisionStats`,
        `productionMomentum`) still count only approved/posted tasks, exactly
        as the Analytics screen does.
      parameters:
        - name: from
          in: query
          required: false
          schema: { type: string }
          description: ISO date/datetime — tasks created on/after this.
        - name: to
          in: query
          required: false
          schema: { type: string }
          description: >-
            ISO date/datetime — tasks created on/before this. A date-only value
            (`YYYY-MM-DD`) covers the WHOLE UTC day; pass a full datetime to
            bound the range at a specific instant instead.
        - name: brandId
          in: query
          required: false
          schema: { type: string, format: uuid }
          description: >-
            Restrict to one brand/client — its projects' tasks, the time
            tracked on them, and its money.
        - name: projectId
          in: query
          required: false
          schema: { type: string, format: uuid }
          description: >-
            Restrict to one project (1.158.0) — its tasks, the time tracked on
            them, its project price and fees, and its brand's retainer lines.
        - name: memberId
          in: query
          required: false
          schema: { type: string, format: uuid }
          description: >-
            Restrict to tasks involving one team member; `timeTracking` keeps
            the time this member tracked.
      responses:
        "200":
          description: The workspace's analytics.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Analytics"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/posts:
    get:
      tags: [Posts]
      operationId: listPosts
      summary: List scheduled posts
      description: |
        Returns the workspace's scheduled social posts, newest first,
        cursor-paginated. A "post" is a task with a scheduling status; each post
        is flattened into a `networks` array — one entry per targeted social
        network — carrying that network's **caption** and **publish status**.

        Captions follow the post's lifecycle:

        - **Before** the post is processed for publishing, each network's
          `caption` is resolved live from the composer (the shared caption,
          overridden per-network where set), and its `status` mirrors the post's
          overall scheduling status.
        - **After** processing, each network has its own execution record: the
          `caption` is the frozen snapshot that was published, and `status`,
          `publishedAt`, `permalink`, and `providerPostId` reflect the real
          per-network result. A network whose `status` is `failed` also carries
          `error` — why it did not publish (since 1.113.0).

        Each post also carries `brandId`/`projectId`, the deliverable approval
        `statusGroup` (`inRevision` = sent back/rejected), a `review` block (the
        client's per-element sign-off), `media` + `customThumbnail` (presigned
        download/thumbnail/preview links), per-network `account` (the
        connected channel it publishes to) and per-network `coverUrl` (the
        cover picked in the app for that network — since 1.157.0). Times are UTC
        instants — interpret them in the response's top-level `timezone` (the
        workspace IANA zone).

        **Changed in 1.233.0 — a disconnected YouTube channel's videos are not
        named.** A network that went out on a YouTube channel since
        disconnected keeps its `platform`, `status`, `caption`, times and
        `account.id`, but its `account` reads `status: "disconnected"` with
        `handle`, `displayName`, `avatarUrl` and `followerCount` `null`, and
        its `permalink`, `providerPostId`, `error` and (with
        `includeMetrics=true`) `metrics` are `null` — YouTube API Services: the
        channel's data stops being used the moment it is disconnected. They
        come back if the same channel is reconnected to the brand within 6
        days; after that the data is deleted. An expired YouTube channel and
        every other network are unchanged.

        Optionally filter by task, project, brand, overall status, or a
        `scheduledFrom`/`scheduledTo` calendar window.
      parameters:
        - $ref: "#/components/parameters/Limit"
        - $ref: "#/components/parameters/Before"
        - name: taskId
          in: query
          description: >-
            Return only the single post for this task (a post is keyed by its
            task — there is no GET `/posts/{id}` route). Returns an empty list
            (not an error) if the task has no scheduled post or is not in this
            workspace. A malformed (non-UUID) value returns 400.
          required: false
          schema:
            type: string
            format: uuid
        - name: projectId
          in: query
          description: Restrict results to a single project (must belong to the same workspace).
          required: false
          schema:
            type: string
            format: uuid
        - name: brandId
          in: query
          description: Restrict results to a single brand (Node) (must belong to the same workspace).
          required: false
          schema:
            type: string
            format: uuid
        - name: status
          in: query
          description: Filter by the post's overall scheduling status.
          required: false
          schema:
            type: string
            enum: [draft, pending, manual, published, failed, missed, partial]
        - name: scheduledFrom
          in: query
          description: >-
            Calendar-window start (inclusive). Keep only posts whose
            `scheduledAt` is at or after this ISO-8601 date/time. A malformed
            value returns 400.
          required: false
          schema:
            type: string
            format: date-time
        - name: scheduledTo
          in: query
          description: >-
            Calendar-window end (inclusive). Keep only posts whose `scheduledAt`
            is at or before this ISO-8601 date/time. A malformed value returns 400.
          required: false
          schema:
            type: string
            format: date-time
        - name: includeMetrics
          in: query
          description: >-
            `true` adds `metrics` to every entry of each post's `networks`: that
            network's latest metrics snapshot (views, reach, impressions, likes,
            comments, shares, saves, engagementRate, watch-time fields,
            capturedAt), or `null` when none was fetched (not published yet,
            manual, or no metrics integration) — never zeros. Loaded in one
            batched read. Default `false` (the key is absent). Any value other
            than `true` / `false` returns 400. (v1.102.0)
          required: false
          schema:
            type: string
            enum: ["true", "false"]
      responses:
        "200":
          description: Page of scheduled posts.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/posts/{taskId}:
    patch:
      tags: [Posts]
      operationId: updatePost
      summary: Write a post's content
      description: |
        Writes the post's content — the shared `caption`, the per-network
        `platformCaptions` overrides, and/or the per-network settings via
        `platformOptions`: YouTube metadata (title, tags, visibility,
        isShorts, madeForKids), Instagram (format, collaborator — up to 3 Instagram
        handles, really invited on the published post — and first comment),
        Facebook
        (first comment — accepted and stored, but NOT posted at publish yet:
        Meta has not granted the Page-comment permission; `format` accepts
        only `post` until reel/story publishing is wired), LinkedIn (postAs,
        targetAudience — stored but NOT applied at publish — and first comment;
        also covers `linkedinCompany` legs),
        TikTok (privacy level, interaction toggles, commercial-content
        disclosure), and Threads (since 1.163.0: `topicTag` — one topic tag,
        stored without its `#`; every Threads post takes replies from
        everyone, so since 1.183.0 `replyControl` accepts only `everyone`). A post
        is keyed by its task (same addressing as `GET /posts?taskId=`).
        X (since 1.210.0) takes a `platformCaptions.x` override like any
        network, and has no `platformOptions`: an `x` key there is refused
        with `400`.

        Manual steps: `collaborators` on `linkedin`, `youtube` (long-form
        videos AND Shorts), `tiktok` and `facebook`, and an in-app
        `audioNote` on `instagram`, `tiktok`, `facebook` (Reels) and
        `youtube` (Shorts), turn that network's leg into a MANUAL hand-off:
        none of those APIs can invite collaborators or attach a trending
        sound, so at the posting time the leg is marked `manual` and the team
        is reminded (naming the people / the track) instead of the post going
        out without them. `linkedin.format: "newsletter"` is always manual.
        Instagram collaborators are NOT manual — they are invited
        automatically. `instagram.trialReel` (Reels only) is accepted on
        every deployment by default since 1.131.1; only a deployment that
        switched Instagram trial reels off refuses it with `422` — "Trial
        reels aren't available yet". A trial reel is a single Reel: turning
        it on (`trialReel.enabled: true`) for a post that publishes to
        Instagram as a carousel — a parent task whose variants post as two or
        more slides — is refused with `400` and `code: "trialReelCarousel"`,
        because Instagram never posts a carousel as a trial reel (it would go
        to all followers). Nothing is written. Turning a trial off is never
        refused.

        This is the content-crafting endpoint: it only ever touches the post's
        copy and per-network options. It does **not** schedule, reschedule,
        target networks, or publish — use `POST /posts/{taskId}/schedule` for
        the slot — and it fires no notifications. Writing content for a media
        task that has no calendar slot yet is allowed: the copy pre-fills the
        composer for when the team plans the post.

        `platformCaptions` merges key-by-key: a string sets that network's
        override, `null` (or `""`) removes it so the network falls back to the
        shared caption, and omitted networks keep their current override.

        `platformOptions.instagram.format` is the post's Instagram format
        (`feed`, `reel`, or `story`) — writing it updates the format the
        in-app composer shows and the format the post actually publishes as.
        Omitting it leaves the current format untouched.

        Side effect (identical to an in-app caption edit): when the caption
        text actually changes, the client's caption approval is reset
        (`review.captionApprovedAt` becomes `null`) so the client re-reviews.

        Fails with `409` once the post is `published` (captions are frozen
        snapshots at publish time) and `403` when the workspace plan does not
        include social posting.

        **Per-network caption limits.** A caption longer than one of the
        post's scheduled networks allows is refused with `400` and
        `code: "captionOverLimit"`, and nothing is written — the `error` names
        the network, the length and the limit. The limits are Instagram 2,200,
        TikTok 2,200, LinkedIn 3,000, Facebook 63,206 and Threads 500
        characters, and YouTube 5,000 **bytes** of UTF-8 (since 1.229.0 — a
        Hebrew or Arabic letter counts 2, an emoji 4; its refusal says bytes).
        Threads counts each emoji at its UTF-8 byte length, as Threads itself
        does — "Hi 👋" is 7 toward its 500, not 3 — and its refusal says so.
        Only the captions the request writes are judged, against the networks
        the post is scheduled to; a post with no networks yet is judged when it
        is scheduled.
        X allows 280 characters as X counts them: a link counts as 23, and
        each emoji or CJK character as 2.

        **YouTube metadata is sent exactly as written (since 1.229.0).**
        Timeliner never cuts, strips or appends to a YouTube title, description
        or tags (YouTube API Services Developer Policies III.C.3): nothing is
        added to the description — no `#Shorts` — and a value YouTube would
        refuse is refused here with `422` and a `code`, and nothing is written:
        `youtubeTitleInvalidChars` — `platformOptions.youtube.title` holds `<`
        or `>`; `youtubeTagsTooLong` — `platformOptions.youtube.tags` add up to
        more than YouTube's 500 characters as YouTube counts them (each tag,
        one per comma between tags, and 2 more for a tag holding a space);
        `youtubeDescriptionTooLong` — `platformCaptions.youtube` (the video's
        description) is over 5,000 bytes of UTF-8; and
        `youtubeDescriptionInvalidChars` — `platformCaptions.youtube` holds `<`
        or `>`. A title over 100 characters (counted as YouTube counts them: an
        emoji is one) stays a `400`. The shared `caption` is the description
        of every YouTube channel the post uploads to that has no caption of its
        own, so on a post scheduled to YouTube a `caption` — or a
        `platformCaptions.youtube: null` that hands YouTube the shared caption
        — over 5,000 bytes or holding `<` / `>` is the same `422`
        `youtubeDescriptionTooLong` / `youtubeDescriptionInvalidChars` (before
        the caption-limit `400`). A post not scheduled to YouTube yet is judged
        when it is scheduled. A post whose YouTube leg still reaches its
        posting time with a title, description or tags YouTube would refuse —
        say a blank title whose new caption line is over 100 characters —
        fails that leg before anything is sent to YouTube, and
        `networks[].error` names the field to fix.

        **Document posts.** A post may live on a media task or on a regular
        `type: doc` task (a text-first post). On a document post the shared
        caption IS the document: the first write here creates the post
        following its document, and from then on the caption tracks every
        document save. Sending a different `caption` for such a post returns
        `409` with `code: "captionFromDoc"` — change the text with
        `PATCH /tasks/{id}/doc` instead. `platformCaptions`, `platformOptions`
        (for example `linkedin.firstComment`) and `thumbnailFileId` work as on
        any post. A parent task or a document variant returns `400`.
      parameters:
        - name: taskId
          in: path
          required: true
          description: The post's task UUID.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePostInput"
      responses:
        "200":
          description: The post's caption state after the write.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostCaption"
        "400":
          description: |
            Invalid request. With `code: "captionOverLimit"`, a caption the
            request writes is longer than one of the post's scheduled networks
            allows (e.g. "The Instagram caption is 2,412 characters; Instagram
            allows 2,200. Shorten it and save again.") — nothing was written.
            With `code: "coverNotImage"` (since 1.150.1), `thumbnailFileId`
            names a file that is not a JPEG, PNG or WebP image — a video or a
            document can't be a post cover — and nothing was written: the post
            keeps its previous cover.
            With `code: "trialReelCarousel"` (since 1.158.0), the request turns
            `platformOptions.instagram.trialReel` on for a post that publishes
            to Instagram as a carousel, which Instagram never posts as a trial
            reel — nothing was written.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The workspace plan does not include social posting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          description: |
            No task with this id is in your workspace, and nothing was written.
            A post is keyed by its task, so this is the task's id. When the id
            is some OTHER row your own workspace owns — a project, a brand or
            folder, a custom column, an HQ item or a file — or a task id with
            one or two characters wrong or shortened (its first 8 characters
            matching a task of your workspace), `error` names which and what to
            send instead. An unknown id, or a task in another workspace, keeps
            the plain `Post not found` error: the two are deliberately
            indistinguishable, and no body echoes the id back.
            Since 1.190.0 that plain body also carries
            `"reason": "task_not_found"` (a named mistake has no `reason`), and
            a task lookup that FAILS on our side answers `500`, never this
            `404`. Get the task's id again (`GET /api/v1/posts` or
            `GET /api/v1/tasks`) and send all 36 characters.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostUpdateNotFoundError"
              examples:
                unknownPost:
                  summary: Unknown id, or a task in another workspace
                  value:
                    error: Post not found
                    reason: task_not_found
                projectIdAsTaskId:
                  summary: A project id was sent as the task id
                  value:
                    error: >-
                      Post not found. That id is a project in this workspace —
                      pass one of its task ids (from list_tasks, or GET
                      /api/v1/tasks?projectId=…) in the path.
                shortenedTaskId:
                  summary: A task id cut short and filled back out with zeros
                  value:
                    error: >-
                      Task not found. No task has that exact id, but one task in
                      this workspace has an id starting with the same 8
                      characters: 3f2a9c10-5b7e-4d21-9a8c-1e6f0b2d4c55. The id
                      sent looks shortened and filled back out — a task id is
                      always the full 36 characters, exactly as list_tasks,
                      get_task or create_task returned it, never shortened or
                      padded. If that is the task you meant, retry with its full
                      id.
        "409":
          description: |
            The post is already published — its caption is frozen. Or, with
            `code: "captionFromDoc"`, the post is a document post whose caption
            follows its document — update the document instead.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "422":
          description: |
            `platformOptions.instagram.trialReel` was sent to a deployment
            that switched Instagram trial reels off (they are on by default
            since 1.131.1) — error "Trial reels aren't available yet".
            Since 1.229.0, also YouTube metadata YouTube would refuse as it
            stands — nothing was written, and Timeliner never alters it to fit:
            `code: "youtubeTitleInvalidChars"` (the title holds `<` or `>`),
            `code: "youtubeTagsTooLong"` (the tags add up to more than 500
            characters as YouTube counts them),
            `code: "youtubeDescriptionTooLong"` (`platformCaptions.youtube` —
            or, on a post scheduled to YouTube, a `caption` YouTube would
            receive as its description — is over 5,000 bytes of UTF-8) or
            `code: "youtubeDescriptionInvalidChars"` (that description holds
            `<` or `>`).
            Since 1.232.0, also `code: "youtube_made_for_kids_required"`
            (body: `YouTubeUploadAnswersError`): the request sets
            `platformOptions.youtube.madeForKids` to `null` on a post already
            queued to YouTube (`pending`, `manual` or `missed` with `youtube`
            among its networks) — its YouTube leg could not upload. Nothing
            was written; change the answer instead, or unschedule first.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: "#/components/schemas/YouTubeUploadAnswersError"
                  - $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/posts/{taskId}/covers/{network}:
    get:
      tags: [Posts]
      operationId: getPostCover
      summary: Get a network's cover image
      description: |
        The image one network of a post publishes as its cover, from its OWN
        slot — the cover the team picked in the app for that network (its
        composer card or the Post tab's **Change**), TikTok's picked frame, or
        YouTube's selected thumbnail. It is the URL `GET /api/v1/posts` reports
        as `networks[].coverUrl`. Such covers are stored with the post, not as
        files, so this is the only way to read their bytes. (1.157.0)
      parameters:
        - name: taskId
          in: path
          required: true
          description: The post's task id (a post is keyed by its task).
          schema:
            type: string
            format: uuid
        - name: network
          in: path
          required: true
          description: The network whose cover to read — a `networks[].platform` value.
          schema:
            type: string
            enum: [facebook, instagram, linkedin, linkedinCompany, tiktok, youtube]
      responses:
        "200":
          description: The cover image (JPEG, PNG or WebP). Not cached — a new pick replaces it at once.
          content:
            image/jpeg:
              schema:
                type: string
                format: binary
            image/png:
              schema:
                type: string
                format: binary
            image/webp:
              schema:
                type: string
                format: binary
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          description: |
            `{ "error": "Cover not found" }` — the task is not in this workspace,
            the network has no cover of its own (it publishes the post's
            `customThumbnail` or the video's own frame), or the post's video was
            removed.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/posts/{taskId}/caption/generate:
    post:
      tags: [Posts]
      operationId: generatePostCaption
      summary: Generate an AI caption, YouTube title, or YouTube tags for a post
      description: |
        Has Timeliner's AI write the post's copy from the task's own
        material: the video's transcript (or its images, for static/carousel
        posts) plus the brand's previously published posts for voice-matching.
        The caption is platform-tuned (short for TikTok/Reels, longer allowed on
        Instagram feed, 280-character hard cap for X), written in the source
        material's language, and follows the brand's saved Voice & Style rules —
        no emojis and no hashtags by default, unless the brand's voice profile
        explicitly asks for them.

        **What to generate** — `field` selects the piece of copy: `caption`
        (default, any network), `title` (the YouTube video title, written for
        search and click-through), or `tags` (the YouTube tag list). Titles and
        tags are YouTube-only and require `platform: "youtube"`; both are
        voice-matched against the brand's previously published YouTube videos
        rather than its captions.

        **Brand memory** — generations also replay the dated corrections the
        brand's team gave on earlier drafts of the same field in-app, so copy
        written through the API inherits the same learned voice the composer
        uses. See `GET /brands/{id}/voice` for the explicit, promoted rules.

        **Removed media** — a video or image removed after the workspace's
        subscription ended (see *Removed media*) is not read: no transcript, no
        frames, no transcription started; the copy is written from the task's
        text alone.

        **A post that already has copy is rewritten (1.126.1)** — when the
        draft already holds text in the field being generated (the caption, or
        for `title` / `tags` that YouTube option), the call rewrites THAT text:
        the same subject and facts in better wording, under the same rules. A
        rewrite is written from that text and `instructions` alone — the
        video's transcript, its frames or images, and the task's title and
        brief are not read — so it never waits on transcription (no `202`),
        never starts one, and never fails with `no_speech`,
        `transcript_failed` or `no_visuals`. A post with no copy in that field
        is written from its material as described above.

        **Async transcript contract** — when the post's video has no transcript
        yet, the call auto-starts transcription and answers
        `202 {status:"transcribing", retryAfterSeconds}` (plus a `Retry-After`
        header). Retry the **same** call after that many seconds until it flips
        to `200 {status:"ok"}`; most videos transcribe in well under two
        minutes. Since 1.164.1 each retry first checks the transcription job
        with the provider, so a finished clip turns into a caption on the very
        next call instead of after a background sweep (up to 20 minutes
        before). `422 {status:"failed"}` is terminal for the task's current
        material (`reason`: `no_speech`, `transcript_failed`,
        `transcripts_unavailable`, `no_visuals`, `insufficient_content`).
        `502 {reason:"generation_failed"}` means the AI call itself failed —
        retry it. `503 {reason:"ai_unavailable"}` means Timeliner's AI
        provider is temporarily out of capacity: every call fails the same way
        until it recovers, so back off and retry later rather than looping.
        `402 {reason:"out_of_credits"}` means the workspace's credits cannot
        cover the caption, title or tag list: nothing was generated and
        nothing was written; relay the message and stop until credits are
        available. Since 1.174.0 the generation spends the workspace's credits
        — charged by the AI work it used, and only for a usable result (a
        `422`, `502` or `503` is never charged, nor — with `apply` — a result
        the draft does not save: `400 captionOverLimit` or `500`). The
        transcription the call needs — its auto-start, or a
        `retryTranscription` — is free since 1.228.4 (a task's video costs no
        credits to transcribe; only raw footage does), so it is never refused
        for credits. From 1.143.0 until 1.228.4 it could be: this `402`, or on
        a video still being processed a later `422
        {reason:"transcript_failed"}` carrying the out-of-credits sentence.

        **Recovering from `transcript_failed`** — that reason means an EARLIER
        transcription of this video failed; the `message` says why. Repeating
        the call unchanged will always fail the same way. Send
        `retryTranscription: true` **once** to re-run the transcription: the
        call answers `202 {status:"transcribing"}` and you poll exactly as
        above. If the retry fails with the same reason the video cannot be
        transcribed as it stands — stop retrying and either replace the file or
        write the caption without a transcript. A retry the workspace cannot
        run (transcripts disabled, file too large, still uploading) answers
        `422` with `reason: transcripts_unavailable`.

        **Apply mode** — `apply:true` saves the generated copy into the post
        draft so the team sees it in the composer immediately: a caption lands
        in the shared caption or the `platform`'s per-network override, while a
        title or tag list lands in the draft's YouTube options. Same side effect
        as `PATCH /posts/{taskId}`: a caption text change resets the client's
        caption approval. With the default `apply:false` the copy is only
        returned. This endpoint never schedules, targets networks, or publishes.

        **Batching** — generation takes 5–20 seconds per post, so the endpoint
        is single-task by design: loop task by task for a batch.

        Each generation is charged in credits by the AI work it used, only when
        it works. Fails `400` when `field` is `title`
        or `tags` without `platform: "youtube"`, `409` when `apply:true` targets
        an already-published post (captions are frozen) and `403` when the
        workspace plan does not include social posting. Read-only API keys
        cannot call this endpoint (all `POST` operations are writes — and a
        generation spends money even without `apply`).
      parameters:
        - name: taskId
          in: path
          required: true
          description: The post's task UUID.
          schema:
            type: string
            format: uuid
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GenerateCaptionInput"
      responses:
        "200":
          description: The generated copy (and whether it was applied).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GeneratedCaption"
        "202":
          description: |
            The video's transcription is running (it was auto-started if
            needed). Retry the same call after `retryAfterSeconds`.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptionGenerationPending"
        "400":
          description: |
            Invalid request. With `apply: true` and `code: "captionOverLimit"`, the
            generated caption is longer than one of the post's scheduled networks
            allows, so it was not saved (`error` names the network and the limit).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/OutOfCredits"
        "403":
          description: The workspace plan does not include social posting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          description: |
            The post was not found, and no caption was written. A post is keyed
            by its task, so this is the task's id. An unknown id, or a task in
            another workspace, answers the plain `Post not found` with
            `"reason": "task_not_found"`: the two are deliberately
            indistinguishable, and no body echoes the id back. When the id is
            some OTHER row your own workspace owns — a project, a brand or
            folder, a custom column, an HQ item or a file — or a task id with
            one or two characters wrong or shortened (its first 8 characters
            matching a task of your workspace), `error` names which and what to
            send instead, with no `reason`. Since 1.203.0, a task of your
            workspace that is in the Trash answers `"reason": "task_trashed"`
            (`list_tasks` shows it with `status: "trashed"`): the API cannot
            restore it — a person restores the task, or its project, from the
            app's Trash page, and then the same call works. A task lookup that
            FAILS on our side answers `500`, never this `404`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptionGenerateNotFoundError"
              examples:
                unknownPost:
                  summary: Unknown id, or a task in another workspace
                  value:
                    error: Post not found
                    reason: task_not_found
                trashedTask:
                  summary: A task of this workspace that is in the Trash
                  value:
                    error: >-
                      Post not found. That task is in the Trash (list_tasks
                      shows it with status "trashed"), so no caption was
                      written. The API cannot restore it: a person restores the
                      task — or its project, if the whole project was moved to
                      the Trash — from the app's Trash page, and then this call
                      works. Otherwise caption a task whose status is "active".
                    reason: task_trashed
                projectIdAsTaskId:
                  summary: A project id was sent as the task id
                  value:
                    error: >-
                      Post not found. That id is a project in this workspace —
                      pass one of its task ids (from list_tasks, or GET
                      /api/v1/tasks?projectId=…) in the path.
        "409":
          description: "`apply:true` on an already-published post — its caption is frozen."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "422":
          description: |
            Generation is not possible for the task's current material —
            terminal until the material changes.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptionGenerationFailed"
        "502":
          description: The AI generation itself failed — safe to retry.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptionGenerationFailed"
        "503":
          description: |
            `reason: ai_unavailable` — Timeliner's AI provider is temporarily
            out of capacity, so no caption can be written right now. Every call
            fails the same way until it recovers: back off and retry later
            (minutes to hours), never in a tight loop.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptionGenerationFailed"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/posts/{taskId}/schedule:
    post:
      tags: [Posts]
      operationId: schedulePost
      summary: Schedule a post (slot + platforms)
      description: |
        Sets or replaces the post's scheduled time and target platforms —
        full-replace semantics, the composer's Schedule button. Also
        reschedules an already-planned post and re-arms a `missed` one.
        `draft: true` places a calendar draft instead (drafts never enter the
        publish queue).

        The response always carries what will ACTUALLY happen:

        - `approvalGate` — whether the post will auto-publish at the slot.
          When the workspace requires approval before posting (the default)
          and the task is not `approved`/`posted`, the schedule still
          succeeds but the gate carries a warning: at the slot the publish
          engine marks the post `missed` and holds it — it never
          auto-publishes late (rescheduling re-arms it). Move the task via
          `PATCH /api/v1/tasks/{id}` with `statusGroup: "approved"` (a
          separate, deliberate, notifying step). Routing through
          `clientApproval` does not publish — the client must approve
          (reaching `approved`) before the slot.
        - `channels` — the per-platform connected-vs-manual breakdown: `auto`
          legs publish through a connected account; `manual` legs (no
          connected account) are posted by the team themselves.

        Side effects mirror an in-app schedule: the post-plan-change
        notification (guests only see it once the task is at `clientApproval`
        or later) and the `post.status_changed` webhook. The slot must be in
        the future (non-drafts). Fails `409` on an already-published post,
        `400` for past slots, `403` when the plan has no social posting.

        **Changed in 1.232.0 — YouTube's "made for kids" answer is required.**
        YouTube asks every upload whether the video is made for kids (COPPA),
        and Timeliner never assumes the answer (YouTube API Services Terms
        §9.1, Developer Policies III.C.1). A non-draft schedule whose
        `platforms` include `youtube`, on a post with no
        `platformOptions.youtube.madeForKids` answer, fails `422` with
        `code: "youtube_made_for_kids_required"` and schedules nothing — ask
        the user, set the answer with `PATCH /api/v1/posts/{taskId}`, and
        send the request again. A calendar draft (`draft: true`) is never
        refused for it.

        **Which tasks can be a post.** A media task, or a regular `type: doc`
        task — a text-first post, where the document is the post text and the
        task's one file (if any) is the attachment. A document parent and a
        document variant return `400`; a media parent can carry a post — its
        post goes out with every variant (see the one-plan rule below). A
        document post with NO file attached
        is a text-only post and is accepted for `linkedin`, `facebook` and
        (since 1.163.0) `threads` only; naming any other platform returns `400`
        — attach an image, video or PDF first with `POST /files/upload-from-url`
        and this task id. Threads is in early access, offered per deployment,
        and only a Timeliner team account may add it to a post — here, the
        account that created the API key. A request that adds a NEW `threads`
        leg (one the post does not already carry) from any other key, or on a
        deployment that does not offer Threads, returns `400` and writes
        nothing; the text-only `400` names `threads` only for a team key. A
        post that already goes to Threads keeps its leg on any reschedule. A
        `threads` leg on a brand without a connected Threads account is a
        `manual` leg (`notConnected`), and a brand's connected Threads account
        publishes automatically.

        **X (since 1.210.0).** `x` is a network every workspace may target: a
        text-only document post may go to it too, and the text-only `400`
        names it. A brand's connected X account publishes the post — its text
        with up to 4 photos or 1 video — and an `x` leg on a brand without one
        is a `manual` leg (`notConnected`).

        **YouTube takes video only (since 1.142.1).** Naming `youtube` for a
        task whose file is known not to be a video (an image, a PDF, audio)
        returns `400` naming `youtube` and the file's type — drafts included,
        and nothing is scheduled. Remove `youtube` from `platforms`, or
        schedule a task whose file is a video. This is the same rule that
        greys YouTube out in the app's composer. A file whose type is unknown
        is never refused here.

        **Approved, then changed.** When the workspace has **Hold posts
        changed after approval** switched on (Settings → Workspace →
        Distribution in the app; off by default since 1.113.1), a document
        post whose text or attachment changed after it was signed off is held
        at its slot (marked `missed`, team notified) exactly like an
        unapproved one, until it is approved again. With it off, the edited
        post publishes at its slot. A client's later comment or un-accepted
        suggestion does not count as a change. `approvalGate.willAutoPublish`
        does not reflect this hold, since an edit can land after scheduling.

        **One deliverable, one post plan.** A parent task and its variants are
        the same deliverable, so it publishes EITHER as the parent (all
        variants together — a carousel, or one post with a cover and the
        caption doc) OR as individual variant posts, never both. Scheduling a
        variant whose parent already holds a post — or a parent one of whose
        variants does — fails `409` (drafts too) and nothing is scheduled.
        Since 1.151.0 that `409` names the task holding the plan:
        `code: "postScopeTaken"`, `heldBy` (`parent` or `variant`) and
        `blockingTask` (`taskId`, `title`, `scheduledAt`, `overallStatus`);
        the `error` sentence is unchanged. Tell the user which post holds the
        plan; if they want this one instead, unschedule that task first
        (`DELETE /posts/{taskId}/schedule` with its `taskId`), then schedule
        again. When several variants hold posts, each refusal names one.
        Already-published posts do not block: they are history, not a
        competing plan.

        **Per-network caption limits.** Since 1.144.0 a post whose caption is
        longer than one of the requested platforms allows is refused with
        `400` and `code: "captionOverLimit"`, and nothing is scheduled — the
        `error` names the network, the length and the limit (Instagram 2,200,
        TikTok 2,200, LinkedIn 3,000, Facebook 63,206, Threads 500 characters
        — Threads counting each emoji at its UTF-8 byte length — and YouTube
        5,000 bytes of UTF-8 since 1.229.0).
        X allows 280 characters as X counts them: a link counts as 23, and
        each emoji or CJK character as 2.
        This catches a caption saved while the post had no
        networks yet. `draft: true` queues nothing and is not judged. Shorten
        the caption with `PATCH /posts/{taskId}`, then schedule again.

        **LinkedIn video size (1.160.1).** LinkedIn takes feed videos up to
        500 MB. When `platforms` includes `linkedin` (or `linkedinCompany`), the
        brand has a connected LinkedIn account and the video the LinkedIn post
        would upload is larger than that, a non-draft schedule fails `409`
        with a sentence naming the file's size and `reason:
        "linkedin_video_too_large"` — the post would otherwise be certain to
        fail at its slot. Upload a smaller file as a new version
        (`POST /files/upload-from-url`), or schedule without LinkedIn; do not
        retry the same call. A draft (`draft: true`) and a post the team publishes
        itself (no connected LinkedIn account) are never refused. A parent
        planned as a carousel uploads no single video, so this check skips it
        and the next one judges it.

        **LinkedIn carousels (1.189.1, 1.218.1).** LinkedIn gets a carousel as a
        PDF, and a PDF page can only hold an image, so LinkedIn cannot take a
        carousel with a video slide whole. When `platforms` includes `linkedin`
        (or `linkedinCompany`), the brand has a connected LinkedIn account and
        any slide LinkedIn would get is a video, a non-draft schedule fails `409`
        with `error` "A LinkedIn carousel is a PDF document, so only image slides
        can become pages, and this carousel has video slides. LinkedIn cannot take
        the whole carousel, so it was not scheduled. Switch the post to a single
        post, schedule it without LinkedIn, or post it on LinkedIn yourself." and
        nothing is scheduled. Any parent with two or more media variants defaults
        to a carousel. Since 1.218.1 this covers a carousel with enough image
        slides too: from 1.189.1 it was refused only under 2 image slides, and one
        with more was queued and published without its video slides. Schedule it
        without LinkedIn, or switch the post to Single post in the app's composer
        (the API cannot change how a post publishes). Do not retry the same call.
        A draft, a post the team publishes itself (no connected account, or
        marked "I'll post this myself") and a LinkedIn post with collaborators or
        set to a newsletter edition, which a person publishes, are never refused.

        **Threads' own limits (1.185.0; shape and frame rate 1.217.0).**
        Threads takes photos saved as JPEG or PNG up to 8 MB and no wider than
        10:1, and videos saved as MP4 or MOV up to 5 minutes and 1 GB, shaped
        between 1:100 and 10:1 (the frame a viewer sees, when Timeliner has
        recorded it; otherwise the video's stored width and height as they
        are — since 1.222.1 a 3840×300 video is refused, where 1.217.0 let it
        through) and playing at 23 to 60 frames per second (each carousel
        item judged on its own). When `platforms` includes
        `threads`, the brand has a connected Threads account and the post is
        not marked "I'll post this myself", a non-draft schedule whose Threads
        file breaks one of those rules fails `400` with
        `code: "threadsMediaRefused"` and an `error` naming the file and the
        limit, and nothing is scheduled — the same rule the app's composer
        shows before Schedule. A text-only document post with no text at all
        (no caption and an empty document) fails `400` with
        `code: "threadsTextRequired"` for the same leg. A draft, a post the
        team publishes itself and a file whose facts are unknown are never
        refused. Replace the file with `POST /files/upload-from-url`, write a
        caption with `PATCH /posts/{taskId}`, or schedule without `threads`.

        **Facebook's own limits (1.189.0).** Facebook does not let other apps
        publish a carousel that contains video, and it takes photos up to
        10 MB in the formats it accepts. When `platforms` includes `facebook`,
        the brand has a connected Facebook Page and the post is not one the
        team publishes itself, a non-draft schedule of a carousel with videos
        and fewer than two photos fails `400` with
        `code: "facebookVideoCarouselRefused"` (a parent with no saved plan
        posts as a carousel, so a parent of videos gets this), and a photo
        Facebook would refuse fails `400` with `code: "facebookPhotoRefused"`.
        Each `error` is the sentence the post would otherwise fail with at its
        slot, and nothing is scheduled; this also applies when you move a post
        that is already scheduled, which then stays on its old slot. A draft,
        a post the team publishes itself, a collab post, a brand with no
        connected Page and a carousel with two or more photos beside its
        videos are never refused for this. Schedule without `facebook`,
        schedule one variant on its own, or replace the photo with
        `POST /files/upload-from-url`; do not retry the same call.

        **YouTube videos over 15 minutes (1.163.3).** A YouTube channel that is
        not verified (or not in good standing) can only post videos up to 15
        minutes; YouTube takes a longer upload and then rejects it. When
        `platforms` includes `youtube`, the video runs over 15 minutes and
        YouTube reports that a connected channel the post would publish to is
        held to 15 minutes, a non-draft schedule fails `409` with a sentence
        naming the video's length and the way out — verify the channel at
        youtube.com/verify, use a version of 15 minutes or less, or schedule
        without YouTube; do not retry the same call. A draft, a post the team
        publishes itself, a YouTube post handed to a person (collaborators to
        invite, a Short's in-app audio) and a channel whose status YouTube does
        not report are never refused.

        **Daily YouTube limit (1.228.3).** A workspace can be held to a set
        number of YouTube videos per day (Shorts included), counted across all
        of its brands and channels in the workspace's time zone (UTC when it has
        none set). A video counts toward its day while it is scheduled, being
        published or published; a draft, a post the team publishes itself, a
        missed or failed post, and an unscheduled or deleted one do not. When
        `platforms` includes `youtube` and the post's day already holds the
        limit, a non-draft schedule fails `409` with a sentence naming the limit
        and the way out — pick another day or unschedule a video; do not retry
        the same call. A post that already counts on that day can still be
        re-saved or moved within it. Workspaces without a limit are never
        refused.

        **Instagram video length (1.163.9).** Instagram takes Story videos up to
        60 seconds and Reel or Feed videos up to 15 minutes from publishing apps.
        When `platforms` includes `instagram`, the brand has a connected Instagram
        account and the post's single video is longer than Instagram takes for
        the post's format (`platformOptions.instagram.format`; a post with none is
        a Feed post), a non-draft schedule fails `409` with a sentence naming the
        video's length and the limit, and nothing is scheduled. Before 1.163.9 this
        schedule answered `200` and the Instagram post failed at its slot. Upload a
        shorter version as a new version, change a Story to a Reel when the video
        is 15 minutes or less, or schedule without Instagram; do not retry the same
        call. A draft, a carousel, a video of unknown length, a post the team
        publishes itself (no connected account, or marked "I'll post this myself")
        and an Instagram post handed to a person for an in-app sound are never
        refused.

        **Instagram photo shape (1.224.1).** Instagram does not publish a feed
        photo or carousel photo taller than 9:16 or wider than 1.91:1 (for
        example 2048 x 1058), and one such slide makes it reject the whole
        carousel. When `platforms` includes `instagram`, the post's format
        (`platformOptions.instagram.format`; a post with none is a Feed post) is
        not a Story, and a photo the Instagram post would publish — its single
        photo, or a slide of its Instagram carousel — is outside that range, a
        non-draft schedule fails `409` with a sentence naming the photo, its
        size and the shapes to crop it to, and nothing is scheduled. This holds
        whether or not the brand has a connected Instagram account. Before
        1.224.1 this schedule answered `200` and the Instagram post failed at
        its slot. Crop the photo and upload it as a new version, post it as a
        Story, or schedule without Instagram; do not retry the same call. A
        draft, a Story, a video, a PDF and a photo of unknown size are never
        refused.
      parameters:
        - name: taskId
          in: path
          required: true
          description: The post's task UUID.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SchedulePostInput"
      responses:
        "200":
          description: The scheduled post, its approval gate, and channel breakdown.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SchedulePostResult"
        "400":
          description: |
            Invalid request. With `code: "captionOverLimit"`, the post's
            caption is longer than one of the requested platforms allows
            (e.g. "The Instagram caption is 2,412 characters; Instagram allows
            2,200. Shorten it and save again.") — nothing was scheduled. With
            `code: "threadsMediaRefused"`, Threads would refuse the Threads
            leg's file (e.g. "Threads would not accept this post's media: the
            photo "Studio portrait" is 17.4 MB, and Threads accepts photos
            up to 8 MB. Replace it and schedule the post again.", or "… the
            video "Brand reel" plays at 15 frames per second, and Threads
            accepts videos between 23 and 60 …"); with
            `code: "threadsTextRequired"`, a Threads text post has no text —
            nothing was scheduled in either case. With
            `code: "facebookVideoCarouselRefused"`, Facebook does not let other
            apps publish this carousel for its video slides (e.g. "Facebook
            does not let other apps publish a carousel that contains video —
            it accepts a carousel of photos only — and this carousel has 5
            video slides and 0 image slides. Switch this post to a single post,
            remove Facebook from it, or post it on Facebook yourself."); with
            `code: "facebookPhotoRefused"`, Facebook would refuse the Facebook
            leg's photo (e.g. "Facebook would not accept this post's photo: the
            photo "Studio portrait" is 13.6 MB, and Facebook accepts photos up
            to 10 MB. Replace it with a smaller JPEG or PNG and schedule the
            post again.") — nothing was scheduled in either case.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "422":
          description: |
            Since 1.229.0: a YouTube channel this post uploads to would get a
            title, description or tags YouTube refuses, and nothing was
            scheduled. Timeliner sends them exactly as written — it never cuts,
            strips or appends to make them fit — so fix the post with
            `PATCH /posts/{taskId}` and schedule again. Judged per channel
            (each channel's caption, else YouTube's, else the shared caption),
            a blank title on the caption's first line or the task name used
            in its place: `code: "youtubeTitleMissing"` (no title, and the
            caption and task name are empty), `"youtubeTitleTooLong"` (a blank
            title whose stand-in is over 100 characters),
            `"youtubeTitleInvalidChars"`, `"youtubeDescriptionTooLong"` (over
            5,000 bytes of UTF-8), `"youtubeDescriptionInvalidChars"` (holds
            `<` or `>`) or `"youtubeTagsTooLong"`. Never for a draft, "I'll
            post this myself", a leg handed to a person, or a brand with no
            connected YouTube channel.

            Since 1.232.0 (body: `YouTubeUploadAnswersError`):
            `code: "youtube_made_for_kids_required"` — `platforms` include
            `youtube` and the post has no `platformOptions.youtube.madeForKids`
            answer (whatever the channel — the answer is the uploader's, and
            the in-app composer asks it too); `code: "youtube_metadata_invalid"`
            with `issue` naming one of the codes above — a value that became
            one YouTube refuses while the request was in flight; and
            `code: "youtube_upload_consent_required"` — reserved for automatic
            uploads on a brand that has not given its one-time consent (an API
            request is never automatic). Nothing was scheduled.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: "#/components/schemas/YouTubeUploadAnswersError"
                  - $ref: "#/components/schemas/ErrorEnvelope"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The workspace plan does not include social posting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          description: |
            The post was not found, and nothing was scheduled. A post is keyed by
            its task, so this is the task's id. An unknown id, or a task in
            another workspace, answers the plain `Post not found` with
            `"reason": "task_not_found"` (since 1.205.0): the two are
            deliberately indistinguishable, and no body echoes the id back.
            When the id is some OTHER row your own workspace owns — a project,
            a brand or folder, a custom column, an HQ item or a file — or a
            task id with one or two characters wrong or shortened (its first 8
            characters matching a task of your workspace), `error` names which
            and what to send instead, with no `reason`. A task of your
            workspace that is in the Trash answers `"reason": "task_trashed"`
            (`list_tasks` shows it with `status: "trashed"`, and `list_posts`
            still lists its post): the API cannot restore it — a person
            restores the task, or its project, from the app's Trash page, and
            then the same call works. A task lookup that FAILS on our side
            answers `500`, never this `404`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ScheduleNotFoundError"
              examples:
                unknownPost:
                  summary: Unknown id, or a task in another workspace
                  value:
                    error: Post not found
                    reason: task_not_found
                trashedTask:
                  summary: A task of this workspace that is in the Trash
                  value:
                    error: >-
                      Post not found. That task is in the Trash (list_tasks
                      shows it with status "trashed"), so nothing was
                      scheduled. The API cannot restore it: a person restores
                      the task — or its project, if the whole project was moved
                      to the Trash — from the app's Trash page, and then this
                      call works. Otherwise schedule a task whose status is
                      "active".
                    reason: task_trashed
                projectIdAsTaskId:
                  summary: A project id was sent as the task id
                  value:
                    error: >-
                      Post not found. That id is a project in this workspace —
                      pass one of its task ids (from list_tasks, or GET
                      /api/v1/tasks?projectId=…) in the path.
        "409":
          description: |
            Either the post is already published (schedule a new post instead)
            — also when it is marked as posted while this request is in flight,
            and for `draft: true`, which since 1.118.2 also refuses a partially
            posted post (live on some of its networks — `overallStatus:
            "partial"`) because moving it to draft takes nothing down on the
            network — or the other side of this deliverable
            already holds the post plan — the parent task for a variant, or one
            of its variants for a parent. Since 1.126.0 also when the post is an
            Instagram trial-reel copy made by a repost rule and has not been
            edited yet (change its opening line and its cover or video first),
            or trial reels are off on this deployment. Since 1.142.0 also when
            the post belongs to an Instagram hook test that is still running:
            the test's copy while its new opening is still being made (or
            while trial reels are off on this deployment), and either post,
            when Instagram is among the platforms, unless its draft goes out as
            a Reel posted as a trial reel shared to followers manually. On the
            parent/variant conflict the body also carries `code:
            "postScopeTaken"`, `heldBy` and `blockingTask` (since 1.151.0).
            Since 1.160.1 also when the video the LinkedIn post would upload
            is over LinkedIn's 500 MB limit (the sentence names its size) —
            that one 409 carries `reason: "linkedin_video_too_large"`.
            Since 1.189.1 also when the post goes out to LinkedIn as a carousel
            LinkedIn's PDF cannot take whole — since 1.218.1, any carousel with a
            video slide (before, only one with fewer than 2 image slides).
            Since 1.166.1 also when the post goes out on Instagram as a trial
            reel and Instagram refused a trial reel from that same Instagram
            account in the last 14 days because the account does not meet its
            follower requirement for trial reels yet — turn the trial off to
            post it as a regular Reel, or try the trial again later.
            Since 1.180.1 also, unless `draft: true`, when the post is on the
            calendar and one of its channels went out, or may have gone out, on
            an account since erased at its owner's request, whatever its
            `overallStatus`. Since 1.163.3 also, unless `draft: true`, when the
            video runs over 15 minutes and a YouTube channel the post would
            publish to can only post videos up to 15 minutes (not verified on
            YouTube) — the sentence names the length and youtube.com/verify.
            Since 1.163.9 also when the post's single video is longer than
            Instagram takes for its format (60 seconds for a Story, 15 minutes
            for a Reel or Feed video).
            Since 1.228.3 also, unless `draft: true`, when `platforms` includes
            `youtube` and the post's day already holds the workspace's daily
            YouTube limit (a limit only some workspaces carry) — the sentence
            names the limit; pick another day or unschedule a video.
            Nothing is written.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ScheduleConflictError"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Posts]
      operationId: unschedulePost
      summary: Unschedule a post
      description: |
        Takes the post off the publish queue: clears the scheduled time and
        the scheduling status. The platform selection is kept so a later
        re-schedule doesn't force re-picking networks. Fails `409` when the
        post isn't scheduled or is already live — published, or (since
        1.118.2) partially posted, live on some of its networks. Unscheduling
        never takes a post down on the network, so a live post cannot be
        unscheduled.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - name: taskId
          in: path
          required: true
          description: The post's task UUID.
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The post's cleared scheduling state.
          content:
            application/json:
              schema:
                type: object
                required: [taskId, title, overallStatus, scheduledAt, platforms]
                properties:
                  taskId: { type: string, format: uuid }
                  title: { type: string }
                  overallStatus:
                    type: "null"
                    description: Always `null` after an unschedule.
                  scheduledAt:
                    type: "null"
                    description: Always `null` after an unschedule.
                  platforms:
                    type: array
                    description: The kept platform selection.
                    items:
                      $ref: "#/components/schemas/SocialPlatform"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The workspace plan does not include social posting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          description: |
            The post was not found, and nothing was unscheduled. A post is keyed by
            its task, so this is the task's id. An unknown id, or a task in
            another workspace, answers the plain `Post not found` with
            `"reason": "task_not_found"` (since 1.205.0): the two are
            deliberately indistinguishable, and no body echoes the id back.
            When the id is some OTHER row your own workspace owns — a project,
            a brand or folder, a custom column, an HQ item or a file — or a
            task id with one or two characters wrong or shortened (its first 8
            characters matching a task of your workspace), `error` names which
            and what to send instead, with no `reason`. A task of your
            workspace that is in the Trash answers `"reason": "task_trashed"`
            (`list_tasks` shows it with `status: "trashed"`, and `list_posts`
            still lists its post): the API cannot restore it — a person
            restores the task, or its project, from the app's Trash page, and
            then the same call works. A task lookup that FAILS on our side
            answers `500`, never this `404`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ScheduleNotFoundError"
              examples:
                unknownPost:
                  summary: Unknown id, or a task in another workspace
                  value:
                    error: Post not found
                    reason: task_not_found
                trashedTask:
                  summary: A task of this workspace that is in the Trash
                  value:
                    error: >-
                      Post not found. That task is in the Trash (list_tasks
                      shows it with status "trashed"), so nothing was
                      unscheduled — but a post whose task is in the Trash does
                      not publish while it stays there. The API cannot restore
                      it: if a person restores the task — or its project, if
                      the whole project was moved to the Trash — from the app's
                      Trash page, its schedule comes back (a queued post whose
                      slot already passed comes back as a draft), and then this
                      call works.
                    reason: task_trashed
                projectIdAsTaskId:
                  summary: A project id was sent as the task id
                  value:
                    error: >-
                      Post not found. That id is a project in this workspace —
                      pass one of its task ids (from list_tasks, or GET
                      /api/v1/tasks?projectId=…) in the path.
        "409":
          description: |
            The post isn't scheduled, or is already live — published or
            partially posted (`overallStatus: "partial"`, since 1.118.2) —
            also when it is marked as posted, or the publish engine rolls it
            up to a live status, while this request is in flight.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/channels:
    get:
      tags: [Posts]
      operationId: listChannels
      summary: List social channels (connected vs manual), per brand
      description: |
        The connected-vs-manual channel map — the read an assistant uses to
        answer "which platforms will auto-post and which are manual?" before
        scheduling. Every platform is listed for every brand (or the one
        selected via `brandId`) — `threads` only where this deployment offers
        Threads AND the account that created the API key is a Timeliner team
        account, or where the brand already has a Threads account (in any
        status). Threads is in early access: only Timeliner team accounts can
        connect it or add it to a post; a `threads` leg on a brand without a
        connected Threads account is manual. Each listed platform carries:

        - `connected` — a live (`status: connected`) account exists; scheduled
          legs on this platform auto-publish.
        - `autoPublishSupported` — the platform has a publishing provider
          (when `false`, its legs are always manual).
        - `account` — the account row when one exists in ANY status (an
          `expired`/`revoked` account is surfaced so you can prompt a
          reconnect, but `connected` is `false`).

        `x` (since 1.210.0) is listed for every brand.

        Accounts connect in-app (brand dialog → Connected accounts, or a
        client connect link) — the API cannot run the OAuth flow.
      parameters:
        - name: brandId
          in: query
          required: false
          description: Restrict to one brand/client (404 on miss).
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Per-brand channel maps.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      required: [brandId, brandName, channels]
                      properties:
                        brandId: { type: string, format: uuid }
                        brandName: { type: string }
                        channels:
                          type: array
                          items:
                            type: object
                            required: [platform, connected, autoPublishSupported, account]
                            properties:
                              platform:
                                $ref: "#/components/schemas/SocialPlatform"
                              connected: { type: boolean }
                              autoPublishSupported: { type: boolean }
                              account:
                                oneOf:
                                  - $ref: "#/components/schemas/SocialAccount"
                                  - type: "null"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/analytics/social:
    get:
      tags: [Analytics]
      operationId: getSocialAnalytics
      summary: Social-performance analytics (views, engagement, channels, posts)
      description: |
        The social-performance bundle — the same numbers as the in-app
        Analytics → Social section, in one call: KPIs (views / engagement /
        engagement rate / posts published, each with a previous-window
        comparison and follower delta), per-day trend, per-channel breakdown,
        post performance rows (with permalinks), top posts, engagement heatmap
        (weekday × hour), content mix, publishing funnel, planned-content
        pipeline, and follower trend.

        **Views-based metric model (v1.47.0):** `views` is the cross-platform
        view count — per post `videoViews ?? impressions` (YouTube / Instagram
        / TikTok report view counts in `videoViews`; Meta / X label their
        impressions "views"). Engagement rate everywhere is
        `(likes + comments) / views`. Lead reports with views / likes /
        comments / shares; `reach` / `impressions` remain on rows as legacy
        Meta-only fields (always `null` on YouTube).

        **Honesty contract:** entries with `metricsAvailable: false` carry
        `metrics: null` — that platform's numbers were never fetched (manual
        posts, or no metrics integration yet). Report "no data", never zeros.
        `hasEverPublished: false` means nothing was ever published through
        Timeliner AND no connected account has imported history (empty state);
        a workspace that only imported its history reads `true`.

        **Posts published outside Timeliner (v1.103.0):** once a connected
        account's history import has run, `posts[]` — and therefore the KPIs,
        trend, channels, top posts, heatmap and content mix — also include the
        account's own posts published natively or by another tool, with
        `source: "external"`, `externalPostId`, `externalThumbnailUrl` and
        `durationSeconds`; their `scheduledPostId` / `taskId` are `null`, they
        carry no `editorIds`, and they never enter `byEditor`, `funnel` or
        `planned`. A post that is also a Timeliner leg of the same account is
        counted once (as the Timeliner row). Every other row carries
        `source: "timeliner"`. External posts are excluded under a
        `projectId` scope (they belong to no project). Account-level daily
        history and demographics live at `GET /api/v1/analytics/social/history`.

        **One account on several brands (v1.180.0):** one real account connected
        to several brands counts once. `channels[]` holds one row for it, reported
        under one connection in `socialAccountId` with all of its connections in
        `connectionIds`; `posts[]` lists each post once; followers and the KPIs
        count it once. `connectedAccounts[]` stays per connection, so it can list
        more rows than `channels[]`. A `posts[].socialAccountId` is the connection
        that imported or published that post, which is any of `connectionIds`.
        Under a `brandId`, followers read the same as with no brand; a post
        published through Timeliner from another brand reads `source: "external"`,
        once.

        **YouTube is reported on its own (v1.231.0 — compliance-driven
        behaviour change).** Under the YouTube API Services Developer
        Policies, YouTube data is never combined with another network's and
        never summed across YouTube channels. Every COMBINED field —
        `kpis`, `trend`, `channels`, `posts`, `postsTruncated`, `topPosts`,
        `heatmap`, `contentMix`, `byEditor`, `funnel.engaged`,
        `followerTrend` — now leaves YouTube out; `pooledExcludes` names what
        they leave out (`["youtube"]`). YouTube lives only in `youtube`: one
        `channels[]` report per channel (its own current and previous totals,
        engagement rate, subscribers gained / lost and daily trend) plus that
        channel's `posts`. Never add a YouTube number to another network's or
        to another channel's; report it per channel and say it comes from
        YouTube. A YouTube subscriber history estimated backwards from the
        live count never moves a follower change. `connectedAccounts` still
        lists YouTube accounts (identity only).

        **Changed in 1.233.0 — a disconnected YouTube channel is hidden at
        once.** Under the YouTube API Services Developer Policies, a channel
        disconnected through Timeliner stops being used the moment it is
        disconnected: it has no `youtube.channels` report, none of its posts
        (published through Timeliner or imported) are in `youtube.posts`, any
        total, `planned`, `hasEverPublished` or the history endpoints, and it
        never adds to the report of the same channel still connected to another
        brand. Its data is kept for 6 days — reconnect the same channel to the
        same brand within them and every number comes back unchanged — and
        deleted after that. An **expired** YouTube channel (its Google access
        stopped working) keeps reporting until it is reconnected or its data
        is deleted. Other networks are unchanged: a disconnected account's
        posts keep counting. The response shape is the same.

        Defaults to the last 30 days ending now. This endpoint is distinct
        from `GET /api/v1/analytics` (business/production analytics).
      parameters:
        - name: from
          in: query
          required: false
          description: ISO window start (default 30 days before `to`).
          schema: { type: string, format: date-time }
        - name: to
          in: query
          required: false
          description: ISO window end (default now).
          schema: { type: string, format: date-time }
        - name: brandId
          in: query
          required: false
          description: Restrict to one brand/client (404 on miss).
          schema: { type: string, format: uuid }
        - name: projectId
          in: query
          required: false
          description: Restrict to one project (400 on miss).
          schema: { type: string, format: uuid }
        - name: accountId
          in: query
          required: false
          description: Restrict to one connected social account. An account connected to several brands is read as one, whichever of its connections you name.
          schema: { type: string, format: uuid }
        - name: platforms
          in: query
          required: false
          description: Comma-separated platform filter (e.g. `instagram,youtube`).
          schema: { type: string }
        - name: timeZone
          in: query
          required: false
          description: IANA zone for day/heatmap bucketing (default UTC).
          schema: { type: string }
      responses:
        "200":
          description: The social analytics bundle.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SocialAnalytics"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The workspace plan does not include social posting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/analytics/social/insights:
    get:
      tags: [Analytics]
      operationId: getSocialContentInsights
      summary: What worked — top and bottom posts with their hooks and transcripts
      description: |
        "What worked" (v1.102.0): the published posts that beat (`winners`)
        and trailed (`losers`) their platform's typical engagement rate — top
        and bottom 5 by engagement rate **normalised per platform** (the post's
        rate ÷ that platform's median rate = `relativeToMedian`) — each joined
        with its **hook** (the caption's first line, or what the video says in
        its first 8 seconds when a transcript exists), a transcript excerpt
        (≤ 600 characters), duration, format and metrics; plus deterministic
        `patterns` comparing winners with losers (hook length, question hooks,
        duration, format, caption length) and the best weekday / hour against
        the median, each with `sampleSize` and `lowConfidence` (sample < 8).
        A published video removed after the workspace's subscription ended
        (see *Removed media*) contributes no transcript: its hook is the
        caption's and its `transcriptExcerpt` is null (since 1.109.0).

        Scoring rules: `engagementRate = (likes + comments) / views`; only
        posts published ≥ 24 h ago with a positive view count are scored, and a
        platform needs ≥ 3 such posts before any of its posts are ranked.
        `postCount: 0` = not enough data yet. Same query parameters, plan gate
        and scope (`read:posts`) as `GET /api/v1/analytics/social`; the default
        window is the last **90** days.

        **YouTube is never scored or ranked (v1.231.0 — compliance-driven).**
        Under the YouTube API Services Developer Policies no YouTube post is
        compared with a "typical" rate, ranked or used in a pattern;
        `excludedPlatforms` (`["youtube"]`) says so. A `platforms=youtube`
        read returns `postCount: 0`.
      parameters:
        - name: from
          in: query
          required: false
          description: ISO window start (default 90 days before `to`).
          schema: { type: string, format: date-time }
        - name: to
          in: query
          required: false
          description: ISO window end (default now).
          schema: { type: string, format: date-time }
        - name: brandId
          in: query
          required: false
          description: Restrict to one brand/client (404 on miss).
          schema: { type: string, format: uuid }
        - name: projectId
          in: query
          required: false
          description: Restrict to one project (400 on miss).
          schema: { type: string, format: uuid }
        - name: accountId
          in: query
          required: false
          description: Restrict to one connected social account.
          schema: { type: string, format: uuid }
        - name: platforms
          in: query
          required: false
          description: Comma-separated platform filter (e.g. `instagram,youtube`).
          schema: { type: string }
        - name: timeZone
          in: query
          required: false
          description: IANA zone for the weekday / hour patterns (default UTC).
          schema: { type: string }
      responses:
        "200":
          description: Winners, losers and pattern findings.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ContentInsights"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The workspace plan does not include social posting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/analytics/social/history:
    get:
      tags: [Analytics]
      operationId: getSocialHistory
      summary: Social account history — daily metrics, demographics, import status
      description: |
        Account-level social history (v1.103.0) for every connected account in
        scope: one point per account per **UTC day** (the networks' own day)
        with `followers` (YouTube: subscribers, reconstructed backwards from the
        live count), `followersGained` / `followersLost`, `views`, `reach`,
        `impressions`, `engagement`, `likes`, `comments`, `shares`, `saves`,
        `profileVisits`, `websiteClicks`, `watchMinutes` and `postsPublished`
        (Timeliner posts + posts imported from outside Timeliner); the latest
        audience `demographics` per account (gender / age / country / city
        shares, 0–1 — `basis` `followers` on Instagram, `viewers` on YouTube);
        and each account's `importStatus`.

        **Honesty contract:** a metric a network does not report is `null`,
        never 0. Demographic arrays are empty below a network's privacy
        threshold (Instagram needs 100+ followers). History exists only once
        an account's import has run (`importStatus[].state` `running` /
        `done`); `unsupportedReason` names why a platform cannot import yet:
        `tiktokApproval` (TikTok analytics is not available on Timeliner yet,
        so no TikTok account can import, reconnected or not),
        `linkedinApproval` (LinkedIn has not approved the access this
        account's history needs), `reconnectRequired` (the account must be
        reconnected first: its connection expired or its grant lacks the
        scope the import reads — since v1.162.0 this includes, once TikTok
        analytics is available, a TikTok account whose grant lacks
        `video.list`, such as one connected before then), or — since 1.163.0 —
        `notSupported` (Timeliner has no importer for that network's past
        posts yet; a connected Threads account reports it once the importer
        has run on it (`state` `unsupported`), and only the posts it
        published through Timeliner are counted).

        Same query parameters, plan gate and scope (`read:posts`) as
        `GET /api/v1/analytics/social`; `timeZone` turns `from` / `to` into
        days. Under a `projectId` scope, `postsPublished` counts only that
        project's Timeliner posts. Defaults to the last 30 days. Since 1.233.0
        a disconnected YouTube channel's posts are never counted, also under
        the same channel connected to another brand (see
        `GET /api/v1/analytics/social`).

        **One account on several brands (v1.180.0):** one real account connected
        to several brands has one `daily` point per day and one `demographics`
        row, under one connection's `socialAccountId`, and `postsPublished` counts
        each post once. `accounts` and `importStatus` stay per connection. Each
        metric is the newest value any of the account's connections reported, so
        a `brandId` returns the same account numbers as no brand at all;
        `postsPublished` still counts only the posts in that brand's scope.

        **YouTube rows stand alone (v1.231.0 — YouTube API Services).** Never
        sum YouTube `daily` rows across accounts or add them to another
        network's rows: report each YouTube channel on its own and say the
        numbers come from YouTube. A YouTube `followers` value is reconstructed
        backwards from the live subscriber count — present it as an estimate,
        never as a measured history.
      parameters:
        - name: from
          in: query
          required: false
          description: ISO window start (default 30 days before `to`).
          schema: { type: string, format: date-time }
        - name: to
          in: query
          required: false
          description: ISO window end (default now).
          schema: { type: string, format: date-time }
        - name: brandId
          in: query
          required: false
          description: Restrict to one brand/client (404 on miss).
          schema: { type: string, format: uuid }
        - name: projectId
          in: query
          required: false
          description: Restrict to the accounts of one project's brand (400 on miss).
          schema: { type: string, format: uuid }
        - name: accountId
          in: query
          required: false
          description: Restrict the per-account arrays to one connected social account.
          schema: { type: string, format: uuid }
        - name: platforms
          in: query
          required: false
          description: Comma-separated platform filter (e.g. `instagram,youtube`).
          schema: { type: string }
        - name: timeZone
          in: query
          required: false
          description: IANA zone used to turn `from` / `to` into days (default UTC).
          schema: { type: string }
      responses:
        "200":
          description: The social history bundle.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SocialHistory"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: The workspace plan does not include social posting.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/platform-guidance:
    get:
      tags: [Posts]
      operationId: listPlatformGuidance
      summary: Official social-platform guidance, with sources
      description: |
        Official statements from the social platforms themselves (v1.102.0) —
        third-party scheduling & reach, original vs reposted content, trial
        reels, collaborators, audio, posting limits, required disclosures and
        API deprecations — newest first. Every item cites an official platform
        page (`sourceUrl`, always on an allowlisted official domain), the
        source's own date (`publishedAt`, may be `null`) and when Timeliner
        read it (`fetchedAt`). Collected weekly; until the first collection
        lands the response is the built-in verified set (`source: "seed"`).
        Global content — identical for every workspace, not plan-gated; scope
        `read:posts`.

        `scope=workspace` (v1.118.0) answers "any platform changes I should
        know about?" for the key's own workspace instead: only the networks it
        has a connected (not disconnected) account on, each item carrying
        `affects` — the accounts on that network and the upcoming and
        last-30-days posts it touches — developer / API notices (topic
        `apiDeprecations`) left out because Timeliner handles them, and
        `accountsNeedingAttention` listing accounts whose connection expired
        or was revoked. With nothing connected, `items` is empty and `note`
        says so — never the generic list. The default `scope=all` is the
        unchanged global list.
      parameters:
        - name: scope
          in: query
          required: false
          description: |
            `all` (default) = the global list (`PlatformGuidanceList`);
            `workspace` = the key's workspace's connected networks, accounts
            and posts (`WorkspacePlatformGuidanceList`). v1.118.0.
          schema:
            type: string
            enum: [all, workspace]
        - name: platform
          in: query
          required: false
          description: Restrict to one platform.
          schema:
            type: string
            enum: [instagram, facebook, tiktok, youtube, linkedin, x, threads, general]
        - name: topic
          in: query
          required: false
          description: Restrict to one topic.
          schema:
            type: string
            enum:
              - thirdPartyScheduling
              - originality
              - trialReels
              - collaborators
              - audio
              - postingLimits
              - apiDeprecations
              - disclosures
              - other
        - name: limit
          in: query
          required: false
          description: Items to return, 1–50 (default 20).
          schema: { type: integer, minimum: 1, maximum: 50 }
      responses:
        "200":
          description: |
            Guidance items, newest first — `PlatformGuidanceList` for
            `scope=all` (the default), `WorkspacePlatformGuidanceList` for
            `scope=workspace`.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: "#/components/schemas/PlatformGuidanceList"
                  - $ref: "#/components/schemas/WorkspacePlatformGuidanceList"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/project-files:
    get:
      tags: [Tasks]
      operationId: listTaskProjectFiles
      summary: List a task's Project files tab
      description: |
        What is on a task's **Project files** tab (1.159.0), in two halves:

        - `taskFiles` — files dropped on the task by the client or the team
          ("Files on this task"). They are ordinary raw project files, kept in
          the project's Raw files in a folder named after the task
          (`folderId`, null until the first file). `fromClient` marks a
          client's upload.
        - `projectFile` — the team-only editing-project backups (Premiere,
          After Effects, Resolve, Photoshop, Illustrator, or a zip of the
          project folder), newest first; `isCurrent` marks the one the next
          editor should open. `null` on a document task, which has no backup
          slot. Backups never appear in `GET /api/v1/projects/{id}/files`.

        Download any file with `GET /api/v1/files/{id}/download`. Add to
        either half with `taskId` + `target` (`taskFiles` / `projectFile`) on
        `POST /api/v1/files/upload-from-url` or the multipart
        `POST /api/v1/files/uploads`. A **parent** task has no tab — each of
        its variants carries one — so its id answers `400`. Requires the
        `read:tasks` scope.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      responses:
        "200":
          description: Both halves of the tab.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskProjectFiles"
              example:
                taskId: "11111111-1111-1111-1111-111111111111"
                taskFiles:
                  folderId: "33333333-3333-3333-3333-333333333333"
                  files:
                    - id: "44444444-4444-4444-4444-444444444444"
                      name: winter-campaign-moodboard.jpg
                      size: 482113
                      mimeType: image/jpeg
                      createdAt: "2026-10-22T09:12:00Z"
                      fromClient: true
                      uploaderId: "55555555-5555-5555-5555-555555555555"
                      mediaRemoved: false
                projectFile:
                  backups:
                    - id: "66666666-6666-6666-6666-666666666666"
                      name: winter-reel.prproj
                      size: 1843200
                      mimeType: application/octet-stream
                      createdAt: "2026-10-22T10:40:00Z"
                      label: null
                      isCurrent: true
                      uploaderId: "77777777-7777-7777-7777-777777777777"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
  /api/v1/files/upload-from-url:
    post:
      tags: [Files]
      operationId: uploadFileFromUrl
      summary: Upload a file into the workspace from a public URL
      description: |
        Pulls a publicly reachable `http(s)` file server-side and attaches it,
        running the same post-upload steps the in-app uploader runs.

        Two destinations:

        - **Task version (the deliverable)** — pass `taskId`. The file becomes
          the task's current version, a `TaskVersion` row is created,
          "version uploaded" automations fire, reviewers get the approval
          notification, and a New Version entry appears in the Activity Log.
          A **parent** task holds no file of its own (its variants each carry
          theirs), so a parent task's id answers `400` whose `error` reads:
          *`taskId` is a parent task, which holds no file of its own — upload
          to one of its variants instead* — nothing is pulled or stored.
        - **Project raw file** — pass `projectId` (optionally `folderId`). The
          team gets the usual project-file notification.
        - **The task's Project files tab (1.159.0)** — pass `taskId` with
          `target`: `taskFiles` drops the file on the task ("Files on this
          task": a raw project file in the folder named after the task, with
          the usual project-file notification and `file.uploaded` webhook);
          `projectFile` stores a team-only backup of the editing project
          (`.prproj`, `.aep`, `.drp`, `.drt`, `.psd`, `.ai` or `.zip`, media
          tasks only) that becomes the task's Current backup, keeps its own
          name, and notifies no one. Any other file sent as `projectFile`
          answers `400` `code: NOT_A_PROJECT_FILE` (*Only project files can be
          backed up here*). An API backup carries no footage list — the app
          reads that from the file in the browser only. List the tab with
          `GET /api/v1/tasks/{id}/project-files`.

        **Post covers:** upload the image (JPEG, PNG or WebP) with
        `projectId`, then send the returned `id` to
        `PATCH /api/v1/posts/{taskId}` as `thumbnailFileId`.

        **Parallel uploads onto one task are safe (1.98.2).** Calls that
        target the same `taskId` at the same time are applied one after
        another: each gets its own consecutive `versionNumber` and every file
        becomes a version. A version that cannot be recorded answers `500` with
        nothing attached — a `201` always means the version exists.

        Limits and guards: the URL must be reachable without authentication,
        must not resolve to a private / loopback / link-local / cloud-metadata
        address (redirects are re-checked at every hop), and the body must be
        at most **100 MB**. Larger deliverables go through the app's own
        multipart uploader. Videos are validated before they are attached, and
        media is queued for transcoding exactly as an in-app upload would be.

        The stored `mimeType` is the canonical form the app uses (for example
        `audio/mp3` is stored as `audio/mpeg`). XML timelines (`.xml` /
        `.fcpxml`) are accepted as **project files only** — refused as a task
        version — and are stored as `application/octet-stream`. A project-only
        file sent as a task version answers `400` naming the two ways to store
        it: for an editing project (`.prproj`, `.aep`, `.drp`, `.psd`, `.ai`,
        a `.zip`) `target: "projectFile"` (the task's backup), for any other
        project-only type (an XML timeline, a camera raw, a LUT …)
        `target: "taskFiles"` — and `projectId` (Raw files) for either.

        **Images get their card thumbnail here too.** JPEG, PNG, GIF, TIFF,
        WebP and HEIC are rendered server-side as they land, so the file shows
        its picture on every card and `media.thumbnailUrl` is populated on the
        very next read — and AI caption generation
        (`POST /api/v1/posts/{taskId}/caption/generate`) can see the image
        instead of answering `no_visuals`. BMP and SVG are stored and
        downloadable as before but get no thumbnail. A thumbnail that cannot be
        rendered never fails the upload: the file still lands, without one.

        Uploading a file from the caller's own device, and pointing at a local
        folder to batch-match files to tasks, are NOT supported by this
        endpoint — both are client-side mechanics with no server-side
        equivalent.

        A workspace whose uploads are paused answers
        **403** `code: UPLOADS_PAUSED` (see *Uploads paused*). Nothing is pulled.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UploadFileFromUrlRequest"
      responses:
        "201":
          description: The file was stored and attached.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadedFile"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: |
            The `taskId` (or `projectId`) is not in your workspace, and
            nothing was started or stored. When the `taskId` is instead
            another row your OWN workspace owns — a project, a brand/folder,
            or a custom column (since 1.110.2), or an HQ item or a file
            (since 1.112.1) — `error` names which and where it belongs: the
            commonest mistake on this endpoint is a project id sent as
            `taskId`, which belongs in `projectId`, and an HQ item takes files
            through `POST /api/v1/hq/items/{id}/files` instead. Since 1.149.4
            a `taskId` that looks **shortened** — its first 8 characters match
            a task of your workspace, the rest padded or made up — names that
            task's full id when exactly one matches (a task id is always the
            full 36 characters); since 1.159.1 a `taskId` with one or two
            characters wrong (mistyped) names the task it is that close to,
            the same way. An unknown id, or a task in another workspace
            (mistyped, padded or not), keeps the plain `Task not found` error:
            the two are deliberately indistinguishable, and no body echoes the
            id back. Since 1.161.0 that plain body also carries
            `"reason": "task_not_found"` — the one machine-readable marker of
            "no task with this id in your workspace" (a named mistake above has
            no `reason`) — and a task lookup that FAILS on our side answers
            `500`, never this `404`. Get the task's id again (`GET
            /api/v1/tasks`) and send all 36 characters, or upload without a task.

            Since 1.159.2 a `projectId` sent WITHOUT a `taskId` gets a similar
            recovery (a `projectId` has no mistyped-id check): when it is
            another row your OWN workspace owns — a task, a sub-folder (task
            group), a folder inside a project's files, a brand/folder, an HQ
            item or a file — `error` names which and where it belongs (a task's
            id goes in `taskId`, or its project's id, named in the body, in
            `projectId`; a project folder's project id is named the same way
            and the folder goes in `folderId`; a sub-folder's project id is
            named too). A `projectId` that looks
            **shortened** — its first 8 characters match a project of your
            workspace, the rest padded or made up — names that project's full
            id when exactly one matches (a project id is always the full 36
            characters). An unknown id, or a project in another workspace
            (padded or not), keeps the plain `{"error":"Project not found"}`
            body, and no body echoes the id back.

            Since 1.187.0 a `folderId` that is no folder of the project gets
            the same kind of recovery, and nothing is pulled or saved: when it
            is a folder of another project of your workspace, `error` names that
            project for `projectId`; a folder of a brand header's raw files names
            the brand (send the call without `folderId`, then
            `POST /api/v1/files/{id}/move` with `brandId` + `folderId`); a
            sub-folder of tasks, a brand or sidebar folder, or a project is named
            as such; a shortened id names the project's folder it matches. An
            unknown id, or a folder in another workspace, reads exactly
            `{"error":"Folder not found","reason":"folder_not_found"}`, and no
            body echoes the id back.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadTaskNotFoundError"
              examples:
                unknownFolder:
                  summary: Unknown folder id, or a folder in another workspace
                  value:
                    error: Folder not found
                    reason: folder_not_found
                brandFolderInFolderId:
                  summary: A brand header's folder was sent as folderId
                  value:
                    error: >-
                      Folder not found. That id is a folder of a brand header's
                      raw files in this workspace, and an upload can only be
                      filed in a folder of a project. Nothing was saved. Send
                      this call without `folderId`, then file it there with
                      move_file (POST /api/v1/files/{id}/move), passing the
                      brand's id, 7c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f, as
                      `brandId` and this folder's id as `folderId`.
                unknownTask:
                  summary: Unknown task id, or a task in another workspace
                  value:
                    error: Task not found
                    reason: task_not_found
                projectIdInTaskId:
                  summary: A project id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is a project in this workspace —
                      pass it as `projectId` instead to save the file as a raw
                      project file, or pass one of its task ids (from
                      list_tasks, or GET /api/v1/tasks?projectId=…) as `taskId`
                      to add the file as that task's new version.
                brandIdInTaskId:
                  summary: A brand or folder id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is a brand or folder in this
                      workspace — `taskId` takes a task id (from list_tasks, or
                      GET /api/v1/tasks) and `projectId` takes a project id
                      (from list_projects, or GET /api/v1/projects).
                hqItemIdInTaskId:
                  summary: An HQ item id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is an HQ item in this workspace —
                      attach a file to an HQ item with
                      upload_hq_item_file_from_url (POST
                      /api/v1/hq/items/{id}/files). `taskId` takes a project
                      task's id (from list_tasks, or GET /api/v1/tasks).
                shortenedTaskId:
                  summary: A shortened id whose first 8 characters match one of your tasks
                  value:
                    error: >-
                      Task not found. No task has that exact id, but one task in
                      this workspace has an id starting with the same 8
                      characters: 3f2a9c10-5b7e-4d21-9a8c-1e6f0b2d4c55. The id
                      sent looks shortened and filled back out — a task id is
                      always the full 36 characters, exactly as list_tasks,
                      get_task or create_task returned it, never shortened or
                      padded. If that is the task you meant, retry with its full
                      id.
                unknownProject:
                  summary: Unknown project id, or a project in another workspace
                  value:
                    error: Project not found
                taskIdInProjectId:
                  summary: A task id was sent as projectId
                  value:
                    error: >-
                      Project not found. That id is a task in this workspace —
                      pass it as `taskId` instead to add the file as that
                      task's new version, or pass its project's id,
                      7c41e2d0-9a3b-4f6e-8d15-2b0c9e4f7a61, as `projectId` to
                      save the file as a raw project file.
                projectFolderIdInProjectId:
                  summary: A folder inside a project's files was sent as projectId
                  value:
                    error: >-
                      Project not found. That id is a folder inside a project's
                      files in this workspace — pass its project's id,
                      7c41e2d0-9a3b-4f6e-8d15-2b0c9e4f7a61, as `projectId` and
                      the folder's id as `folderId`.
                shortenedProjectId:
                  summary: A shortened id whose first 8 characters match one of your projects
                  value:
                    error: >-
                      Project not found. No project has that exact id, but one
                      project in this workspace has an id starting with the
                      same 8 characters: 7c41e2d0-9a3b-4f6e-8d15-2b0c9e4f7a61.
                      The id sent looks shortened and filled back out — a
                      project id is always the full 36 characters, exactly as
                      list_projects, get_project or create_project returned it,
                      never shortened or padded. If that is the project you
                      meant, retry with its full id.
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/doc-attachments/upload-from-url:
    post:
      tags: [Files]
      operationId: uploadDocAttachmentFromUrl
      summary: Upload an image or file into a document from a public URL
      description: |
        Pulls a publicly reachable `http(s)` image or file server-side and
        stores it as **document content** — the bytes an HQ item's Document
        tab, a doc task's body, or a task brief renders inline.

        Use it in two steps:

        1. `POST` here with the source `url`.
        2. Paste the returned `embedHtml` into the `contentHtml` you send to
           `PUT /api/v1/hq/items/{id}/doc` or `PATCH /api/v1/tasks/{id}/doc`.
           Those endpoints REPLACE the whole body, so keep the surrounding HTML.

        `embedHtml` is the exact markup the in-app editor produces: an `<img>`
        for images, an inline player block for videos, and a download chip for
        every other allowed type. `url` on its own is the app-relative path the
        document renders from (viewers need a Timeliner session, same as an
        attachment added in the app).

        Allowed types and per-type ceilings: JPEG / PNG / GIF / WebP / TIFF /
        BMP / HEIC / HEIF (**10 MB**), MP4 / WebM / QuickTime / OGG
        (**95 MB**; 100 MB before 1.129.1), audio — MP3 / WAV / AIFF / AAC /
        M4A / FLAC / OGG (**50 MB**, e.g. sound effects; embedded as a chip
        the editor can play), PDF / Word / PowerPoint / Excel, DaVinci Resolve
        project files and XML timelines (`.xml` / `.fcpxml`) (**25 MB**),
        `text/plain` (**1 MB**). A file over its type's ceiling — or over
        95 MB, the most any document attachment can be, which is as far as
        the server downloads (since 1.153.0; 100 MB before) — answers **400**
        with `reason: file_too_large` and `maxBytes` (the ceiling it went
        over), and nothing is stored. The `error` still starts
        `File too large (max N MB).` and then names the file's kind and size
        when known, every document limit, and what works instead: a smaller
        copy, or a plain link to the file in the document. The app's document
        editor has the same limits, so uploading the file there instead does
        not help. SVG is not allowed. An XML timeline is always stored and returned as
        `mimeType: application/octet-stream` whatever the source served it as,
        so it downloads rather than being displayed.

        Same SSRF guards as `POST /api/v1/files/upload-from-url`: the URL must
        be reachable without authentication and must not resolve to a private,
        loopback, link-local or cloud-metadata address (redirects are
        re-checked at every hop).

        This is **not** a task deliverable and **not** a project raw file — use
        `POST /api/v1/files/upload-from-url` for those. Uploading bytes from
        the caller's own device is not supported (no server-side equivalent).

        A workspace whose uploads are paused answers
        **403** `code: UPLOADS_PAUSED` (see *Uploads paused*). Nothing is pulled.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UploadDocAttachmentFromUrlRequest"
      responses:
        "201":
          description: The attachment was stored and is ready to embed.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadedDocAttachment"
        "400":
          description: |
            The body failed validation, the `url` was refused (private address,
            bad scheme, the remote host answered an error), the type is not
            allowed in documents, or the file is over a document limit — that
            last one answers `reason: file_too_large` with `maxBytes`. Nothing
            is stored.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocAttachmentUploadError"
              examples:
                fileTooLarge:
                  summary: An image over the 10 MB image limit
                  value:
                    error: >-
                      File too large (max 10 MB). This image is 12.5 MB, over the
                      10 MB a document allows for it. Document limits: videos 95 MB,
                      audio 50 MB, PDF, Word, PowerPoint, Excel and project files
                      25 MB, images 10 MB, plain text 1 MB. Nothing was stored. The
                      app's document editor has the same limits, so adding the file
                      there will not work either: use a smaller copy of the file, or
                      put a plain link to it in the document instead. Do not retry
                      the same URL.
                    reason: file_too_large
                    maxBytes: 10485760
                typeNotSupported:
                  summary: A type documents do not take
                  value:
                    error: File type not supported in documents
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/{id}/download:
    get:
      tags: [Files]
      operationId: getFileDownloadUrl
      summary: Get a presigned download URL for a file
      description: |
        Generates a presigned URL for a file in the workspace, valid for
        7 days (`expiresAt` says exactly when — fetch a fresh one after that).
        Use `type` to choose between the original upload, a generated
        preview, the thumbnail, or an MP4 copy of a transcoded height
        (`type=variant&height=N`).

        **Brand files (1.134.0).** `id` can also be a brand file — one of a
        brand header's Raw files & Assets (logos, fonts, global assets), the
        `files[].id` of `GET /api/v1/brands/{id}/files` and
        `GET /api/v1/brands/{id}/header`. A key that also holds the
        `read:files` scope downloads exactly the brand files it can list
        there (listing needs `read:projects`, downloading `read:files`): one
        still uploading, in the trash or deleted answers 404
        `File not found`, like an unknown id. A brand file has no on-demand
        MP4 copies: `type=variant` serves only a copy it already has, and
        never answers 202.

        Requires the `read:files` scope.

        **Variants are created on demand (1.123.0).** Transcoding produces
        streaming renditions, not files, so the first `type=variant` request
        for a height the video was transcoded to (its `media.availableHeights`)
        starts making the MP4 and answers **202** `{ status: "generating",
        type, height, retryAfterSeconds }` with a `Retry-After` header. Call
        the same URL again after that many seconds: it keeps answering 202
        until the copy exists, then **200** with the URL (the copy also
        appears in `media.variants` from then on). This needs the workspace
        setting **Settings → Workspace → Media & Workflow → Proxies → On-demand proxy
        generation**; while it is off the request answers **403**
        `variant_downloads_disabled` (copies created earlier stay
        downloadable). A height the video was not transcoded to answers
        **404** `variant_unavailable`; a video still transcoding answers
        **409** `transcoding_in_progress`.

        Pass `downloadName` to force the browser to download the file
        under a specific name (`Content-Disposition: attachment`).

        A file whose content was removed after the workspace's subscription
        ended answers **404** with `code: file_content_missing` and
        `purgedAt` for every `type`. Reactivating the subscription restores
        the content and the links only if the file has not yet been
        permanently deleted; a deleted file keeps answering 404
        `file_content_missing`.
      parameters:
        - name: id
          in: path
          required: true
          description: |
            The file's UUID — a task's or project's file, or a brand file
            (`files[].id` of `GET /api/v1/brands/{id}/files` or `/header`).
          schema:
            type: string
            format: uuid
        - name: type
          in: query
          required: false
          description: Which rendition to download. Defaults to `original`.
          schema:
            type: string
            enum: [original, preview, thumbnail, variant]
            default: original
        - name: height
          in: query
          required: false
          description: |
            Required when `type=variant`. The height in pixels of the desired
            variant — one of the file's `media.availableHeights` (from `480`,
            `1080`, `2160`).
          schema:
            type: integer
            minimum: 1
        - name: downloadName
          in: query
          required: false
          description: When set, the URL forces a browser download under this filename.
          schema:
            type: string
            maxLength: 255
      responses:
        "200":
          description: Presigned download URL.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileDownload"
        "202":
          description: |
            `type=variant` only — the MP4 copy of that height is being made.
            Wait `retryAfterSeconds` (also sent as `Retry-After`) and call the
            same URL again; it answers 200 once the copy exists.
          headers:
            Retry-After:
              description: Seconds to wait before calling again.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileVariantGenerating"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: |
            The key does not hold the `read:files` scope
            (`code: insufficient_scope` — a key limited to `read:projects`
            lists files but cannot download them). Or, `type=variant` only —
            the copy does not exist yet and the workspace has on-demand MP4
            copies turned off (`code: variant_downloads_disabled`). A
            workspace admin can turn on
            Settings → Workspace → Media & Workflow → Proxies → On-demand proxy generation.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: Downloadable MP4 copies are turned off for this workspace — an admin can turn on Settings → Workspace → Media & Workflow → Proxies → On-demand proxy generation
                code: variant_downloads_disabled
        "404":
          description: |
            The file does not exist in this workspace (a brand file still
            uploading, trashed or deleted reads the same), the requested
            rendition does not exist (`code: variant_unavailable` for a height
            the video was not transcoded to, or a brand file's height with no
            MP4 copy), or the file's content was removed after the workspace's
            subscription ended (`code: file_content_missing`, with
            `purgedAt`).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              examples:
                missingRendition:
                  value:
                    error: No thumbnail available for this file
                missingVariant:
                  value:
                    error: No 2160p variant available for this file
                    code: variant_unavailable
                purged:
                  value:
                    error: File content was removed after the workspace's subscription ended
                    code: file_content_missing
                    purgedAt: "2026-10-20T09:00:00.000Z"
        "409":
          description: |
            `type=variant` only — the video is still being transcoded
            (`code: transcoding_in_progress`). Call again once it finishes.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/{id}/transcript:
    get:
      tags: [Files]
      operationId: getFileTranscript
      summary: Read a raw file's transcript
      description: |
        **New in 1.124.0.** The transcript of a RAW file (a project file or a
        brand file, by its id from the raw-file listings) as plain text, with
        the same statuses as `GET /api/v1/tasks/{id}/transcript`. Read-only:
        it never starts a transcription (`POST` on this path does). 404
        `file_content_missing` with `purgedAt` when the file was removed after
        the workspace's subscription ended. Requires the `read:files` scope.

        **Timings (since 1.206.0).** The same opt-in `includeSegments`,
        `includeWords`, `fromSeconds` and `toSeconds` as
        `GET /api/v1/tasks/{id}/transcript`: the timed lines and every word
        with its start and end in seconds, narrowed to a stretch of the
        video when you send a window. Without them the response is
        unchanged; a bad value is a `400` naming the parameter.
      parameters:
        - name: id
          in: path
          required: true
          description: The raw file's UUID (a project file or a brand file).
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/TranscriptIncludeSegments"
        - $ref: "#/components/parameters/TranscriptIncludeWords"
        - $ref: "#/components/parameters/TranscriptFromSeconds"
        - $ref: "#/components/parameters/TranscriptToSeconds"
      responses:
        "200":
          description: The transcript, or its status when no text is available.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileTranscript"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Files]
      operationId: startFileTranscription
      summary: Start a raw file's transcription
      description: |
        **New in 1.124.0.** Starts the transcription of a raw video or audio
        file under the same plan, billing, workspace-setting and file checks
        as the app's Transcribe button (it spends the workspace's credits; the
        file of a task version, which this path also accepts, is transcribed
        free since 1.228.4).
        `202` with `started: true` and the new status (`pending`, or
        `extracting` while a smaller copy of a very large file is made); poll
        `GET` on this path every ~20s. A file that already has a transcript —
        or one being made — starts nothing: `200` with its status and
        `started: false`, so a retry is safe. `422 transcripts_unavailable`
        with the app's own sentence when the file cannot be transcribed (plan,
        workspace setting, not a video or audio file, still uploading, too
        large). `402 out_of_credits` (since 1.143.0) when the workspace's
        credits cannot cover the transcription — nothing started.

        **A video still being processed (since 1.172.1).** `extracting` also
        means a video that is still being processed: its credits are
        checked only once processing ends, against its real length — so a
        workspace that cannot cover it gets `202` with `extracting` here, not
        a `402`. The transcript then ends `failed`, carrying the
        out-of-credits sentence as its message: `GET` answers `status:
        failed` (the reason is shown in the app, on the file's transcript),
        and `POST` answers `200` with `started: false` for it, like any
        existing transcript. It is re-run from the app's **Retry** once
        credits are available. Requires the `write:files` scope.
      parameters:
        - name: id
          in: path
          required: true
          description: The raw file's UUID (a project file or a brand file).
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Already transcribed or in progress — nothing started.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileTranscriptionStart"
        "202":
          description: Transcription started.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileTranscriptionStart"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/OutOfCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          description: The file cannot be transcribed.
          content:
            application/json:
              schema:
                type: object
                required: [status, reason, message]
                properties:
                  status:
                    type: string
                    enum: [failed]
                  reason:
                    type: string
                    enum: [transcripts_unavailable]
                  message:
                    type: string
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/attach-raw-file:
    post:
      tags: [Tasks]
      operationId: attachRawFileToPost
      summary: Attach a raw file to a text post
      description: |
        **New in 1.208.0.** Attaches a file that is ALREADY in Raw files &
        assets to a text post (a **document task**) by its file id, with no
        download and no new upload: an image, video or PDF from the task's own
        project, or from the brand header the project sits under. The file id
        is looked up in the task's project first, then in that brand. It
        becomes the post's attachment (the task's next version), the same as
        **Attach file → From Raw files & Assets** in the app, and publishes
        with the post.

        The raw file stays where it is, unchanged. The post gets its own file
        entry that points at the same stored file, so nothing is stored twice;
        like a task created from a raw file, the workspace storage total counts
        it again. Replacing an existing attachment keeps the old one in the
        task's version history. Like an upload, the attach fires the
        `version.uploaded` webhook, the task's version automations, the
        approval notification when the post is waiting for approval, and an
        Activity Log entry.

        Refused, and nothing changes:

        - **400** `not_a_document` — the task is a media task: its versions
          come from `POST /api/v1/files/upload-from-url` or the multipart
          upload with `taskId`;
        - **404** — the task, or the file in the task's project and its brand
          (a file of another project, brand or workspace is not found);
        - **409** `published` — the post is already published;
        - **409** `task_file` — the id is a task's own file (a deliverable, a
          version or a project-file backup), not a raw file;
        - **409** `not_attachable` — the file is not an image, video or PDF,
          or is still uploading, still having its preview made, in the trash
          or removed;
        - **403** `UPLOADS_PAUSED` — the workspace's media is scheduled for
          removal, so it takes no new files.

        Requires the `write:tasks` scope.
      parameters:
        - name: id
          in: path
          required: true
          description: The document task (text post) id.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AttachRawFileRequest"
            examples:
              brandPhoto:
                summary: A photo from the brand's Raw files & assets
                value:
                  fileId: 6a1f3c9e-2b7d-4e8a-9c5b-0d4e7f2a1b38
      responses:
        "201":
          description: The raw file is now the post's attachment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AttachedRawFile"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: The task, or the file in the task's project and its brand, does not exist in this workspace.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: File not found
                code: not_found
        "409":
          description: The post is published (`published`), the id is a task's own file (`task_file`), or the file cannot go with a post (`not_attachable`).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: "That file cannot be attached to a post: only a finished image, video or PDF (not one still uploading, having its preview made, in the trash or removed)"
                code: not_attachable
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/{id}/move:
    post:
      tags: [Files]
      operationId: moveFile
      summary: Move a raw file to another project, brand or folder
      description: |
        **New in 1.122.0.** Moves an existing **raw file** (Raw files & assets)
        — keeping the SAME file: its `id`, its comments, its transcript and its
        share link come along, and (1.210.1) so do its footage tags, its tagged
        moments, its AI tagging and its Liked mark. Nothing is downloaded,
        uploaded or copied, and storage is not counted twice.

        Where it goes:

        - `projectId` — into that project's Raw files & assets;
        - `brandId` — into that brand header's Raw files & assets;
        - `folderId` alone — into a folder of the project or brand the file is
          already in (`null` = its top level).

        Add `folderId` to `projectId` / `brandId` to land it in a folder of the
        destination (omitted or `null` = the top level). File ids come from
        `GET /api/v1/projects/{id}/header` and `GET /api/v1/brands/{id}/header`
        (`files[].id`); send all 36 characters exactly as returned. A name
        already used at the destination gets a `" (1)"` suffix and
        `renamed: true`. Who can see the file follows the
        destination — a brand's guests see its brand files, and a guest-hidden
        folder hides it from guests. The move is silent: no notification and
        no webhook.

        **The destination's Raw files & Assets card (1.125.0).** In the app a
        moved file opens only from its destination header's **Raw files &
        Assets** card, and a brand header starts without one. So before it
        moves the file, the call makes sure that card is there: a header with
        none gets one (the workspace's own default for that card when it has
        one, else the standard **Raw files & Assets** card in the Production
        section — `rawFilesCard.added: true`), and a card hidden from everyone
        is shown again (`rawFilesCard.restored: true`; per-role restrictions
        set in Card permissions stay). A header never opened in the app is
        first given its default cards, as the app's first open would.
        `rawFilesCard.id` is the card in every 200.

        Refused with **409** and nothing moved:

        - `task_file` — the file is part of a task (a deliverable or version,
          a task's project-file backup); download it and upload it again;
        - `file_in_use` — a post cover, a published post's file, or a file in a
          link column or a task hand-off moves only between projects or between
          brands, never between a project and a brand; so does a file AI
          footage tagging is working on right now, until the tagging finishes
          (1.210.1);
        - `not_movable` — the file is in the trash or still processing;
        - `file_content_missing` — its content was removed after the
          workspace's subscription ended.

        **A file id that names no file (1.189.3).** An id that is not a file of
        this workspace answers **404** with `code: not_found` and nothing moved:
        `File not found` for an unknown id and for another workspace's file
        alike. When the id looks shortened and filled back out — exactly one
        file of this workspace starts with its first 8 characters — `error`
        starts `File not found.` and names that file's full id (several such
        files: it says so and names none). A missing destination project, brand
        or folder answers its own 404 with no `code`.
      parameters:
        - name: id
          in: path
          required: true
          description: The raw file's UUID (a project file or a brand file), all 36 characters.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MoveFileRequest"
            examples:
              toProjectFolder:
                summary: Into a folder of another project
                value:
                  projectId: 2b7e9c1a-4f3d-4a8e-9b6c-1d2e3f4a5b6c
                  folderId: 7c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f
              toBrand:
                summary: Into a brand header's Raw files & assets
                value:
                  brandId: 9f8e7d6c-5b4a-4392-8170-6f5e4d3c2b1a
      responses:
        "200":
          description: The file was moved (or was already there).
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/MovedFile"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: The file (`code` is `not_found`, and `error` may name the file a shortened id most likely meant), the destination project or brand, or the folder does not exist in this workspace (or is in the trash).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: File not found
                code: not_found
        "409":
          description: The file cannot be moved — `code` is `task_file`, `file_in_use`, `not_movable` or `file_content_missing`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: This file belongs to a task (a deliverable, a version or a task's project-file backup), and task files cannot be moved — download it and upload it again where you need it
                code: task_file
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/{id}/selects:
    get:
      tags: [Files]
      operationId: listFileSelects
      summary: List a raw file's selects
      description: |
        **New in 1.218.0.** The footage selects logged on a RAW project video
        or audio file — the time ranges the app's Selects panel shows — in
        timecode order, each with its task and an app link that opens the
        moment. `409 selects_unavailable` for a brand file, a task's file or
        a file that is not video or audio. Requires the `read:files` scope.
      parameters:
        - name: id
          in: path
          required: true
          description: The raw project file's UUID (from `GET /api/v1/projects/{id}/files`).
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The file's selects.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FootageSelectList"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Files]
      operationId: createFileSelect
      summary: Create a select on a raw file
      description: |
        **New in 1.218.0.** Logs a footage select on a RAW project video or
        audio file: `startSeconds` and `title` (required — read the times off
        `GET /api/v1/files/{id}/transcript?includeSegments=true`, its
        `segments[].start` / `end`), `endSeconds`
        (omit or `null` for a point select), `notes`, `script` (omit to fill
        it with the words the transcript has in the range, as the app does)
        and `taskId` — a live task of the same project, never a parent task,
        whose Plan → Media then lists the select. It shows in the app's
        Selects panel like one made there. Silent: nobody is notified. Not
        idempotent — every call makes a new select. `409 selects_unavailable`
        for a file that cannot carry selects, `409 too_many_selects` past
        1000 on one file. Requires the `write:files` scope.
      parameters:
        - name: id
          in: path
          required: true
          description: The raw project file's UUID.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FootageSelectCreate"
            example:
              startSeconds: 12
              endSeconds: 31.5
              title: Opening hook
              notes: Use the B-cam for the reaction.
      responses:
        "201":
          description: The new select.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FootageSelect"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/{id}/selects/{selectId}:
    patch:
      tags: [Files]
      operationId: updateFileSelect
      summary: Edit a select
      description: |
        **New in 1.218.0.** Edits a select's range, title, notes, script or
        task (`taskId: null` takes it off its task). Only the fields sent
        change; the camera angles linked in the app are kept. Silent.
        Requires the `write:files` scope.
      parameters:
        - name: id
          in: path
          required: true
          description: The raw project file's UUID.
          schema:
            type: string
            format: uuid
        - name: selectId
          in: path
          required: true
          description: The select's UUID.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FootageSelectUpdate"
      responses:
        "200":
          description: The edited select.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FootageSelect"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Files]
      operationId: deleteFileSelect
      summary: Delete a select
      description: |
        **New in 1.218.0.** Deletes a select for good; the file and the task
        it was sent to are untouched. Silent. Runs the shared delete budget
        (429 with `Retry-After` over it). Requires the `write:files` scope.
      parameters:
        - name: id
          in: path
          required: true
          description: The raw project file's UUID.
          schema:
            type: string
            format: uuid
        - name: selectId
          in: path
          required: true
          description: The select's UUID.
          schema:
            type: string
            format: uuid
      responses:
        "204":
          description: Deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/{id}/frames:
    get:
      tags: [Files]
      operationId: getFileFrames
      summary: See a video file's frames
      description: |
        **New in 1.184.0.** Still frames of a video file (a project file or a
        brand file, by its id from the raw-file listings), as base64 JPEGs an
        AI agent can look at — for footage a transcript cannot describe, such
        as silent B-roll. The video's frames are saved when its preview is
        made (12, evenly spread over its length); this answers `count` of
        them (1–12, default 6), evenly spread, each with the second it was
        taken at.

        `framesStatus`:

        - `ready` — `frames` holds the frames;
        - `processing` — the video is still being processed; `frames` is
          empty, call again in a few minutes;
        - `unavailable` — no saved frames (a video processed before frames
          existed): `frames` holds the file's one thumbnail, `seconds: null`,
          when it has one.

        Read-only — nothing is generated by the call. `409 not_video` for a
        file that is not a video. 404 `file_content_missing` with `purgedAt`
        when the file was removed after the workspace's subscription ended.
        Requires the `read:files` scope.
      parameters:
        - name: id
          in: path
          required: true
          description: The video file's UUID (a project file or a brand file).
          schema:
            type: string
            format: uuid
        - name: count
          in: query
          required: false
          description: How many frames, 1–12 (default 6).
          schema:
            type: integer
            minimum: 1
            maximum: 12
            default: 6
      responses:
        "200":
          description: The frames, or the status when there are none.
          content:
            application/json:
              schema:
                type: object
                required: [fileId, name, durationSeconds, framesStatus, frames]
                properties:
                  fileId:
                    type: string
                    format: uuid
                  name:
                    type: string
                  durationSeconds:
                    type: number
                    nullable: true
                  framesStatus:
                    type: string
                    enum: [ready, processing, unavailable]
                  frames:
                    type: array
                    items:
                      type: object
                      required: [seconds, mimeType, data]
                      properties:
                        seconds:
                          type: number
                          nullable: true
                          description: Seconds into the video; null for the fallback thumbnail.
                        mimeType:
                          type: string
                          enum: [image/jpeg]
                        data:
                          type: string
                          format: byte
                          description: The JPEG, base64-encoded.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: The file is not a video — `code` is `not_video`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/folders:
    post:
      tags: [Files]
      operationId: createRawFolder
      summary: Create a folder in a project's or brand's raw files
      description: |
        **New in 1.184.0.** Creates a folder in a project's Raw files & assets
        (`projectId`) or a brand header's (`brandId`) — exactly one of the two
        — at the top level, or inside another folder of the same project or
        brand (`parentId`). Put files in it with `POST
        /api/v1/files/{id}/move` (`folderId`). The same folder the app's
        Create Folder makes: everyone who can see that project's or brand's
        raw files sees it.

        A folder with the same name (any letter case) already at that level
        is answered as it is — `200` with `created: false` — and no second
        one is made, so a retry is safe; a new folder is `201` with `created:
        true`. A brand header starts without a Raw files & Assets card, so the
        card is added first (`rawFilesCard.added: true`), or shown again when
        it was hidden from everyone (`rawFilesCard.restored: true`). Silent:
        no notification and no webhook. `400` when `parentId` is not an active
        folder of that project or brand, or the key has no associated user.
        Requires the `write:files` scope.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name]
              additionalProperties: false
              properties:
                projectId:
                  type: string
                  format: uuid
                  description: The project to make it in. Never together with `brandId`.
                brandId:
                  type: string
                  format: uuid
                  description: The brand (client) to make it in. Never together with `projectId`.
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: The folder's name (surrounding spaces are trimmed).
                parentId:
                  type: string
                  format: uuid
                  nullable: true
                  description: A folder of the same project or brand to make it inside; omitted or `null` = the top level.
            examples:
              projectTopLevel:
                summary: A B-roll folder at a project's top level
                value:
                  projectId: 2b7e9c1a-4f3d-4a8e-9b6c-1d2e3f4a5b6c
                  name: B-roll
      responses:
        "200":
          description: A folder with that name was already there — answered as it is.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RawFolderResult"
        "201":
          description: The folder was created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RawFolderResult"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: The project or brand does not exist in this workspace (or is in the trash).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands:
    get:
      tags: [Brands]
      operationId: listBrands
      summary: List brands and clients
      description: |
        Returns the workspace's brands and clients — Nodes of type `brand` or
        `client` — newest first. Cursor-paginated. Each row carries
        `parentId` (the sidebar folder it sits in) and `archived` (1.206.0).

        `type=folder` lists the sidebar folders instead — the Nodes that
        group brands (and other folders) in the Timeliner sidebar, archived
        ones included. They use the same row shape with the brand-only
        fields empty (`null` / `[]`); `GET /api/v1/brands/{id}` still answers
        404 for a folder id. A sidebar folder is not a project's raw-file
        folder. Omitting `type` never returns folders.
      parameters:
        - $ref: "#/components/parameters/Limit"
        - name: before
          in: query
          required: false
          description: |
            Opaque pagination cursor — pass a previous response's `nextBefore`
            value. Treat it as opaque; do not construct or parse it.
          schema:
            type: string
        - name: type
          in: query
          required: false
          description: |
            Restrict to a single node type. Omit to return both `brand` and
            `client`; `folder` returns the sidebar folders instead (1.206.0).
          schema:
            type: string
            enum: [brand, client, folder]
      responses:
        "200":
          description: Page of brands.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: createBrand
      summary: Create a brand
      description: |
        Creates a top-level brand or client in the workspace (always top-level —
        the API does not nest brands under a parent). `type` defaults to
        `brand`. Returns the full brand, so the response matches
        `GET /api/v1/brands/{id}` (with an empty `socialAccounts` array and the
        workspace's effective `intakeForm`, if any).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateBrandInput"
            examples:
              minimal:
                summary: Just the required name
                value:
                  name: Aurora Films
              full:
                summary: With type, social links, and the Metricool blog ID
                value:
                  name: Aurora Films
                  type: client
                  language: en
                  socialLinks:
                    - platform: tiktok
                      url: https://tiktok.com/@aurorafilms
                  externalMetadata:
                    metricool:
                      blogId: "12345"
              namedLinksAndMetadata:
                summary: Generic named links (not just social) + custom metadata
                value:
                  name: Aurora Films
                  socialLinks:
                    - platform: Website
                      url: https://aurorafilms.com
                    - platform: Drive
                      url: https://drive.google.com/drive/folders/abc123
                    - platform: instagram
                      url: https://instagram.com/aurorafilms
                  externalMetadata:
                    crm:
                      accountId: A-123
                    notes: VIP client — renewal in Q4
      responses:
        "201":
          description: Brand created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Brand"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}:
    get:
      tags: [Brands]
      operationId: getBrand
      summary: Retrieve a brand
      description: |
        Returns the brand's full detail: identity fields, `socialLinks`,
        `metricoolBlogId` / `externalMetadata`, connected `socialAccounts`
        (platform credentials excluded), and the effective `intakeForm`
        (the brand brief — its question template and catalog items).

        **Membership is not part of this response.** To see or change who has
        access to the brand, use
        [`GET /api/v1/brands/{id}/members`](#tag/Brands/operation/listBrandMembers),
        [`POST`](#tag/Brands/operation/addBrandMember) to grant it and
        [`DELETE`](#tag/Brands/operation/removeBrandMember) to revoke it.

        Brands cannot be deleted through the API — `DELETE` on this path
        answers `405`. Delete a brand in the Timeliner app, or delete its
        projects individually with `DELETE /api/v1/projects/{id}`.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Brand"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Brands]
      operationId: updateBrand
      summary: Update a brand's brief/guidelines, links, and integration metadata
      description: |
        Updates a brand's writable fields — provide at least one.
        `description` is the brand's brief / guidelines text (a brand header doc
        card that still shows it — usually Guidelines — follows it until that card
        is written on its own with `PATCH /api/v1/header-cards/{cardId}`); it is a
        full text replace —
        pass `""` to clear it, omit or `null` to leave it unchanged. Writing
        `description` fires no notifications. `externalMetadata` (where the
        Metricool blog ID and any custom variables live) is a full-object replace,
        so merge client-side before sending.

        `socialLinks` is the brand's **Brand Links** card (any label, not just
        social). It is a **full-array replace** — the list you send becomes the
        brand's links, so read the brand first and send the merged array; `null`
        or `[]` clears them all. The links are written INTO that card (1.98.1),
        so they show in the app on the brand's next load, and links a user adds
        in the card come back on every read. A brand never opened in the app
        gets its header set up first; if its Brand Links card was deleted, a new
        one is added to the header.

        `adminApprovalMode` is this brand's override for the Admin Approval stage.
        On the **Agency + 2 approvers** workflow `"on"` forces the stage, `"off"`
        removes it, `null` inherits the workspace's `adminApprovalScope` (readable
        from `GET /api/v1/workspace/settings`). On the **Agency**,
        **Agency + End Client** and **Internal** workflows (1.98.0) `"on"` ADDS
        the stage for this brand alone, right after Supervisor Approval; `null`
        and `"off"` both leave it out, since those workflows have no workspace
        scope. On the **Basic** or **Team + Manager + Admin** workflows it is
        refused (`400`). Since 1.199.0, when a change makes the brand **lose**
        the stage, its tasks sitting in Admin Approval are first moved back to
        Supervisor Approval — exactly what the in-app Edit Brand → Workflow
        flow does. No notifications either way.

        `name` renames the brand (1–200 characters). `type` converts it:
        `client` (client approval stage, guests) or `brand` (internal). Turning
        a client brand internal is refused with `409` while it still has
        client-stage tasks, guests or end clients (1.199.0).

        Every other Edit Brand setting: `PATCH /api/v1/brands/{id}/settings`;
        the logo: `PUT /api/v1/brands/{id}/logo`.

        Returns the full updated brand.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateBrandInput"
            examples:
              setBrief:
                summary: Rewrite the brand brief / guidelines
                value:
                  description: |
                    Tone: short, plain, direct. Always name the offer. No filler.
              replaceBrandLinks:
                summary: Replace the brand's links (send the WHOLE list — this wipes any link you omit)
                value:
                  socialLinks:
                    - platform: Website
                      url: "https://aurorafilms.com"
                    - platform: Drive
                      url: "https://drive.google.com/drive/folders/abc123"
                    - platform: instagram
                      url: "https://instagram.com/aurorafilms"
              clearBrandLinks:
                summary: Remove every link from the brand
                value:
                  socialLinks: []
              setMetricoolBlogId:
                summary: Store the Metricool blog ID
                value:
                  externalMetadata:
                    metricool:
                      blogId: "12345"
              forceAdminApproval:
                summary: Require Admin Approval on this brand regardless of the workspace scope
                value:
                  adminApprovalMode: "on"
              inheritAdminApproval:
                summary: Fall back to the workspace's adminApprovalScope
                value:
                  adminApprovalMode: null
      responses:
        "200":
          description: The updated brand.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Brand"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/members:
    get:
      tags: [Brands]
      operationId: listBrandMembers
      summary: List a brand's members
      description: |
        Who currently has access to this brand, with each member's brand-level
        `role`. Team members only by default — pass `includeGuests=true` for
        external reviewers and `includeDeactivated=true` for removed members.

        Each entry carries `automatic`, which is `true` when the access comes
        from the member being a **workspace admin** rather than from an explicit
        assignment: admins are granted every brand automatically when the brand
        is created. That is why `POST` answers `409` for an admin nobody ever
        added, and why `DELETE` refuses to remove one.

        Use this instead of inferring membership from `POST`'s `409` — that
        tells you only about the single member you just attempted.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - name: includeGuests
          in: query
          required: false
          schema:
            type: string
            enum: ["true", "false"]
          description: Include guests (external reviewers). Defaults to `false`.
        - name: includeDeactivated
          in: query
          required: false
          schema:
            type: string
            enum: ["true", "false"]
          description: Include deactivated / removed members. Defaults to `false`.
      responses:
        "200":
          description: The brand's members.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandMembershipListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: addBrandMember
      summary: Add a team member to a brand
      description: |
        Grants an existing workspace **team** member access to a brand by
        creating a brand-level role assignment. The grant cascades to the
        brand's projects. `memberId` is a member id from `GET /api/v1/members`;
        `role` is the brand-level team role and defaults to `editor`.

        Guests are not added through this endpoint — external reviewers reach a
        brand through the invite / share-link flow. Returns `409` if the member
        already has access to the brand.

        **A workspace admin always returns `409`, even on a brand you have
        never assigned them to.** Admins are granted access to every brand
        automatically the moment the brand is created, so there is nothing to
        add — this is correct behaviour, not a failed assignment. `GET` on this
        path shows those grants with `automatic: true`.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AddBrandMemberInput"
            examples:
              addEditor:
                summary: Add an existing editor to the brand
                value:
                  memberId: "66666666-6666-6666-6666-666666666666"
              addSupervisor:
                summary: Grant a supervisor role on the brand
                value:
                  memberId: "66666666-6666-6666-6666-666666666666"
                  role: supervisor
      responses:
        "201":
          description: The member was granted access to the brand.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandMembershipResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/members/{memberId}:
    delete:
      tags: [Brands]
      operationId: removeBrandMember
      summary: Remove a team member from a brand
      description: |
        Revokes a team member's access to a brand — the undo for `POST` on the
        collection, so a wrong assignment can be corrected without opening the
        Timeliner app.

        Scoped to the brand: an explicit grant on one of the brand's projects is
        left in place and must be removed on that project.

        Two members are refused, each for a reason worth knowing before you
        build a retry around it:

        - **Workspace admins** (`409`). Admins hold every brand automatically
          and cannot be removed from one; change their workspace role first.
        - **Guests** (`400`). Revoking guest access also has to rotate their
          share link, so it stays an in-app action.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandMemberId"
      responses:
        "204":
          description: Access revoked.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          description: |
            The brand is not in this workspace, or that member does not have
            access to the brand.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/voice:
    get:
      tags: [Brands]
      operationId: getBrandVoice
      summary: Read a brand's Brand Brain and voice & style profile
      description: |
        The brand's Brand Brain and writing-style profile: what the brand does
        (`about`), who its content is for (`audience`), how it sounds
        (`tone`), the points it keeps repeating (`keyMessages`), the words and
        phrases it must never use (`neverSay`), freeform voice instructions
        (how this brand titles, tags, and captions its content) and optional
        per-platform notes (e.g. YouTube title conventions vs Instagram
        caption register).

        Nothing on the `neverSay` list may appear in a script, caption, title
        or on-screen text written for the brand.

        The profile is injected into every caption generation for the brand —
        the in-app composer, Janet, and `POST /posts/{taskId}/caption/generate`
        — as an explicit style block that outranks the mined prior-caption
        examples. External assistants should read it before composing any
        caption, title, or description for the brand. Returns empty defaults
        (`updatedAt: null`) when no profile is saved yet.
      parameters:
        - name: id
          in: path
          required: true
          description: The brand's UUID.
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The brand's voice profile (empty defaults when unset).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandVoice"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Brands]
      operationId: updateBrandVoice
      summary: Save a brand's voice & style profile
      description: |
        Saves or refines the brand's writing-style profile — the durable
        style memory every caption/title generation for the brand obeys.

        `instructions` REPLACES the whole freeform text (read first and merge;
        `""` clears; ≤4000 chars). `platformNotes` merges key-by-key: a string
        sets that platform's note (≤1000 chars), `null` (or `""`) deletes it,
        omitted platforms are untouched. The Brand Brain answers `about`,
        `audience`, `tone` and `keyMessages` (≤1000 chars each) and the
        `neverSay` list (≤50 entries of ≤80 chars, trimmed and de-duplicated
        ignoring case) each REPLACE that answer. Provide at least one field.
        Silent — no notifications.
      parameters:
        - name: id
          in: path
          required: true
          description: The brand's UUID.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BrandVoiceInput"
      responses:
        "200":
          description: The voice profile after the merge.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandVoice"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/files:
    get:
      tags: [Projects]
      operationId: listProjectRawFiles
      summary: List a project's raw files, folder by folder
      description: |
        **New in 1.124.0.** A project's raw files (Raw files & Assets) one
        folder level at a time, newest first, with each file's size, type,
        folder, duration and transcript status, and the level's subfolders.
        Task files (deliverables, versions, project-file backups) and header
        attach-card files are never listed — the ids returned are exactly the
        `projectFile` / `projectFolder` items a task's link column accepts
        (`PATCH /api/v1/tasks/{id}/custom-columns`). Unlike the header's
        `files` (at most 50, no folders), this lists every file. Requires the
        `read:projects` scope.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
        - name: folderId
          in: query
          required: false
          description: A folder to open (`folders[].id` of a previous page). Omitted = the top level.
          schema:
            type: string
            format: uuid
        - name: limit
          in: query
          required: false
          description: Files per page (1–200). Defaults to 50.
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - name: before
          in: query
          required: false
          description: The previous page's `nextBefore` (opaque).
          schema:
            type: string
      responses:
        "200":
          description: One page of this level's raw files, plus its subfolders on the first page.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RawFileListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          description: No project with that id in your workspace, or `folderId` is not one of its folders.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/projects/{id}/header:
    get:
      tags: [Projects]
      operationId: getProjectHeader
      summary: Read a project's header content
      description: |
        Returns the project's header in one flattened, agent-friendly payload:
        the `brief`, every `docs` entry (guidelines / moodboard / …), `links`,
        `attachments` (docs attached to fileAttach cards), `files` (the raw Assets
        list, bounded — each with a `downloadUrl` valid for 7 days since 1.134.0,
        `null` unless the key also holds `read:files`), and `cards` (the header
        canvas, section by section — each card names its `section`, and
        `sections` lists the section names). All text is plain (HTML
        stripped, capped).

        **`brief` (1.154.0).** The project's Brief card's text and nothing
        else — `null` when the Brief is empty, even when other pages have
        text (they are in `docs`). Before 1.154.0 an empty Brief fell back to
        the first page with text, so a page added through
        `POST /api/v1/header-cards` read back as the brief.
      parameters:
        - $ref: "#/components/parameters/ProjectId"
      responses:
        "200":
          description: The project's header content.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderContentResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/files:
    get:
      tags: [Brands]
      operationId: listBrandRawFiles
      summary: List a brand's raw files, folder by folder
      description: |
        **New in 1.124.0.** A brand header's raw files (the brand's Raw files &
        Assets) one folder level at a time, same shape as
        `GET /api/v1/projects/{id}/files`. The ids returned are the
        `brandFile` / `brandFolder` items a task's link column accepts for
        tasks of projects directly under this brand. Requires the
        `read:projects` scope. Download any file listed here with
        `GET /api/v1/files/{id}/download` (since 1.134.0) — with a key that
        also holds `read:files`.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - name: folderId
          in: query
          required: false
          description: A folder to open (`folders[].id` of a previous page). Omitted = the top level.
          schema:
            type: string
            format: uuid
        - name: limit
          in: query
          required: false
          description: Files per page (1–200). Defaults to 50.
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - name: before
          in: query
          required: false
          description: The previous page's `nextBefore` (opaque).
          schema:
            type: string
      responses:
        "200":
          description: One page of this level's raw files, plus its subfolders on the first page.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RawFileListResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          description: No brand with that id in your workspace, or `folderId` is not one of its folders.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/header:
    get:
      tags: [Brands]
      operationId: getBrandHeader
      summary: Read a brand's header content
      description: |
        Returns the brand's header in one flattened payload: `brief` /
        guidelines, every `docs` entry, `links`, `attachments`, `files` (the raw
        brand files, bounded), `sections` (the section names, 1.154.0) and
        `cards` (the header canvas, section by section — each card names its
        `section`). All text is plain (HTML stripped, capped).

        **`brief` (1.154.0).** A brand has no Brief card — its `brief` is the
        Guidelines card's text (then a "Brief" page added to the brand), and
        `null` when that card is empty, never another page's text (before
        1.154.0 an empty Guidelines fell back to the first page with text,
        e.g. a Contacts card).

        **Downloads (1.134.0).** Each `files[]` entry carries a `downloadUrl`
        (the original file, valid for 7 days) when the key also holds the
        `read:files` scope — the scope `GET /api/v1/files/{id}/download`
        needs; a key without it gets `downloadUrl: null` on every file. For a
        fresh link or another rendition, pass its `id` to
        `GET /api/v1/files/{id}/download`.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's header content.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderContentResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/package:
    get:
      tags: [Brands]
      operationId: getBrandPackage
      summary: Read a brand's package (colors, brand files, fonts, edit direction)
      description: |
        **New in 1.139.0.** What the brand's videos must look and sound like:

        - `editDirection` — `replicate` (match the style of the brand's
          approved videos), `improve` (keep the look, raise the bar), or
          `null` (not chosen yet).
        - `ctaText` / `ctaUrl` — the brand's call to action;
          `endCardNotes`, `musicNotes` (background music) and — new in
          1.222.0 — `sfxNotes` (sound effects) — free text.
        - `colors` — brand colors in order of importance, upper-case
          `#RRGGBB`, each with an optional `name` and `role`.
        - `assets` — the brand kit's files (the brand header's raw files
          someone added to the kit) marked as `logo`, `productImage`,
          `broll`, `music` (background music), `sfx` (sound effects — new in
          1.201.0), `endCard`, `overlay`, `look` (a LUT or color
          preset), `reference`, `doc`, `other`, or — since 1.163.5 —
          `productRecording` (a screen recording of the brand's product),
          `screenshot` or `photo`, with a free `variant` label and where the
          mark came from (`source`). Treat a category you do not know as
          `other`. A file that is no longer usable — trashed, still
          uploading, removed by the media purge, or moved to another brand —
          is left out. A font file is never an asset (fonts are listed under
          `fonts`, where their license decides), and neither is a file named
          after the Birzia font; both are re-checked on every read, so a
          file renamed after the package was saved is left out too.
        - `fonts` — brand fonts with `licenseStatus` (`ofl`, `commercialOk`,
          `userAttested`, `unknown`, `restricted`) and `usable`. **Never use
          a font whose `usable` is `false`** (license unknown or restricted):
          use its `fallbackFamily`, or an open-license font. The Birzia
          font is always `restricted` — by its family name or by the current
          name of its font file — and a font that may not be used never
          carries its `file`.

        Each file carries a `downloadUrl` (the original, valid for 7 days)
        when the key also holds the `read:files` scope — the scope
        `GET /api/v1/files/{id}/download` needs; a key without it gets
        `downloadUrl: null` on every file. Change it with `PATCH` (1.199.0)
        and the per-file `PUT` / `DELETE …/package/items/{fileId}`.

        Many brands have no package yet — every list empty and
        `updatedAt: null`. That is normal: treat it as "no brand rules
        recorded" and use the brand header (`GET /api/v1/brands/{id}/header`)
        for the brief and guidelines.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's package (empty defaults when nothing is saved).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandPackageResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Brands]
      operationId: updateBrandPackage
      summary: Change a brand's package (Brand assets)
      description: |
        **New in 1.199.0.** Edit Brand → Brand assets. Send only what changes:
        `ctaText`, `ctaUrl`, `endCardNotes`, `musicNotes`, `sfxNotes` (1.222.0),
        `colors`, `assets`, `fonts`, and `editDirection`. A list you send **replaces that whole
        list** — read `GET` first and send it back changed; a list you leave
        out is kept as stored.

        The save runs **as the API key's creator** with the app's own rules,
        so the API can never store a kit the app would refuse: they must be a
        supervisor or admin on the brand (`403` otherwise), each asset's
        `fileId` must be a usable file of this brand (others are dropped), at
        most 24 colors / 100 assets / 12 fonts.
        `editDirection` is an Editor beta setting (`403`
        `editor_beta_required` elsewhere).
        Nothing is sent to anyone.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BrandPackagePatch"
            example:
              ctaText: Book a free consult
              ctaUrl: https://harborlights.example/consult
              colors:
                - { hex: "#0B3D91", name: Harbor navy, role: primary }
                - { hex: "#F2B705", name: Beacon gold, role: accent }
      responses:
        "200":
          description: The brand's package as stored.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandPackageResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/package/items/{fileId}:
    put:
      tags: [Brands]
      operationId: addBrandKitItem
      summary: Put a brand file in the brand's kit
      description: |
        **New in 1.199.0.** The Brand assets tab's toggle: put one of the
        brand's files (`GET /api/v1/brands/{id}/files`) in the kit under a
        category. A font file always goes in as a font. Runs as the API key's
        creator with the app's rule (editor and up on the brand).
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandKitFileId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [category]
              properties:
                category:
                  type: string
                  enum: [font, logo, productImage, broll, music, sfx, endCard, overlay, look, reference, doc, other, productRecording, screenshot, photo]
      responses:
        "200":
          description: The file is in the kit.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandKitItemResult"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Brands]
      operationId: removeBrandKitItem
      summary: Take a file out of the brand's kit
      description: |
        **New in 1.199.0.** Takes the file out of the kit; the file stays in
        the brand's files. Only a supervisor removes a licensed font. Counts
        against the destructive budget.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandKitFileId"
      responses:
        "204":
          description: Taken out (or was not in the kit).
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/posting-plan:
    parameters:
      - name: id
        in: path
        required: true
        description: The brand's id.
        schema:
          type: string
          format: uuid
    get:
      tags: [Brands]
      operationId: getBrandPostingPlan
      summary: Read a brand's posting plan
      description: |
        A brand's posting plan — **Edit Brand → Posting plan** in the app
        (1.227.0): the weekly times its approved posts are scheduled into, the
        plan's time zone (`null` = the workspace's), whether the brand's best
        posting hour is used, the minimum lead time, and the team member
        alerted when a post can't be placed. A brand with no plan yet returns
        an empty `times` list and the defaults. Needs a posting plan
        (social posting) — `403` otherwise. A brand in another workspace, a
        folder or a trashed brand is `404`.
      responses:
        "200":
          description: The brand's posting plan.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostingPlanResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Brands]
      operationId: updateBrandPostingPlan
      summary: Edit a brand's posting plan
      description: |
        Changes a brand's posting plan — the same as saving **Edit Brand →
        Posting plan** in the app (1.227.0). Send only the fields that change;
        the rest keep their stored values. `times` is a FULL REPLACE of the
        weekly list: send the times to keep plus the new ones. Refused with
        `400` (and a `code`) for more than 28 times, a time or day that can't
        be read, the same day + time + network twice, an unknown time zone, a
        lead time outside 15–1440 minutes, or an `alertMemberId` who is not an
        active team member. Saving schedules nothing and notifies no one —
        posts are placed into the plan when they are scheduled.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePostingPlanInput"
            examples:
              default:
                value:
                  times:
                    - { days: [1, 3, 5], time: "09:30", platforms: [instagram] }
                    - { days: [2], time: "10:00", platforms: [] }
      responses:
        "200":
          description: The saved plan.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostingPlanResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/settings:
    get:
      tags: [Brands]
      operationId: getBrandSettings
      summary: Read a brand's Portal Design, Guest Access and Workflow settings
      description: |
        **New in 1.199.0.** The Edit Brand dialog's Portal Design, Guest
        Access and Workflow tabs as one object grouped `{ portal, guestAccess,
        workflow }`. `null` on an override means the brand inherits the
        workspace value (`GET /api/v1/workspace/settings`). The share
        passcode is reported as its state only — never the passcode.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's settings.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandSettings"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Brands]
      operationId: updateBrandSettings
      summary: Change a brand's Portal Design, Guest Access or Workflow settings
      description: |
        **New in 1.199.0.** Send only what changes, grouped like the `GET`
        answer. Every value is validated and plan-gated by the same code the
        in-app Edit Brand save runs: a plan-gated value answers `403` with
        the plan it needs (narrowing or clearing to `null` is always
        accepted), a bad value `400`. Unknown groups or keys are `400`.

        Side effects, exactly as in the app:
        - Turning `workflow.adminApprovalMode` so the brand **loses** the
          Admin Approval stage first moves its tasks sitting in Admin
          Approval back to Supervisor Approval (no notifications).
        - Switching an approval window on (`workflow.approvalWindowMinutes`
          above 0) starts it from now: a task in client approval is
          auto-approved when its window ends, counted from when it entered
          approval or now, whichever is later — never instantly.

        Nothing else moves and no one is notified. The share passcode has
        its own endpoint (`PUT /api/v1/brands/{id}/share-password`).
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BrandSettingsPatch"
            example:
              portal: { theme: dark, welcomeMessage: Welcome to your Harbor Lights review space }
              workflow: { revisionLimit: 3, requirePostReview: true }
      responses:
        "200":
          description: The brand's settings after the change.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandSettings"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
        "503":
          description: |
            **Documented in 1.202.0.** `workflow.automationMode` was sent but
            the workspace's plan could not be read, so the Automations plan
            gate was not decided and nothing was saved. Retry shortly.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: Could not verify the workspace plan. Try again.

  /api/v1/brands/{id}/logo:
    put:
      tags: [Brands]
      operationId: setBrandLogo
      summary: Replace a brand's logo from an image URL
      description: |
        **New in 1.199.0.** Edit Brand → General → logo. The server downloads
        the image (public hosts only — a private or internal address is
        refused; redirects are re-checked; ≤ 5 MB; PNG, JPEG, WebP, GIF or
        SVG), stores the same two sizes the app does, and answers the brand:
        `logoUrl` is the new stable public URL.

        A workspace whose uploads are paused answers
        **403** `code: UPLOADS_PAUSED` (see *Uploads paused*, since 1.201.0).
        Nothing is pulled.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [url]
              properties:
                url:
                  type: string
                  maxLength: 2000
                  description: Public http(s) URL of the image.
            example:
              url: https://harborlights.example/brand/logo.png
      responses:
        "200":
          description: The brand with its new logo.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Brand"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/share-password:
    put:
      tags: [Brands]
      operationId: setBrandSharePassword
      summary: Set, rotate or turn off a brand's share passcode
      description: |
        **New in 1.199.0.** Edit Brand → Workflow → share passcode. Every
        share link under the brand inherits it unless a project or link sets
        its own.

        - `{ "password": "…" }` sets or rotates it (Scale plan). Everyone who
          already unlocked a link must enter the new one.
        - `{ "mode": "off" }` pins the brand explicitly open (never
          plan-gated).
        - `{ "mode": "inherit" }` drops the brand's own passcode (same as
          `DELETE`).
        - `{ "password": "…", "mode": "custom" }` is the same as sending
          `password` alone (1.210.1 — documented; `custom` is the state a
          passcode puts the brand in). `mode: "custom"` without a `password`
          is a `400`, and `password` beside `"off"` or `"inherit"` is a `400`.

        The passcode is **write-only**: no endpoint returns it. Every change
        leaves a security-audit event.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                password:
                  type: string
                  description: The new passcode.
                mode:
                  type: string
                  enum: ["off", inherit, custom]
                  description: |
                    `"off"` pins the brand open, `"inherit"` drops its own
                    passcode. `"custom"` is accepted only together with
                    `password` (it changes nothing beyond what `password`
                    does).
            example:
              password: harbor-2026
      responses:
        "200":
          description: The passcode state.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandSharePasswordState"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
        "503":
          description: |
            **Documented in 1.210.1.** Setting a passcode (`password`) was
            refused and nothing was saved: either this deployment has no
            passcode encryption key configured (`"Passcodes are not available
            on this deployment"`), or the workspace's plan could not be read,
            so the Scale gate was not decided (`"Could not verify your plan.
            Please try again."` — retry shortly). `{ "mode": … }` never
            answers `503`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: Passcodes are not available on this deployment
    delete:
      tags: [Brands]
      operationId: clearBrandSharePassword
      summary: Remove a brand's own share passcode
      description: |
        **New in 1.199.0.** Back to `inherit`: the brand's links stop asking
        for a passcode unless the workspace policy requires one. Never
        plan-gated. Counts against the destructive budget.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The passcode state.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandSharePasswordState"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/automation-rules/copy:
    post:
      tags: [Automations]
      operationId: copyBrandAutomationRules
      summary: Copy automation rules onto a brand
      description: |
        **New in 1.199.0.** Edit Brand → Workflow → Automations → "Start
        from…": copy the workspace's rules (`fromBrandId: null`) or another
        brand's onto this brand. Each copy is re-validated against this brand
        and lands **disabled** (turn each on with
        `PATCH /api/v1/automation-rules/{id}` `enabled: true`); a rule that no
        longer fits is skipped with its reason. Automations plan. Covered by
        the `automations` scope.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [fromBrandId]
              properties:
                fromBrandId:
                  type: ["string", "null"]
                  format: uuid
                  description: The brand to copy from; `null` = the workspace-wide rules.
                ruleIds:
                  type: array
                  items: { type: string, format: uuid }
                  description: Copy only these rules (default all of the source's).
      responses:
        "200":
          description: What was copied and what was skipped.
          content:
            application/json:
              schema:
                type: object
                required: [brandId, copied, skipped]
                properties:
                  brandId: { type: string, format: uuid }
                  copied: { type: integer }
                  skipped:
                    type: array
                    items:
                      type: object
                      required: [reason, count]
                      properties:
                        reason: { type: string }
                        count: { type: integer }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/notification-defaults:
    get:
      tags: [Brands]
      operationId: getBrandNotificationDefaults
      summary: Read a brand's notification defaults
      description: |
        **New in 1.199.0.** Edit Brand → Notifications: the admin default per
        audience (`member` = the team, `guest` = the brand's clients) — muted,
        or per-channel email / WhatsApp / Slack on-off — applied to everyone
        who has not set their own rule for the brand. `null` = no default.
        Personal rules belong to people and are not readable with a key.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's notification defaults.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandNotificationDefaults"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    put:
      tags: [Brands]
      operationId: setBrandNotificationDefault
      summary: Set or clear one audience's notification default
      description: |
        **New in 1.199.0.** Replaces that audience's default. `muted: null`
        with no `channels` clears it. Setting one needs Notification Controls
        (Pro); clearing is always free. Sends nothing — it only changes how
        future notifications about the brand are delivered.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [audience]
              properties:
                audience:
                  type: string
                  enum: [member, guest]
                muted:
                  type: ["boolean", "null"]
                channels:
                  $ref: "#/components/schemas/NotificationChannelMap"
            example:
              audience: guest
              channels: { whatsapp: false }
      responses:
        "200":
          description: The brand's notification defaults after the change.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandNotificationDefaults"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/report-schedule:
    get:
      tags: [Brands]
      operationId: getBrandReportSchedule
      summary: Read a brand's scheduled client report
      description: |
        **New in 1.199.0.** Edit Brand → Reports: the scheduled report email
        (a status recap and/or social numbers) sent to the listed client
        addresses. `exists: false` = never saved (the defaults are shown).
        **1.200.0:** adds `design` — the Design tab's theme, header, accent,
        title, headline numbers and section order.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's report schedule.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandReportSchedule"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    put:
      tags: [Brands]
      operationId: updateBrandReportSchedule
      summary: Change a brand's scheduled client report
      description: |
        **New in 1.199.0.** Merges onto the saved schedule — send only what
        changes. Turning it **on** (`enabled: true`) needs the Elite plan
        (`403`); turning it off is always free. A save never sends; the
        hourly cron delivers the next due slot. Turning it on, or changing
        when it goes out (`cadence`, `weekday`, `monthDay`, `sendTime`,
        `timeZone`), schedules the next slot from now. A save that leaves the
        timing alone keeps the pending slot as it is — `nextSendAt` can then
        be a time that has just passed, and that send goes out on the next
        cron run rather than being skipped. An address that unsubscribed is
        never put back; a running schedule whose every recipient has
        unsubscribed is a `400`. The first save
        gives the brand a view-only client link that never expires (the
        email's buttons open it) when it has none. At most 10 recipients.

        **1.200.0 — `design`.** Merges per key like `sections`; `stats` and
        `blocks` each replace their whole list, in the order given. The
        design decides which data the email loads, so a body with `design`
        cannot also carry `sections` (`400`) and the response's `sections`
        follow it. A body with `sections` alone keeps the saved design: a
        section turned off loses its items, one turned on gets its default
        items. A design that shows nothing is a `400`. Social items
        (`posts`, `views`, `engagement`, `topPosts`) render only when
        `hasSocial` is true.

        The in-app "Send test" is not offered: it mails the person who
        pressed it, and an API key is not a person.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BrandReportScheduleInput"
            example:
              enabled: true
              cadence: weekly
              weekday: 1
              sendTime: "09:00"
              timeZone: America/New_York
              recipients: [maya@harborlights.example]
              design:
                theme: dark
                title: Your month at Harbor Lights
                stats: [views, finished, awaitingReview, engagement]
                blocks: [highlights, topPosts, awaitingReview, pipeline]
      responses:
        "200":
          description: The schedule as saved.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandReportSchedule"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/report-schedule/preview:
    post:
      tags: [Brands]
      operationId: previewBrandReport
      summary: Preview a brand's next client report
      description: |
        **New in 1.199.0.** What the brand's NEXT report email would contain
        — the same builder the scheduled send uses — for the saved schedule,
        or with the body's fields (same keys as `PUT`) overlaid. Sends
        nothing, saves nothing. The personal message is not part of it.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BrandReportScheduleInput"
      responses:
        "200":
          description: The report's content.
          content:
            application/json:
              schema:
                type: object
                required: [brandId, preview]
                properties:
                  brandId: { type: string, format: uuid }
                  preview:
                    type: object
                    additionalProperties: true
                    description: |
                      The report's sections, window and numbers, as the email renders them, plus
                      (1.200.0) the `design` it renders with. Each `social.topPosts[]` entry carries
                      `iconUrl` (the platform badge) and `thumbnailUrl` (the post cover, signed for
                      7 days; `null` when it has none).
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/retainer:
    get:
      tags: [Pricing]
      operationId: getBrandRetainer
      summary: Read a brand's monthly retainer
      description: |
        **New in 1.199.0.** Edit Brand → Billing: the amount in effect this
        month and every step of the retainer's schedule. Money received:
        `GET /api/v1/pricing/receivables`. Covered by the `finance` scope.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's retainer.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandRetainer"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    put:
      tags: [Pricing]
      operationId: setBrandRetainer
      summary: Set a brand's monthly retainer from a month on
      description: |
        **New in 1.199.0.** Sets the amount FROM `effectiveMonth` on
        (append-on-change: earlier months are never rewritten, and months
        already recorded against keep their stored amount). `monthlyAmount:
        null` ends the retainer from that month. Setting an amount needs the
        Pricing plan (Elite); ending one is always free. Nothing is sent to
        the client.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [monthlyAmount, effectiveMonth]
              properties:
                monthlyAmount:
                  type: ["number", "null"]
                  exclusiveMinimum: 0
                effectiveMonth:
                  type: string
                  description: YYYY-MM (a YYYY-MM-DD is read as its month).
            example:
              monthlyAmount: 4500
              effectiveMonth: "2026-12"
      responses:
        "200":
          description: The retainer after the change.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandRetainer"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/charges:
    get:
      tags: [Pricing]
      operationId: listBrandCharges
      summary: List a brand's one-off charges
      description: |
        **New in 1.199.0.** One-off charges billed to the brand on top of its
        retainer, newest first (at most 500). `paid` = received in full;
        partial payments are on `GET /api/v1/pricing/receivables`.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's charges.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/BrandCharge"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Pricing]
      operationId: createBrandCharge
      summary: Add a one-off brand charge
      description: |
        **New in 1.199.0.** Bill the brand for work outside its retainer.
        Pricing plan (Elite). Record money received with
        `POST /api/v1/payments` (`nodeId` = the brand). Nothing is sent to the
        client.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BrandChargeInput"
            example:
              label: Extra drone day
              amount: 850
              chargeDate: "2026-11-14"
      responses:
        "201":
          description: The new charge.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandCharge"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/charges/{chargeId}:
    patch:
      tags: [Pricing]
      operationId: updateBrandCharge
      summary: Edit a one-off brand charge
      description: |
        **New in 1.199.0.** Send only what changes. Raising the amount of a
        fully received charge makes it part-received again. Pricing plan.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandChargeId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BrandChargePatch"
      responses:
        "200":
          description: The charge after the change.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandCharge"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Pricing]
      operationId: deleteBrandCharge
      summary: Remove a one-off brand charge
      description: |
        **New in 1.199.0.** Refused with `409` while payments are recorded
        against it — void them first, so removing a line never makes received
        money disappear. Counts against the destructive budget.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandChargeId"
      responses:
        "204":
          description: Removed.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/connect-invites:
    get:
      tags: [Brands]
      operationId: listBrandConnectInvites
      summary: List a brand's social connect links
      description: |
        **New in 1.199.0.** The brand's no-login connect links (Edit Brand →
        Connected Accounts), newest first (at most 100).
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's connect links.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/BrandConnectInvite"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: createBrandConnectInvite
      summary: Create a social connect link for a brand
      description: |
        **New in 1.199.0.** Connecting a social account needs its owner's own
        login (OAuth), which no API call can perform. This mints a no-login
        link instead: give `url` to the client, they open it, pick the channel
        and sign in, and the account appears on the brand
        (`GET /api/v1/brands/{id}` → `socialAccounts`).

        The URL is a credential — whoever holds it can connect an account to
        this brand until it expires (`expiresInDays` 1–90, default the
        workspace setting) or is revoked. Needs a posting plan, and the
        workspace must allow client connect links.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                platforms:
                  type: array
                  items: { type: string }
                  description: Channels the link offers (default any).
                expiresInDays:
                  type: integer
                  minimum: 1
                  maximum: 90
            example:
              platforms: [instagram, tiktok]
              expiresInDays: 14
      responses:
        "201":
          description: The new connect link.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandConnectInvite"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/connect-invites/{inviteId}:
    delete:
      tags: [Brands]
      operationId: revokeBrandConnectInvite
      summary: Revoke a social connect link
      description: |
        **New in 1.199.0.** The link stops working at once; an account
        already connected through it stays connected. Counts against the
        destructive budget.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - name: inviteId
          in: path
          required: true
          schema: { type: string, format: uuid }
      responses:
        "204":
          description: Revoked.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/social-accounts/{accountId}:
    delete:
      tags: [Brands]
      operationId: disconnectBrandSocialAccount
      summary: Disconnect a brand's social account
      description: |
        **New in 1.199.0.** What the app's Disconnect does: the account is
        marked disconnected and its stored token is no longer used, the audit
        trail records it, and scheduled posts on that channel stop publishing
        until the client connects it again. Nothing is deleted on the platform
        and nobody is notified. Idempotent. Counts against the destructive
        budget.

        **Changed in 1.230.0 — YouTube.** Disconnecting a YouTube channel
        also deletes Timeliner's stored Google token for it and revokes
        Timeliner's access at Google right away (YouTube API Services
        Developer Policies III.D.2.c), so Timeliner leaves that Google
        Account's third-party connections. While the same channel is still
        connected to another brand, its Google access is kept for that brand
        (Google grants one permission per channel) and is revoked when the
        channel's last brand disconnects. A revoke Google does not answer is
        retried within the hour; the response is `204` either way.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - name: accountId
          in: path
          required: true
          description: "`socialAccounts[].id` from `GET /api/v1/brands/{id}`."
          schema: { type: string, format: uuid }
      responses:
        "204":
          description: Disconnected.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/copywriting:
    get:
      tags: [Brands]
      operationId: listBrandCopywriting
      summary: Read a brand's copywriting rules (Scripts & captions)
      description: |
        **New in 1.199.0.** Edit Brand → Scripts & captions: the written rules
        the AI follows for this brand in three `sections` (`editing`,
        `briefing`, `captions`), the `candidates` the learning passes proposed
        (each with how many videos it was seen on), and the caption `voice`
        (read-only here — `PATCH /api/v1/brands/{id}/voice`). AI editor beta
        workspaces only (`403` `editor_beta_required`).
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's copywriting view.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandCopywriting"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: addBrandCopywritingRule
      summary: Add a copywriting rule
      description: |
        **New in 1.199.0.** Adds a rule to a section (≤ 500 characters).
        Editor beta only.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [topic, text]
              properties:
                topic: { type: string, enum: [editing, briefing, captions] }
                text: { type: string, maxLength: 500 }
            example:
              topic: captions
              text: Always end with the harbour emoji and a question to the viewer.
      responses:
        "201":
          description: The new rule.
          content:
            application/json:
              schema:
                type: object
                required: [id, topic, text]
                properties:
                  id: { type: string, format: uuid }
                  topic: { type: string, enum: [editing, briefing, captions] }
                  text: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/copywriting/{factId}:
    delete:
      tags: [Brands]
      operationId: deleteBrandCopywritingRule
      summary: Delete a copywriting rule or dismiss a candidate
      description: |
        **New in 1.199.0.** The AI stops reading it at once; a dismissed
        candidate is never proposed again. Editor beta only. Counts against
        the destructive budget.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandFactId"
      responses:
        "204":
          description: Deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/copywriting/{factId}/confirm:
    post:
      tags: [Brands]
      operationId: confirmBrandCopywritingRule
      summary: Confirm a proposed copywriting rule
      description: |
        **New in 1.199.0.** The candidate becomes an active rule in its
        section and the AI starts following it. Editor beta only.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandFactId"
      responses:
        "200":
          description: Confirmed.
          content:
            application/json:
              schema:
                type: object
                required: [id, status]
                properties:
                  id: { type: string, format: uuid }
                  status: { type: string, enum: [active] }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/inspiration:
    get:
      tags: [Brands]
      operationId: getBrandInspiration
      summary: Read a brand's inspiration examples
      description: |
        **New in 1.199.0.** Brand assets → Inspiration: `pinned` examples the AI
        editor follows (`good`) or avoids (`bad`) with why; the brand's edits
        approved the first time (`firstPass`) and the ones that came back
        (`cameBack`); and the revision rules its history keeps repeating
        (`repeated`). **Changed in 1.201.0:** a task example may be any
        brand's task of the workspace; each pin carries its video
        (`fileId`), `statusGroup`, `brandName` and whether it is this brand's
        own (`ownBrand`), and `pinned` lists the brand's own examples first —
        the order the AI studies the `good` ones in. Editor beta only.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's inspiration.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandInspiration"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: addBrandInspiration
      summary: Pin an inspiration example
      description: |
        **New in 1.199.0.** `url` is a Timeliner task link of this
        workspace — this brand's task or, since 1.201.0, any other brand's —
        or any public link; `why` (≤ 300 characters) is what the editor
        should take from it. A `good` task example is a video the AI
        watches on every cut of the brand, after the brand's own examples.
        Pinning the same example again updates it. Editor beta only.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [polarity, url, why]
              properties:
                polarity: { type: string, enum: [good, bad] }
                url: { type: string, maxLength: 500 }
                why: { type: string, maxLength: 300 }
            example:
              polarity: good
              url: https://www.instagram.com/reel/example
              why: Fast cuts on the beat and captions that never cover faces.
      responses:
        "201":
          description: The pinned example.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandInspirationPin"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/inspiration/{factId}:
    delete:
      tags: [Brands]
      operationId: removeBrandInspiration
      summary: Unpin an inspiration example
      description: |
        **New in 1.199.0.** The AI editor stops reading it at once; the
        record is retired, not erased. Editor beta only. Counts against the
        destructive budget.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandFactId"
      responses:
        "204":
          description: Unpinned.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/brain-facts:
    get:
      tags: [Brands]
      operationId: listBrandBrainFacts
      summary: Read what the AI learned about a brand
      description: |
        **New in 1.199.0.** Edit Brand → What the AI learned: the facts the AI
        check reviews this brand's videos against, by section, whether a
        person wrote them or the AI learned them, and the checks switched off
        for this brand (`suppressions`). An end client also lists the parent
        brand's facts it inherits. Editor beta only. **Since 1.202.0** every
        brain-facts operation also answers 403 `staff_required` unless the
        key was created by Timeliner staff — like the in-app tab, What the AI
        learned is limited to staff during the beta. **Since 1.210.1** that
        creator must also still hold an active team seat in this workspace
        (not deactivated, not pending), else the same 403.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's facts.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandBrainFacts"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: addBrandBrainFact
      summary: Add a fact the AI uses
      description: |
        **New in 1.199.0.** A person's fact in a section (≤ 500 characters).
        `overrideOf` (an end client only) re-words an inherited fact for this
        client — it takes that fact's section. Editor beta only; a key not
        created by Timeliner staff with an active team seat here gets 403
        `staff_required` (1.202.0; the seat since 1.210.1).
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [kind, text]
              properties:
                kind:
                  type: string
                  enum: [identity, vocabulary, voice, visual, audio, format, compliance, process]
                text: { type: string, maxLength: 500 }
                overrideOf: { type: string, format: uuid }
            example:
              kind: visual
              text: The logo sits bottom-right, never over a face.
      responses:
        "201":
          description: The new fact.
          content:
            application/json:
              schema:
                type: object
                required: [id, kind, text]
                properties:
                  id: { type: string, format: uuid }
                  kind: { type: string }
                  text: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/brain-facts/{factId}:
    patch:
      tags: [Brands]
      operationId: updateBrandBrainFact
      summary: Re-word a fact the AI uses
      description: |
        **New in 1.199.0.** A NEW fact replaces it — the answer's `id` is the
        new fact's and `replaces` names the old one — except an end client's
        override, which is re-worded in place (`replaces: null`). Editor beta
        only; a key not created by Timeliner staff with an active team seat
        here gets 403 `staff_required` (1.202.0; the seat since 1.210.1).
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandFactId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [text]
              properties:
                text: { type: string, maxLength: 500 }
      responses:
        "200":
          description: The fact after the change.
          content:
            application/json:
              schema:
                type: object
                required: [id, replaces, text]
                properties:
                  id: { type: string, format: uuid }
                  replaces: { type: ["string", "null"], format: uuid }
                  text: { type: string }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Brands]
      operationId: deleteBrandBrainFact
      summary: Delete a fact the AI uses
      description: |
        **New in 1.199.0.** Removes a fact for good: its text is blanked, the
        evidence behind it is erased, and it is never re-learned. A
        switched-off check is restored, not deleted. Editor beta only; a key
        not created by Timeliner staff with an active team seat here gets 403
        `staff_required` (1.202.0; the seat since 1.210.1).
        Counts against the destructive budget.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandFactId"
      responses:
        "204":
          description: Deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/brands/{id}/brain-facts/{factId}/restore:
    post:
      tags: [Brands]
      operationId: restoreBrandBrainCheck
      summary: Turn a switched-off check back on
      description: |
        **New in 1.199.0.** For a check this brand switched off
        (`suppressions[].id`). It runs again on the next review and switches
        off again only after two NEW "not relevant" marks. Editor beta only;
        a key not created by Timeliner staff with an active team seat here
        gets 403 `staff_required` (1.202.0; the seat since 1.210.1).
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandFactId"
      responses:
        "200":
          description: Restored.
          content:
            application/json:
              schema:
                type: object
                required: [id, restored]
                properties:
                  id: { type: string, format: uuid }
                  restored: { type: boolean }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/posts/{taskId}/thumbnails:
    get:
      tags: [Posts]
      operationId: listPostThumbnails
      summary: List a post's AI thumbnails
      description: |
        **New in 1.212.0.** The post's AI thumbnail generations, newest first
        (up to 20), each with its versions, their state, signed image URLs
        (valid 10 minutes) and the networks / YouTube slots already using them.
        `403` `notAvailable` or `planDoesNotIncludeSocialPosting` is final for
        the workspace.

        **Removed images (1.216.0).** When a workspace stays cancelled, its AI
        thumbnails are removed with its uploaded files (see *Removed media*): a
        removed version keeps its metadata, with `purgedAt` set and `imageUrl` /
        `previewUrl` `null`. Paying again before the permanent deletion brings
        it back; after it, the version stays removed.
      parameters:
        - $ref: "#/components/parameters/ThumbnailPostId"
      responses:
        "200":
          description: The post's generations.
          content:
            application/json:
              schema:
                type: object
                required: [generations]
                properties:
                  generations:
                    type: array
                    items: { $ref: "#/components/schemas/ThumbnailGeneration" }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Posts]
      operationId: generatePostThumbnails
      summary: Generate AI thumbnails for a post
      description: |
        **New in 1.212.0.** Timeliner's AI designs 1–4 thumbnail versions for a
        video post from its transcript, frames, the brand's colors and
        thumbnail style, and optionally the brand's consented speakers (only
        people whose permission is on file — `GET /api/v1/brands/{id}/speakers`).
        A face is never invented: without a speaker the thumbnail shows none.

        **Price** — each version is charged in credits, only when it comes
        back (a failed version costs nothing). Quote first with
        `POST …/thumbnails/quote`.

        **Async** — answers `202` with a `generationId`; poll
        `GET …/thumbnails/{generationId}` every few seconds (usually 30–90 s).
        With `wait: true` the call holds up to ~50 s and answers `200` with
        the finished generation, or `202` when it is still rendering.
        `idempotencyKey` (a UUID) makes a retried call answer the same
        generation instead of paying twice: `202` while it is still rendering,
        `200` with the generation once it settled (as `wait: true` answers),
        and the same `422` `likenessRefused` / `503` `aiUnavailable` when the
        first call was refused (1.213.2).

        Refusals: `402` out of credits (nothing ran); `403` `UPLOADS_PAUSED`
        while the workspace's uploads are paused (see *Uploads paused*; since
        1.216.0) — checked before anything is held, planned or made, so a
        retried `idempotencyKey` hears it too; `422`
        `insufficientContext` (no transcript, no frames and no hook or
        instructions) or `likenessRefused` (the instructions or hook ask for a
        real person who is not a consented speaker — by name too — and nothing
        is charged); `409` `speakerUnavailable`; `429` a workspace limit;
        `503` `aiUnavailable` (Timeliner's AI is out of capacity, nothing
        charged); `400` TikTok (its cover is a frame time).
      parameters:
        - $ref: "#/components/parameters/ThumbnailPostId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ThumbnailRequest"
            example:
              platform: youtube
              variants: 2
              hookText: I QUIT MY JOB
              speakerIds: [3f1d2c4b-5a6e-4f70-8a9b-0c1d2e3f4a5b]
              idempotencyKey: 9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d
      responses:
        "200":
          description: "`wait: true` and the generation settled, or `idempotencyKey` replayed a generation that already settled."
          content:
            application/json:
              schema:
                type: object
                required: [status, generation]
                properties:
                  status: { type: string, enum: [ready, partial, failed, cancelled] }
                  generation: { $ref: "#/components/schemas/ThumbnailGeneration" }
                  replay: { type: boolean }
        "202":
          description: The generation is rendering — poll it.
          headers:
            Retry-After:
              description: Seconds to wait before polling.
              schema: { type: integer }
          content:
            application/json:
              schema:
                type: object
                required: [status, generationId, estimateCredits]
                properties:
                  status: { type: string, enum: [generating] }
                  generationId: { type: string, format: uuid }
                  estimateCredits: { type: integer, description: The most this run can charge. }
                  replay: { type: boolean, description: "`true` when `idempotencyKey` matched an earlier call." }
                  retryAfterSeconds: { type: integer }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/OutOfCredits"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "422":
          $ref: "#/components/responses/BadRequest"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"
        "503":
          $ref: "#/components/responses/ServerError"
  /api/v1/posts/{taskId}/thumbnails/quote:
    post:
      tags: [Posts]
      operationId: quotePostThumbnails
      summary: Price AI thumbnails before generating
      description: |
        **New in 1.212.0.** What `POST …/thumbnails` would cost with the same
        body, before anything runs: the resolved model, shape, resolution and
        quality, credits per version and in total, whether the workspace is
        charged at all, and every model's per-version price for the same
        shape. Nothing is held or spent.
      parameters:
        - $ref: "#/components/parameters/ThumbnailPostId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ThumbnailRequest"
      responses:
        "200":
          description: The quote.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ThumbnailQuote"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/posts/{taskId}/thumbnails/{generationId}:
    get:
      tags: [Posts]
      operationId: getPostThumbnails
      summary: Check an AI thumbnail generation
      description: |
        **New in 1.212.0.** One generation and its versions. While `status` is
        `queued`, `directing` or `generating` each call moves it forward —
        poll every few seconds (`Retry-After`). A version whose image was
        removed after the workspace's subscription ended has `purgedAt` set
        and no image URLs (1.216.0).
      parameters:
        - $ref: "#/components/parameters/ThumbnailPostId"
        - $ref: "#/components/parameters/ThumbnailGenerationId"
      responses:
        "200":
          description: The generation.
          content:
            application/json:
              schema:
                type: object
                required: [generation]
                properties:
                  generation: { $ref: "#/components/schemas/ThumbnailGeneration" }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/posts/{taskId}/thumbnails/{generationId}/select:
    post:
      tags: [Posts]
      operationId: selectPostThumbnail
      summary: Use an AI thumbnail as the post's cover
      description: |
        **New in 1.212.0.** Makes one version the post's cover — on every
        network that takes a cover image (default), the named `networks`, or
        YouTube Test & Compare `youtubeSlots`. The post needs a saved draft
        (`409` `noDraft`). Re-opens the client's thumbnail approval, as a
        cover change in the app does. `409` `notReady`: the version is still
        rendering or failed. `404` `{ "code": "file_content_missing",
        "purgedAt": "…" }`: its image was removed after the workspace's
        subscription ended (see *Removed media*; since 1.216.0) — nothing is
        changed. `403` `UPLOADS_PAUSED` while the workspace's uploads are
        paused — a new cover is an upload (see *Uploads paused*; since
        1.216.0, which replaced this endpoint's earlier undocumented
        `uploadsPaused` code).
      parameters:
        - $ref: "#/components/parameters/ThumbnailPostId"
        - $ref: "#/components/parameters/ThumbnailGenerationId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [variantId]
              properties:
                variantId: { type: string, format: uuid }
                networks:
                  oneOf:
                    - { type: string, enum: [all] }
                    - type: array
                      minItems: 1
                      items: { type: string, enum: [youtube, instagram, facebook, linkedin] }
                youtubeSlots:
                  type: array
                  minItems: 1
                  items: { type: string, enum: [a, b, c] }
            example:
              variantId: 3f1d2c4b-5a6e-4f70-8a9b-0c1d2e3f4a5b
              networks: [youtube]
              youtubeSlots: [b]
      responses:
        "200":
          description: Where the cover was applied.
          content:
            application/json:
              schema:
                type: object
                required: [applied, skipped, thumbnailApprovalReset]
                properties:
                  applied:
                    type: array
                    items:
                      type: object
                      required: [network, youtubeSlot]
                      properties:
                        network: { type: string }
                        youtubeSlot: { type: ["string", "null"] }
                  skipped: { type: array, items: { type: string } }
                  thumbnailApprovalReset: { type: boolean }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/posts/{taskId}/thumbnails/{generationId}/cancel:
    post:
      tags: [Posts]
      operationId: cancelPostThumbnails
      summary: Cancel an AI thumbnail generation
      description: |
        **New in 1.212.0.** Stops a generation still rendering. Versions not
        back yet are not charged; finished ones are kept. `409` `notLive` when
        it already finished.
      parameters:
        - $ref: "#/components/parameters/ThumbnailPostId"
        - $ref: "#/components/parameters/ThumbnailGenerationId"
      responses:
        "200":
          description: The generation after cancelling.
          content:
            application/json:
              schema:
                type: object
                required: [generation]
                properties:
                  generation: { $ref: "#/components/schemas/ThumbnailGeneration" }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/posts/{taskId}/thumbnails/{generationId}/feedback:
    post:
      tags: [Posts]
      operationId: ratePostThumbnail
      summary: Rate an AI thumbnail version
      description: |
        **New in 1.212.0.** Tells the brand's thumbnail style what worked. The
        brand learns from it overnight (`GET /api/v1/brands/{id}/thumbnail-style`
        → `learnedNotes`).
      parameters:
        - $ref: "#/components/parameters/ThumbnailPostId"
        - $ref: "#/components/parameters/ThumbnailGenerationId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [variantId, verdict]
              properties:
                variantId: { type: string, format: uuid }
                verdict: { type: string, enum: [liked, rejected] }
                reason: { type: string, enum: [faceMismatch, textWrong, cluttered, offBrand, wrongVibe, other] }
                note: { type: string, maxLength: 300 }
            example:
              variantId: 3f1d2c4b-5a6e-4f70-8a9b-0c1d2e3f4a5b
              verdict: rejected
              reason: textWrong
      responses:
        "200":
          description: Recorded.
          content:
            application/json:
              schema:
                type: object
                required: [ok]
                properties:
                  ok: { type: boolean }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/brands/{id}/speakers:
    get:
      tags: [Brands]
      operationId: listBrandSpeakers
      summary: List a brand's speakers
      description: |
        **New in 1.212.0.** The people the brand's AI thumbnails may show:
        handle, name, consent state, likeness state and use count. Only
        `usable` speakers can be passed as `speakerIds`. A speaker whose
        photos were removed after the workspace's subscription ended has
        `purgedAt` set and is not `usable` while they are removed (1.216.0);
        paying again before the permanent deletion brings them back.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The brand's speakers.
          content:
            application/json:
              schema:
                type: object
                required: [speakers]
                properties:
                  speakers:
                    type: array
                    items: { $ref: "#/components/schemas/BrandSpeaker" }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: createBrandSpeaker
      summary: Add a brand speaker
      description: |
        **New in 1.212.0.** Adds a person the brand's AI thumbnails may show,
        with 1–4 clear photos: public `https` `imageUrls` (fetched
        server-side, ≤ 8 MB each, private networks refused) and/or the
        brand's own `brandFileIds`.

        **Consent is mandatory.** `consent` records who agreed and how; it is
        the attestation of the API key's creator, who must be an admin or
        supervisor of the brand (`403` otherwise), and is stored with their
        name and the time. Only call it when that person really agreed. The
        likeness is then prepared in the background (`likeness: "syncing"` →
        `"ready"`).

        `403` `UPLOADS_PAUSED` while the workspace's uploads are paused (see
        *Uploads paused*; since 1.216.0): after the body and consent checks,
        before any photo is fetched or stored — nothing is created.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [displayName, handle, consent]
              properties:
                displayName: { type: string, maxLength: 80 }
                handle: { type: string, pattern: "^[A-Za-z][A-Za-z0-9]{1,23}$" }
                description: { type: string, maxLength: 300 }
                imageUrls: { type: array, maxItems: 4, items: { type: string, format: uri } }
                brandFileIds: { type: array, maxItems: 4, items: { type: string, format: uuid } }
                consent:
                  type: object
                  required: [subjectName, method, attested]
                  properties:
                    subjectName: { type: string, maxLength: 120 }
                    method: { type: string, enum: [writtenOnFile, inAppAttestation] }
                    attested: { type: boolean, enum: [true] }
                    note: { type: string, maxLength: 500 }
            example:
              displayName: Maya Cohen
              handle: maya
              imageUrls: [https://cdn.harborlights.example/maya-1.jpg]
              consent: { subjectName: Maya Cohen, method: writtenOnFile, attested: true }
      responses:
        "201":
          description: The new speaker.
          content:
            application/json:
              schema:
                type: object
                required: [speaker]
                properties:
                  speaker: { $ref: "#/components/schemas/BrandSpeaker" }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "413":
          $ref: "#/components/responses/BadRequest"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/brands/{id}/speakers/{speakerId}:
    patch:
      tags: [Brands]
      operationId: updateBrandSpeaker
      summary: Update a brand speaker
      description: |
        **New in 1.212.0.** Rename or re-describe a speaker, or withdraw their
        permission (`revokeConsent: true` — the speaker is never used again
        and their likeness is deleted). Photos change in the app. Admin or
        supervisor keys.

        A speaker whose photos were removed after the workspace's subscription
        ended (`purgedAt` set, 1.216.0) takes only `revokeConsent: true`,
        which always works — any other field in the same body is ignored. A
        body without it answers **404** `{ "error": "…", "code":
        "file_content_missing", "purgedAt": "…" }` and changes nothing.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandSpeakerId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                displayName: { type: string, maxLength: 80 }
                handle: { type: string, pattern: "^[A-Za-z][A-Za-z0-9]{1,23}$" }
                description: { type: string, maxLength: 300 }
                revokeConsent: { type: boolean }
            example:
              revokeConsent: true
      responses:
        "200":
          description: The speaker.
          content:
            application/json:
              schema:
                type: object
                required: [speaker]
                properties:
                  speaker: { $ref: "#/components/schemas/BrandSpeaker" }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Brands]
      operationId: deleteBrandSpeaker
      summary: Delete a brand speaker
      description: |
        **New in 1.212.0.** Removes the speaker, their photos and likeness.
        Thumbnails already made stay. Admin or supervisor keys.
      parameters:
        - $ref: "#/components/parameters/BrandId"
        - $ref: "#/components/parameters/BrandSpeakerId"
      responses:
        "200":
          description: Deleted.
          content:
            application/json:
              schema:
                type: object
                required: [ok]
                properties:
                  ok: { type: boolean }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/brands/{id}/thumbnail-style:
    get:
      tags: [Brands]
      operationId: getBrandThumbnailStyle
      summary: Read a brand's thumbnail style
      description: |
        **New in 1.212.0.** The brand's AI-thumbnail style and what the AI
        learned from the team's picks and the client's reviews.
        `preferences.referenceCount` is how many reference thumbnails the
        brand holds (they are managed in the app) and, since 1.216.0,
        `removedReferenceCount` how many of them were removed after the
        workspace's subscription ended.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      responses:
        "200":
          description: The style.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BrandThumbnailStyle"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    put:
      tags: [Brands]
      operationId: updateBrandThumbnailStyle
      summary: Update a brand's thumbnail style
      description: |
        **New in 1.212.0.** Fields you omit keep their value; `doNotes` /
        `dontNotes` replace the lists. Reference thumbnails are managed in
        the app. Admin or supervisor keys.
      parameters:
        - $ref: "#/components/parameters/BrandId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [preferences]
              properties:
                preferences:
                  type: object
                  properties:
                    palette: { type: string, enum: [brandKit, auto, custom] }
                    customColors: { type: array, maxItems: 3, items: { type: string, pattern: "^#[0-9a-fA-F]{6}$" } }
                    textStyle: { type: string, enum: [boldCaps, titleCase, none] }
                    favouriteArchetypes: { type: array, maxItems: 5, items: { type: string } }
                    doNotes: { type: array, maxItems: 15, items: { type: string, maxLength: 200 } }
                    dontNotes: { type: array, maxItems: 15, items: { type: string, maxLength: 200 } }
            example:
              preferences:
                textStyle: boldCaps
                dontNotes: [Red backgrounds]
      responses:
        "200":
          description: The saved preferences.
          content:
            application/json:
              schema:
                type: object
                required: [preferences]
                properties:
                  preferences: { $ref: "#/components/schemas/BrandThumbnailPreferences" }
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/header-cards:
    post:
      tags: [Brands]
      operationId: createHeaderCard
      summary: Add a card to a header
      description: |
        Adds a new card to a project's (`projectId`) or brand's (`brandId`)
        header canvas — the same as the header's **+** button in the app.

        Two card types can be added, the same two `PATCH /api/v1/header-cards/{cardId}`
        writes:
        - **`doc`** — a rich-text page. Optional `html` is its starting text.
        - **`links`** — a list of links. Optional `links` is its starting list.

        Leave the content out for an empty card and write it later with
        `PATCH /api/v1/header-cards/{cardId}` using the returned `id`. The new
        card is an ordinary card — never the project's Brief — so it is always
        writable that way.

        The card goes last in the header's first section, or in the section
        named by `section` (case-insensitive). An unknown section name is a
        `400` whose message lists the header's sections. Since 1.154.0 the
        header read (`GET /api/v1/projects/{id}/header`,
        `GET /api/v1/brands/{id}/header`) lists them too: `sections`, and each
        `cards[]` entry's `section`.

        Someone with the project or brand open in the app sees the new card —
        and any later write to it — appear in the header without reloading
        (since 1.154.0).

        A header that has never been opened in the app has no cards yet; it is
        given the workspace's default cards first (for a project: Brief and
        Raw files & Assets; for a brand: Guidelines and Brand Links — or the
        workspace's own saved defaults), so adding a card never replaces them.
        Those default cards are titled in English.

        Since 1.219.0 `visibility` chooses who sees the new card — one of the
        app's **Card permissions** presets (`everyone`, `team`, `approvers`,
        `adminsOnly`). Left out, the card gets the visibility the workspace's
        saved default gives that card type (Settings → Workspace → Header
        cards), like a card added in the app. Requires `write:projects`. No
        notifications fire.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateHeaderCardInput"
            examples:
              docCard:
                summary: Add a doc card to a project header
                value:
                  projectId: "3f2c1a9e-6b7d-4c2e-9a1f-0d8e5b4c3a21"
                  type: doc
                  title: "Niche Profile"
                  html: "<h2>Niche</h2><p>Coastal surf brands, 18–30</p>"
                  visibility: team
              linksCard:
                summary: Add a links card to a brand header
                value:
                  brandId: "7a6b5c4d-3e2f-4a1b-8c9d-0e1f2a3b4c5d"
                  type: links
                  title: "Shoot references"
                  links:
                    - title: "Mood board"
                      url: "https://drive.example.com/mood"
      responses:
        "201":
          description: The new card.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderCardResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/header-cards/{cardId}:
    patch:
      tags: [Brands]
      operationId: updateHeaderCard
      summary: Write a header card's content or visibility
      description: |
        Writes the content of one card on a brand's or project's header canvas,
        chooses who sees it, or hides a default card — one call may do any of
        them (send at least one of `html`, `links`, `visibility`, `hidden`).
        Card ids come from `cards[].id` on `GET /api/v1/projects/{id}/header` or
        `GET /api/v1/brands/{id}/header` — a card id resolves to exactly one
        header, so this single endpoint serves both scopes.

        Writable card types:
        - **`doc`** — send `html`: a FULL REPLACE of the card's rich text
          (`""` clears it).
        - **`links`** — send `links`: a FULL REPLACE of the whole list, so
          include the entries that should stay (`[]` clears it).

        Sending the wrong field for the card's type is a `400`. `assets`,
        `timeline` and `intake` cards render live from other data and
        `fileAttach` needs a real upload, so none of them are writable.

        Every `doc` card is written on its own — including a brand card that is
        still showing the brand's `description` (a brand's Guidelines card, or
        several doc cards set up to mirror it). Since 1.105.0 the write gives
        THAT card its own text and it stops following the description: a later
        `PATCH /api/v1/brands/{id}` `description` no longer changes it, and the
        other cards are untouched. (Before 1.105.0 those cards answered `409`,
        leaving the brand `description` — which repaints every mirroring card
        at once — as the only way to write them.)

        The one exception is a **project's Brief** card (`409`): it always shows
        the project's `description`, so write its text with
        `PATCH /api/v1/projects/{id}` instead.

        **Visibility** (since 1.219.0) — `visibility` sets who sees the card,
        with the app's **Card permissions** presets: `everyone` (every role,
        guests included, sees and edits it), `team` (the internal team only —
        guests don't see it), `approvers` (the team edits, guests view) or
        `adminsOnly`. Every card type but an `intake` form card takes it
        (`400` there — its visibility follows the form's own setup). It never
        un-hides a hidden card.

        **Hiding a default card** (since 1.219.0) — `hidden: true` hides a
        default card (Brief, Guidelines, Brand Links, Raw files & Assets —
        `isDefault: true` on the header read) from everyone; `hidden: false`
        brings it back. Default cards are hidden, never deleted. Any other
        card is removed with `DELETE /api/v1/header-cards/{cardId}`, so
        `hidden` on one is a `400`.

        No notifications fire.
      parameters:
        - name: cardId
          in: path
          required: true
          description: The header card's id (from `cards[].id` on a header read).
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateHeaderCardInput"
            examples:
              writeDoc:
                summary: Replace a doc card's text
                value:
                  html: "<h2>Tone of voice</h2><p>Short, plain, direct. Name the offer.</p>"
              writeLinks:
                summary: Replace a links card's list
                value:
                  links:
                    - title: "Brand kit"
                      url: "https://drive.example.com/brand-kit"
                    - url: "https://example.com"
              setVisibility:
                summary: Show a card to the internal team only
                value:
                  visibility: team
              hideDefaultCard:
                summary: Hide a default card from everyone
                value:
                  hidden: true
      responses:
        "200":
          description: The updated card.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderCardResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: The project Brief card is a live view of the project's description — write its text with `PATCH /api/v1/projects/{id}` instead.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Brands]
      operationId: deleteHeaderCard
      summary: Delete a header card
      description: |
        Permanently removes one card someone added to a brand's or project's
        header (a doc page, a links list, a Documents & attachments card, …) —
        the same as the card's **Delete** in the app. There is no undo.
        Since 1.219.0.

        **Default cards** (Brief, Guidelines, Brand Links, Raw files & Assets —
        `isDefault: true` on the header read) can't be deleted (`409`); hide
        one with `PATCH /api/v1/header-cards/{cardId}` and `{"hidden": true}`.

        Files attached to a Documents & attachments card are not deleted —
        they stay in the project's files. The card's public share link stops
        working.

        Deletes draw on the API's shared delete budget: about 20 per minute
        per key, plus daily ceilings per key and per workspace — over budget
        is a `429` with a `Retry-After` header. No notifications fire.
      parameters:
        - name: cardId
          in: path
          required: true
          description: The header card's id (from `cards[].id` on a header read).
          schema:
            type: string
            format: uuid
      responses:
        "204":
          description: The card was deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: "A default card can't be deleted — hide it with `PATCH /api/v1/header-cards/{cardId}` and `hidden: true` instead."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/header-cards/{cardId}/share-link:
    parameters:
      - name: cardId
        in: path
        required: true
        description: The header card's id (from `cards[].id` on a header read).
        schema:
          type: string
          format: uuid
    get:
      tags: [Brands]
      operationId: getHeaderCardShareLink
      summary: Read a header card's share link
      description: |
        Whether one header card has a read-only share link — the card's
        **... → Share** in the app (1.227.0). `url` is the public page anyone
        with the link opens without signing in; `null` when there is no
        active link. `blockReason` says why no working link can exist right
        now: `hiddenFromClients` (the card's visibility hides it from clients)
        or `unsupportedType` (only `doc`, `links`, `assets` and `timeline`
        cards can be shared). A card in another workspace is `404`.
      responses:
        "200":
          description: The card's link state.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderCardShareLinkResponse"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Brands]
      operationId: createHeaderCardShareLink
      summary: Create a header card's share link
      description: |
        Creates a read-only link to one header card — the card's
        **... → Share → Create link** in the app (1.227.0). When the card
        already has an active link, that link comes back with `200` rather
        than a second one (`201` = newly created). Refused with `409` on a card
        hidden from clients (change its `visibility` with
        `PATCH /api/v1/header-cards/{cardId}` first) or a card type that can't
        be shared. A billing-locked workspace is refused like every API write.
        No body. Silent — no one is notified.
      responses:
        "200":
          description: The card already had a link — the same link.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderCardShareLinkResponse"
        "201":
          description: The newly created link.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderCardShareLinkResponse"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: The card is hidden from clients, or its type can't be shared.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Brands]
      operationId: revokeHeaderCardShareLink
      summary: Revoke a header card's share link
      description: |
        Turns off a header card's read-only link — the card's
        **... → Share → Revoke** in the app (1.227.0). Anyone opening the old
        link sees that it is no longer available; a link created later has a
        new address. Never billing-gated: turning a link off always works.
        `revoked: false` when the card had no active link.

        Revokes draw on the API's shared delete budget: about 20 per minute
        per key, plus daily ceilings per key and per workspace — over budget
        is a `429` with a `Retry-After` header. No notifications fire.
      responses:
        "200":
          description: The link is off.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HeaderCardShareRevokeResponse"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/workspace/settings:
    get:
      tags: [Workspace]
      operationId: getWorkspaceSettings
      summary: Read workspace settings
      description: |
        Returns the curated workspace settings (Settings → Workspace + Advanced) —
        permissions, workflow (dual deadlines, revision caps), media review, the
        guest portal, plus read-only context like the download policy. Effective
        values, with view defaults applied.
      responses:
        "200":
          description: The workspace settings.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WorkspaceSettingsResponse"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Workspace]
      operationId: updateWorkspaceSettings
      summary: Update workspace settings
      description: |
        Changes one or more writable settings — send only the keys to change.
        Plan-gated keys require the workspace's plan to ENABLE them (disabling
        is always allowed): `dualDeadlineMode` needs a Studio plan or higher;
        `enableTranscripts` needs any current plan (Studio, Agency or Scale) or
        a legacy Elite plan; `guestCanViewBrief` needs a Studio plan or higher
        (a lower plan gets 403; setting it to `false` works on every plan);
        `autoTranscribeUploads` follows `enableTranscripts` (any current
        plan; it needed the Scale plan from 1.106.0 until 1.143.0);
        `defaultRevisionLimit` and the workload keys need
        an Agency plan or higher; a Studio workspace inside a running free
        trial (status `trialing`, trial end still ahead) passes every
        Agency-plan gate on this and every other `/api/v1` route, Require
        two-factor and 4K excepted, so it gets 200 where a paid Studio gets
        403 (1.224.2); `guestCanSchedulePosts` needs a plan with
        social posting — Studio, Agency, Scale or Enterprise — and a lower
        plan's 403 reads "Client scheduling requires a Studio plan or higher"
        (it named Agency before 1.158.1). Read-only settings (`downloadPolicy`,
        `archiveEnabled`, …) are rejected with 400. Returns the full updated
        settings.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateWorkspaceSettingsInput"
            examples:
              relaxEditors:
                summary: Let editors see all project tasks
                value:
                  editorSeeAllProjectTasks: true
              revisionCap:
                summary: Cap revisions at 3 (plan-gated)
                value:
                  defaultRevisionLimit: 3
      responses:
        "200":
          description: The updated workspace settings.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WorkspaceSettingsResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/workspace/ai-credits:
    get:
      tags: [Workspace]
      operationId: getAiCredits
      summary: Read the credits balance
      description: |
        The workspace's credits — what its transcription, AI work and WhatsApp
        notifications are paid in (1.141.0). `available` is what can be spent
        right now: every bucket plus the extra usage headroom, minus `held`
        (credits reserved by AI work still running); `availableWithoutOverage`
        leaves extra usage out. Both can be negative when running work reserved
        more than is left. "Extra usage" is what the app calls the bucket the
        fields name `overage` (1.173.0 — the names of the fields are unchanged).

        Buckets are spent in this order: `base` (the plan's included credits
        for the month),
        `committed` (reads 0),
        `lots`
        (extra credits granted by Timeliner, kept past the reset until used or
        expired), then `overage` — extra usage (only while switched on, up to
        its per-cycle `cap`; `amountUsd` is this cycle's extra usage bill so
        far). A cycle is the workspace's own credit month (1.228.2): it runs
        from one billing date of the workspace's subscription to the next —
        the day of the month the subscription renews, an annual plan's too,
        counted in UTC — and `resetsAt`, when the included credits reset, is
        the next billing date. A workspace with no billing date (one that pays
        Timeliner directly) keeps the UTC calendar month. In the one cycle a
        workspace moves onto its billing date, `cycleStart` stays where that
        cycle began and only `resetsAt` moves, so that cycle runs longer or
        shorter than a month, once.

        `usage` is this cycle's INCLUDED credits (base + committed) used:
        `percentUsed` (whole percent, `null` with no included credits) and
        `alertThreshold` — `75`, `90` or `100` once that alert level is
        crossed. Once blocking is switched on, the workspace's admins are
        emailed at each level.

        **Since 1.145.0** the plan's monthly base is given in credits
        (`included.credits`), and `rateCard.prices` carries the price sheet.
        The v1 `edits` / `transcriptionMinutes` / `checks` counts are gone.
        An AI edit costs `editJobCredits` plus a price per FINISHED second
        (`editFirstMinutePerSecond` for seconds 1–60,
        `editToThreeMinutesPerSecond` to 3 minutes, `editBeyondPerSecond`
        after), and `editExtraRawMinute` for every raw-footage minute beyond
        `editRawMinutesPerFinishedMinute` per finished minute (at least
        `editMinIncludedRawMinutes`); versions of an approved edit and
        AI-generated shots are priced on the same sheet. `creditsPerEdit` is
        now the price of a 60-second edit.
        AI checks are priced on the same sheet (`checkRunCredits`,
        `checkPerMinute`, `checkRecheckShare`), and `creditsPerCheck` is the
        price of an AI check of a 1-minute video.
        AI thumbnails (`thumbnail`, `thumbnailSet`) and Drive editing proxies
        (`driveProxyPerHour`) are priced there too.

        **Since 1.170.0** every paying workspace can read it — a trial
        included — once Timeliner has switched credits on: no allowlist and no
        key-creator check. A sandbox, a workspace whose billing is locked
        (blocked, canceled or awaiting its first checkout), or any workspace
        while credits are not switched on yet gets `403` with
        `code: ai_credits_unavailable`. Needs `read:finance`: the balance
        carries the workspace's credits bill and prices. The example's numbers
        are illustrative, not a price list.

        **Since 1.175.0** `rateCard.prices.whatsAppMessage` is what one
        WhatsApp notification costs (a workspace invitation is free): it is
        charged when WhatsApp accepts the message, and, once blocking is
        switched on, a workspace whose credits cannot cover it gets its
        WhatsApp notifications paused while email and in-app notifications
        still go out.

        **Since 1.226.0** `rateCard.prices.xPost` is what one post to X
        costs, and `rateCard.prices.xPostWithLink` what one whose text carries
        a link costs: charged when X accepts the post, never for one X refused
        or did not clearly answer. Once blocking is switched on, an X post the
        workspace's credits cannot cover is not sent and fails with the
        out-of-credits reason.

        **Since 1.179.0** the balance answers on every deployment, and
        `rateCard` carries only the prices of what that deployment offers: a
        price for something this deployment does not offer is left out of
        `rateCard` and `rateCard.prices` (it is never 0), so read a price key
        only when it is present. `committed` and `committedBlocks` read 0 where
        no top-up applies.

        **Since 1.228.2** the cycle follows the workspace's billing date
        instead of the 1st of the month (above): `cycleStart` and `resetsAt`
        are the workspace's own dates, and every per-cycle figure — the
        buckets, `usage`, the extra usage `cap` and its bill `amountUsd` —
        counts over that cycle. The response's shape is unchanged.
      responses:
        "200":
          description: The credits balance.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AiCreditsResponse"
              examples:
                default:
                  value:
                    data:
                      cycleStart: "2026-10-15T09:30:00+00:00"
                      resetsAt: "2026-11-15T09:30:00+00:00"
                      available: 7500
                      availableWithoutOverage: 7500
                      held: 1500
                      included: { credits: 10000, committedBlocks: 0 }
                      base: { granted: 10000, used: 3000, remaining: 7000 }
                      committed: { granted: 0, used: 0, remaining: 0 }
                      lots: { remaining: 2000, count: 1, nextExpiresAt: null }
                      overage: { enabled: false, cap: null, used: 0, headroom: 0, amountUsd: 0 }
                      usage: { usedCredits: 3000, includedCredits: 10000, percentUsed: 30, alertThreshold: null }
                      rateCard:
                        creditUsd: 0.01
                        transcriptionCreditsPerMinute: 2
                        creditsPerEdit: 960
                        creditsPerCheck: 250
                        overageUsdPerCredit: 0.01
                        prices:
                          editJobCredits: 300
                          editFirstMinutePerSecond: 11
                          editToThreeMinutesPerSecond: 10
                          editBeyondPerSecond: 7
                          editIncludedRevisionRounds: 1
                          editRawMinutesPerFinishedMinute: 10
                          editMinIncludedRawMinutes: 15
                          editExtraRawMinute: 10
                          versionAspectRatioPerSecond: 4
                          versionHookOrCta: 150
                          versionCutdownPerSecond: 6
                          versionCutdownMin: 120
                          versionMusicSwap: 60
                          versionCaptionLanguagePerSecond: 3
                          versionExtraRevisionPerSecond: 4
                          aiShot: 150
                          aiShotPremium: 500
                          aiStill: 30
                          checkRunCredits: 150
                          checkPerMinute: 100
                          checkRecheckShare: 0.5
                          thumbnail: 30
                          thumbnailSet: 90
                          driveProxyPerHour: 10
                          whatsAppMessage: 2
                          xPost: 2
                          xPostWithLink: 25
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: |
            Credits are not open to this workspace (`code:
            ai_credits_unavailable` — a sandbox, a locked workspace, or
            credits not switched on yet), or the key lacks `read:finance`
            (`code: insufficient_scope`).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: Credits are not available for this workspace
                code: ai_credits_unavailable
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/intake-forms:
    get:
      tags: [IntakeForms]
      operationId: listIntakeForms
      summary: List intake forms
      description: |
        Lists the workspace's intake (deliverable-request) forms — the
        Typeform-style request forms clients fill in to request work. Default form
        first. (Plan-gated feature.)
      responses:
        "200":
          description: The workspace's intake forms.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntakeFormList"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [IntakeForms]
      operationId: createIntakeForm
      summary: Create an intake form
      description: |
        Creates a new named intake form. `language` defaults to `en`. The first
        form (or `setAsDefault: true`) becomes the workspace default. The questions
        and catalog are then built in the app. (Plan-gated feature; supervisor+.)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateIntakeFormInput"
            examples:
              default:
                value:
                  name: New project intake
      responses:
        "201":
          description: The created intake form.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntakeFormResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/intake-forms/{id}:
    get:
      tags: [IntakeForms]
      operationId: getIntakeForm
      summary: Retrieve an intake form
      description: |
        Returns one form in full: its `sections` toggles, the `questions` builder,
        the catalog `items` (deliverables with prices/badges), and the
        post-submission `settings`.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: The intake form's UUID.
      responses:
        "200":
          description: The intake form.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IntakeFormDetailResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/automation-rules:
    get:
      tags: [Automations]
      operationId: listAutomationRules
      summary: List Automations Center rules
      description: |
        Returns the workspace's Automations Center rules — the "when X happens,
        do Y" board rules — in the order they execute, plus
        `automationsCenterEnabled`, the master toggle (while it is `false`,
        every rule is stored but dormant).

        Triggers cover status/stage changes, the posting time being scheduled
        (`publishDateScheduled`), a date custom column being set
        (`dateColumnSet`), version uploads (`versionUploaded`, optionally
        conditioned on duration/orientation), and review comments landing
        (`commentAdded` — optionally only client or team comments, or only
        comments that @-mention someone; 1.80.0), and a rule's own inbound URL
        being called (`inboundHook` — the catch hook; see
        `POST /api/hooks/automations/{token}`; 1.80.0), and a deadline being N
        days away (`deadlineApproaching` — evaluated hourly, once per deadline
        value, date-anchored on the deadline's day; 1.80.0). Under the date-anchored
        triggers, the date actions' `offsetDays` count from the ANCHOR date
        (negative = before it) — the backward-scheduling recipe.

        **Not** `/api/v1/automations`, which returns the review/workflow timeout
        settings. Requires an Agency plan or higher.

        Rules whose trigger type postdates this API version are omitted from
        the list rather than partially described (1.49.1).

        Each rule carries `brandId`: `null` for a workspace-global rule, or the
        brand (Node) it is scoped to. A brand-scoped rule runs only on that
        brand's tasks, and only when the brand's own automation mode admits it
        — so an `enabled` brand rule can still be dormant, exactly as any rule
        is while `automationsCenterEnabled` is `false` (1.70.0).

        Rules also carry `hqBoardId`: non-null for a HEADQUARTERS BOARD rule,
        which runs on that internal board's items rather than on client work.
        Board rules use a separate vocabulary — every trigger and action name
        starts with `hq` — and the two never mix inside one rule. `brandId` and
        `hqBoardId` are mutually exclusive: an HQ board belongs to the
        workspace, not to a client (1.76.0).
      parameters:
        - name: brandId
          in: query
          required: false
          description: |
            Narrow the list to one scope. A brand id returns only that brand's
            rules; the literal `none` returns only the workspace-global set.
            Omit to return every scope, which is what this endpoint returned
            before per-brand rules existed.
          schema:
            type: string
            example: "3f1c9a52-8d4e-4b7a-9c21-6e5f0a7b2c3d"
        - name: hqBoardId
          in: query
          required: false
          description: |
            Narrow the list to one HQ board's rules. A board id returns only
            that board's rules; the literal `none` returns only the deliverable
            (non-board) rules. Omit to return every scope. (1.76.0)
          schema:
            type: string
            example: "8a2d5c31-7e94-4f6b-a1c8-0d3e2b9f4a76"
      responses:
        "200":
          description: The workspace's automation rules, in execution order.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationRulesResponse"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Automations]
      operationId: createAutomationRule
      summary: Create an Automations Center rule
      description: |
        Creates one rule. A full-scope API key acts as the admin who minted it
        (same trust model as the webhooks CRUD); read-only keys are rejected.
        Validation is identical to the in-app builder — referential checks
        (columns, options, members, templates), the per-rule action-conflict
        guard, and the self-trigger guard (a `dateColumnSet` rule may not
        `setDateColumn` its own trigger column; a `publishDateScheduled` rule
        may not `setPostingTime`). `setPostingTime` additionally requires a
        plan with social distribution (Enterprise, Agency, or Scale).

        The workspace rule ceiling is plan-dependent — 50 rules on Scale (and
        Enterprise/Custom contracts), 25 on every other plan — with up to 20
        actions per rule; pack a
        recipe into one rule rather than one rule per action. An exact
        duplicate of an existing rule (same trigger + actions) returns `409`,
        so retries are safe. The created rule only RUNS while
        `automationsCenterEnabled` (returned in the response) is `true`.
        Requires an Agency plan or higher and active billing.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AutomationRuleInput"
      responses:
        "201":
          description: The created rule + the master-toggle state.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationRuleWriteResponse"
        "400":
          description: >-
            Validation failed. `error` is the same sentence the in-app builder
            shows. A refusal the caller cannot fix by changing the payload
            also carries a machine-readable `reason` (1.108.0) — today only
            `slack_not_connected`: the rule has a `postToSlack` or
            `sendReviewLinkToSlack` action and the workspace's Slack is not
            connected (a person connects it in
            Settings → Integrations; retrying the same call will not help).
            Every other validation error has no `reason`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationRuleValidationError"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "409":
          description: >-
            The workspace's rule cap is reached (50 on Scale/Enterprise, 25
            otherwise), or an identical rule already exists. The error message
            names the cap that applied.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/automation-rules/{id}:
    patch:
      tags: [Automations]
      operationId: updateAutomationRule
      summary: Update an Automations Center rule
      description: |
        Edits a rule. Recipe edits must send BOTH `trigger` and `actions`
        (they are validated as a whole); `enabled` may be sent alone.
        Enabled-only changes work on any plan — a downgraded workspace can
        still turn rules off; recipe edits require an Agency plan or higher
        and active billing.

        Since 1.188.0 `enabled: true` alone is refused with a 400 while the
        rule is off and a stage it uses, or the date field it watches, has
        been deleted: such a rule could only fail. Send a recipe naming a
        stage or date field that exists, then turn it on. A rule that is
        already on is not refused and can always be turned off, and a deleted
        date field the rule only sets does not block anything.
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string, format: uuid }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AutomationRuleUpdateInput"
      responses:
        "200":
          description: The updated rule + the master-toggle state.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationRuleWriteResponse"
        "400":
          description: >-
            Validation failed. `error` is the same sentence the in-app builder
            shows. A refusal the caller cannot fix by changing the payload
            also carries a machine-readable `reason` (1.108.0) — today only
            `slack_not_connected`: the rule has a `postToSlack` or
            `sendReviewLinkToSlack` action and the workspace's Slack is not
            connected (a person connects it in
            Settings → Integrations; retrying the same call will not help).
            Every other validation error has no `reason`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationRuleValidationError"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Automations]
      operationId: deleteAutomationRule
      summary: Delete an Automations Center rule
      description: |
        Permanently deletes a rule (its run history is kept; armed delay
        timers are cancelled). Works on any plan. To pause a rule instead,
        PATCH `enabled: false`.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string, format: uuid }
      responses:
        "204":
          description: Deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/automation-flows:
    get:
      tags: [Automations]
      operationId: listAutomationFlows
      summary: List automation flows
      description: |
        Returns the workspace's Automation Studio flows — the visual
        multi-step automations (waits, If/else branches, goals, splits and
        HQ ↔ workspace steps) — newest first. Each flow carries a
        plain-English `summary` and `triggers` with the workspace's own
        names resolved, and 7-day `activity`. `flowsPaused` is `true` when
        every flow is held from the workspace settings, whatever its own
        status (1.138.0).

        Classic single-step rules are `/api/v1/automation-rules`. Requires an
        Agency plan or higher.
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum: [draft, published, paused, dormant]
          description: Only flows in this state.
      responses:
        "200":
          description: The flows.
          content:
            application/json:
              schema:
                type: object
                required: [data, flowsPaused]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/AutomationFlow"
                  flowsPaused:
                    type: boolean
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Automations]
      operationId: createAutomationFlow
      summary: Create an automation flow (draft)
      description: |
        Creates a flow as a DRAFT. A draft never runs: a person publishes it
        in Timeliner after its safety checks (there is deliberately no
        publish operation in the API — agents draft, people ship). The
        response's `check` lists everything that would block publishing, so
        the caller can fix the draft with `PATCH /api/v1/automation-flows/{id}`
        first (1.138.0).

        A graph whose shape is wrong is not saved: a 400 whose `error` starts
        `graph is malformed:` and names each path, for example
        `shape (triggers.0.filters.conditions): missing (expected array)`.
        A well-formed graph with findings is saved, and `check` lists them
        (1.189.2).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AutomationFlowWriteInput"
      responses:
        "201":
          description: The draft flow and its publish check.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationFlowWriteResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/automation-flows/validate:
    post:
      tags: [Automations]
      operationId: validateAutomationFlow
      summary: Validate an automation flow graph
      description: |
        Runs every check publishing runs — structure, loops (every loop must
        wait at least an hour each time round), availability, references to
        columns / members / boards, message safety, and conflicts with the
        workspace's live automations — on a graph WITHOUT saving anything,
        and returns the plain-English outline the graph reads as. Pass
        `flowId` when validating a new version of an existing flow (it is
        then left out of the conflict check). Writes nothing; it is a POST
        only because the graph travels in the body, so it needs a key that
        may write (1.138.0).

        A graph whose shape is wrong gets a 400 whose `error` starts
        `graph is malformed:` and names each path, for example
        `shape (triggers.0.filters.conditions): missing (expected array)`.
        Everything else, including an action type flows do not offer,
        answers 200 with `canPublish: false` and its findings (1.189.2;
        wording 1.227.1).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [graph]
              properties:
                graph:
                  $ref: "#/components/schemas/AutomationFlowGraph"
                flowId:
                  type: string
                  format: uuid
      responses:
        "200":
          description: The check and the outline.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    allOf:
                      - $ref: "#/components/schemas/AutomationFlowCheck"
                      - type: object
                        required: [summary, outline]
                        properties:
                          summary:
                            type: string
                          outline:
                            type: array
                            items:
                              type: string
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/automation-flows/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
    get:
      tags: [Automations]
      operationId: getAutomationFlow
      summary: Get an automation flow
      description: |
        One flow: `draftGraph` (the exact graph the builder edits),
        `publishedGraph` (what runs now; `null` if never published), a
        plain-English `outline`, 7-day `activity` and `check` — what still
        blocks publishing (1.138.0).
      responses:
        "200":
          description: The flow.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/AutomationFlowDetail"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Automations]
      operationId: updateAutomationFlow
      summary: Update an automation flow draft
      description: |
        Renames or re-describes the flow and/or REPLACES its draft graph.
        Never touches what runs: a published flow keeps running its
        published version until a person publishes again. Pass
        `expectedDraftUpdatedAt` (the `draftUpdatedAt` you last read) to get
        a 409 instead of overwriting someone's edits. An archived flow
        cannot be edited (409) (1.138.0).

        A graph whose shape is wrong gets a 400 naming each path, and the
        draft stays as it was (1.189.2). The check is stricter than the
        builder's save: a draft holding an extra trigger key, or a
        fixed-list condition value the app no longer offers, must be fixed
        before it can be sent back.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AutomationFlowUpdateInput"
      responses:
        "200":
          description: The flow and its publish check.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationFlowWriteResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/automation-flows/{id}/status:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
    post:
      tags: [Automations]
      operationId: setAutomationFlowStatus
      summary: Pause or resume an automation flow
      description: |
        `pause` stops new tasks entering a live flow; tasks already waiting
        in it hold and continue on `resume`. On resume, only waits that fell
        due in the last 48 hours re-arm — older ones exit instead of
        delivering late. Resume cannot publish a draft (409) (1.138.0).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [action]
              properties:
                action:
                  type: string
                  enum: [pause, resume]
      responses:
        "200":
          description: The flow after the change.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/AutomationFlow"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/automation-flows/{id}/runs:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
    get:
      tags: [Automations]
      operationId: listAutomationFlowRuns
      summary: List an automation flow's runs
      description: |
        The flow's latest enrollments (one task or HQ card travelling
        through it), newest first, each with its step outcomes and skip
        codes (1.138.0).
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 20
      responses:
        "200":
          description: The runs.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/AutomationFlowRun"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/automations:
    get:
      tags: [Automations]
      operationId: getAutomations
      summary: Read workspace automations
      description: |
        Returns the workspace automations: `reviewWorkflow` (the writable
        review/workflow timeouts) and `notifications` (the read-only quiet /
        batch / catch-up notification automations — change those in-app).
      responses:
        "200":
          description: The workspace automations.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationsResponse"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Automations]
      operationId: updateAutomations
      summary: Update review/workflow automations
      description: |
        Changes one or more review/workflow automations. Minutes: `0` = off.
        Guest windows: `0` = off, `-1` = forever, else minutes. The notification
        automations (quiet/batch/catch-up) are read-only here. Returns the full
        updated automations.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateAutomationsInput"
            examples:
              autoSubmit:
                summary: Auto-submit uploads for review after 30 min
                value:
                  autoSubmitForReviewTimeout: 30
      responses:
        "200":
          description: The updated automations.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AutomationsResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/activity:
    get:
      tags: [Tasks]
      operationId: listTaskActivity
      summary: Read a task's activity / status timeline
      description: |
        The task's full event history: created, moved between statuses, field
        changes (title, assignees, deadlines, custom fields…), new version
        uploaded, commented, viewed, downloaded. Returned **oldest first**, so it
        reads as a timeline: when the task entered revision, when it went to
        approval, when it was sent to the client, and who did each.

        **Every channel is listed (since 1.215.0).** Creates, moves and field
        changes made through this API, through MCP and by workspace automations
        are included — the same events the task's History panel shows in the
        app. Before 1.215.0 only changes made in the app were returned. Each
        entry's `source` says which door it came through (`app`, `api`, `mcp`,
        `automation`, `share`, `cron`, `system`; `null` = not recorded, e.g. a
        view or a comment). A move made in the app is listed once.

        Entries read from the task's change history (their `id` starts with
        `th-`) name the status with today's label and carry no role snapshot
        (`actor.role` is `null`); `targetName`, `projectName` and `brandName`
        on them are today's names. That history starts on 2026-09-22 for moves
        and 2026-10-09 for creation, so older tasks list only what the app
        logged. Price, team pay and pricing-template changes are listed only for
        a key with `read:finance`.

        **Durations are yours to compute, on purpose.** "How long the editor
        took" is the gap between two consecutive `moved` entries, and only your
        report knows whether that should count weekends, business hours, or
        repeat visits to the same status. Take the timestamps and subtract.

        **Key on `movedFromStatusKey` / `movedToStatusKey`, not on the labels.**
        `movedFrom` / `movedTo` are the status names as they read at the time and
        a workspace can rename a status; the `*StatusKey` fields are stable. Both
        are `null` on entries that are not status moves, and on entries recorded
        before status history was captured.

        Use `limit` (default 200, max 500) with `from` / `to` to window the
        result. The newest entries are always the ones kept: when `hasMore` is
        `true` there are OLDER entries than this window covers — page back by
        passing `to=` the oldest `createdAt` you received.
      parameters:
        - $ref: "#/components/parameters/TaskId"
        - name: limit
          in: query
          description: |
            Max entries to return. Default 200, values above 500 are clamped to
            500 (not rejected). When the task has more, the most RECENT `limit`
            are returned and `hasMore` is `true`.
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 200
        - name: action
          in: query
          description: |
            Return only this kind of entry. `moved` alone is the status history —
            the usual filter for a report, and far smaller than the full feed
            (`viewed` entries outnumber everything else). `changed` alone is the
            field changes (since 1.215.0).
          schema:
            type: string
            enum:
              [
                viewed,
                downloaded,
                deleted,
                created,
                newVersion,
                moved,
                commented,
                discussed,
                captionEditedAfterApproval,
                settingsChanged,
                postTextEdited,
                restored,
                permanentlyDeleted,
                postScheduleChanged,
                commentDeleted,
                changed,
              ]
        - name: from
          in: query
          description: Only entries at or after this instant (ISO-8601).
          schema:
            type: string
            format: date-time
        - name: to
          in: query
          description: |
            Only entries at or before this instant (ISO-8601). Also how you page
            backwards through a task with more history than `limit`.
          schema:
            type: string
            format: date-time
      responses:
        "200":
          description: The task's activity entries, oldest first.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ActivityEntryList"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: |
            The key has no Tasks access (`code: insufficient_scope`,
            `requiredScope: read:tasks`). Since 1.111.1 — before that this
            endpoint alone answered a scope refusal (and a rate-limit refusal)
            with `401 Invalid or missing API key`, as if the key were invalid.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: This API key does not have the read:tasks scope
                code: insufficient_scope
                requiredScope: read:tasks
                grantedScopes: [read:projects]
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/events:
    get:
      tags: [Tasks]
      operationId: listRecentEvents
      summary: List recent events
      description: |
        What happened in the workspace recently, **oldest first**: a new
        version uploaded to a task (`version.uploaded`), a comment added
        (`comment.created`) and a task approved (`task.completed`). Each item is
        the exact `WebhookEnvelope` a webhook subscriber to that event receives,
        same `id` included — so a system using both can dedupe on it.

        Built for a client that cannot receive a webhook — an AI assistant
        checking on a schedule (a Claude routine, a ChatGPT task) through the
        Timeliner MCP connector (`list_recent_events`), or a script on a timer.
        No webhook subscription is needed.

        **Resuming.** Keep the `nextCursor` from each response and pass it back
        as `cursor` on the next check: the page continues exactly after the last
        event you received, never repeating one. `nextCursor` is returned even
        on the last page, and echoed back when nothing new arrived. Without a
        cursor, `since` sets the start (inclusive); the default is 24 hours ago.
        `hasMore: true` means more events already exist — call again with
        `nextCursor` right away.

        **What is kept.** Events are recorded from the release of this endpoint
        (1.133.0) onward — nothing earlier is backfilled — and only while the
        workspace holds at least one API key. Nothing older than 30 days is
        returned; an older `since` is raised to that limit rather than refused.

        **Team-only comments are included** (`data.visibility: team`), exactly
        as a `comment.created` webhook carries them: never forward those to a
        client. Since 1.133.0.
      parameters:
        - name: since
          in: query
          description: |
            Return events at or after this instant (ISO-8601). Ignored when
            `cursor` is given. Default: 24 hours ago. Clamped to the last 30
            days.
          schema:
            type: string
            format: date-time
          example: "2026-10-15T08:00:00Z"
        - name: types
          in: query
          description: |
            Only these event types, comma-separated (or the parameter repeated).
            Default: all three.
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
              enum: [version.uploaded, comment.created, task.completed]
        - name: limit
          in: query
          description: Events per page, 1-100.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: cursor
          in: query
          description: |
            The `nextCursor` from a previous response, passed back verbatim
            (opaque — never build or parse it). Continues strictly after the last
            event that response returned.
          schema:
            type: string
      responses:
        "200":
          description: One page of the workspace's recent events, oldest first.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecentEventsPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: |
            The key has no Tasks access (`code: insufficient_scope`,
            `requiredScope: read:tasks`).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: This API key does not have the read:tasks scope
                code: insufficient_scope
                requiredScope: read:tasks
                grantedScopes: [read:projects]
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/time-entries:
    get:
      tags: [Tasks]
      operationId: listTimeEntries
      summary: List time entries
      description: |
        Every time entry tracked in the workspace, **one row per entry**, each
        carrying its task, project and brand (ids and names), who tracked it
        (`memberId`), whether it came from the timer or was added by hand, its
        start, end and `durationSeconds`, and its note. Running timers are
        included (`running: true`, `endedAt: null`; `durationSeconds` is the
        time saved before the current run, which started at `startedAt`). No
        pay, rate or money field. MCP tool `list_time_entries`. Since 1.207.0.

        **Order and syncing.** Rows come back by their last change, oldest
        first: `updatedAt` (then `id`) for a live entry, `deletedAt` for a
        deleted one. Keep the `nextCursor` from each response and pass it back
        as `cursor`: the next page continues exactly after the last row you
        received, never skipping or repeating one. `nextCursor` is returned even
        on the last page, and echoed back when nothing changed. Without a
        cursor, `updatedSince` (inclusive) sets the start. `hasMore: true` means
        more rows already exist — call again with `nextCursor` right away.

        **Deleted entries.** With `includeDeleted=true`, entries deleted at or
        after `updatedSince` (or after the cursor) come back in the same stream
        as `{ id, taskId, projectId, brandId, memberId, deleted: true,
        deletedAt }` rows. Deletions are recorded from 1.207.0 onward. An entry
        removed because its whole task was permanently deleted is listed too;
        entries removed with a permanently deleted project or brand are not.
        Entries that existed before 1.207.0 carry that release time as their
        `updatedAt`.

        Filters combine (AND). An id from another workspace matches nothing.
        `from` / `to` narrow live entries by `startedAt` only.
      parameters:
        - name: taskId
          in: query
          description: Only entries on this task.
          schema:
            type: string
            format: uuid
        - name: projectId
          in: query
          description: Only entries on this project's tasks.
          schema:
            type: string
            format: uuid
        - name: brandId
          in: query
          description: Only entries on tasks in projects directly under this brand.
          schema:
            type: string
            format: uuid
        - name: memberId
          in: query
          description: Only entries tracked by this workspace member.
          schema:
            type: string
            format: uuid
        - name: from
          in: query
          description: |
            Entries started at or after this date or instant (ISO-8601). Does
            not narrow deleted rows.
          schema:
            type: string
          example: "2026-11-01"
        - name: to
          in: query
          description: |
            Entries started at or before this date or instant (ISO-8601); a date
            alone covers the whole day. Does not narrow deleted rows.
          schema:
            type: string
          example: "2026-11-30"
        - name: updatedSince
          in: query
          description: Only entries changed (or, with `includeDeleted`, deleted) at or after this instant (ISO-8601).
          schema:
            type: string
            format: date-time
          example: "2026-11-01T08:00:00Z"
        - name: includeDeleted
          in: query
          description: "Also return deleted entries as `deleted: true` rows."
          schema:
            type: boolean
            default: false
        - name: limit
          in: query
          description: Rows per page, 1-100.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: cursor
          in: query
          description: |
            The `nextCursor` from a previous response, passed back verbatim
            (opaque — never build or parse it). Continues strictly after the last
            row that response returned.
          schema:
            type: string
      responses:
        "200":
          description: One page of time entries, oldest change first.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TimeEntriesPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          description: |
            The key has no Tasks access (`code: insufficient_scope`,
            `requiredScope: read:tasks`).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: This API key does not have the read:tasks scope
                code: insufficient_scope
                requiredScope: read:tasks
                grantedScopes: [read:projects]
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/comments:
    get:
      tags: [Tasks]
      operationId: listTaskComments
      summary: List a task's comments
      description: |
        Returns the task's review thread — team/authed comments AND anonymous
        client comments (from share links), merged oldest-first. `isGuest` is
        true for client/guest comments — an anonymous share-link comment, or a
        comment a signed-in guest posted in the app; `timecode` is the video
        position in seconds (or `null` for a general comment).

        Since 1.111.0 each comment also carries what was attached and drawn:
        `attachments` (name, type, size and a presigned `downloadUrl` valid
        7 days — fetch it to see the image or file; `removed: true` and no
        link once a cancelled workspace's media was purged) and `drawings`
        (each annotation's type, color, PDF page and normalized 0-1 `bounds`
        on the frame; arrows add `from` / `to`). A comment can be only a
        drawing or only an attachment, with empty `text`. Plus `endTimecode`
        (a range comment's end) and `fileId` (the version it was left on).

        **Full read (since 1.132.0)** — everything an editing or QC agent
        needs to act on a note without opening the app:

        - **Where:** `frames` (0-based frame numbers, the nearest frame at the
          version's real frame rate — the numbering the app's DaVinci Resolve /
          Final Cut marker export uses) and `smpte` (`HH:MM:SS:FF`,
          non-drop-frame), both `null` when there is no timecode or the
          version's frame rate is unknown. A backwards or zero-length range is
          a single point: `endTimecode` is never at or before `timecode`.
          `page` is a PDF comment's page.
        - **Which version:** `version` — file id, version number, whether it is
          the current one, media `kind`, width, height, duration and fps.
          `null` for a comment saved with no version: such a comment shows on
          every version of the task, it is not missing data.
        - **What is said in the video:** `transcriptExcerpt` — the words
          spoken during a range comment (a comment made by selecting words in
          the Transcript tab is one), rebuilt from the version's transcript,
          on a thread's first comment. Its `turns` split the words by speaker
          only when that transcript carries speaker labels: videos transcribed
          since 1.139.1 (October 2026) carry none, so their excerpt is one turn
          with `speaker: null`. A voice memo's
          `attachments[].transcript` is what the REVIEWER said; the excerpt is
          what is said IN THE VIDEO.
        - **Drawings:** every annotation with its geometry — normalized 0-1 to
          the picture the reviewer drew on, letterbox bars excluded, so
          `x × width` is the source pixel — plus `lineThickness` and
          `opacity`; circles add `center` / `radius`, pins `point`, freehand
          strokes their `points` (thinned to at most 128).
        - **Who and how:** `mentions`, `visibility` (`public` = clients see it,
          `team` = internal), `editedAt`, `textAnchor` (a document or caption
          comment's quoted passage) and `postPlatform`.

        **Filters (since 1.132.0).** `version` (`current`, or a version's file
        id — another task's or an unknown file id → `404`), `resolved`
        (`open` / `resolved`) and `sort` (`created` / `timecode`). Filters
        decide per thread: a reply goes wherever its thread's first comment
        goes. An invalid value → `400`.

        **Voice memos (1.138.0).** A voice memo is an attachment whose
        `mimeType` is `audio/*`; its `transcript` is null until generated —
        `POST /api/v1/tasks/{id}/comments/voice-memos/transcribe` fills every
        memo on the task in one call, and
        `POST /api/v1/tasks/{id}/comments/{commentId}/attachments/{attachmentId}/transcript`
        one memo. Call it before acting on a thread: voice memos are the most
        common notes, and a memo-only comment has empty `text`.

        **AI notes (1.137.0).** A comment an AI wrote says so:
        `authorKind` is `ai` (else `team` or `guest`), `agentName` is the
        name it is signed with — `Ronald` (the editor of the Timeliner
        editing service; also on notes written earlier, which read
        `Timeliner Editor` before 1.152.0; see **Ronald's notes are
        staff-only** below), `Smith` (Timeliner's AI check; also on earlier
        notes, which read `Timeliner Supervisor` before 1.168.0; see
        **Smith's notes are staff-only** below), or an
        outside AI's own `aiLabel` (see the POST) — and `ai` carries its
        `source`, `kind`, `severity` and `extraRanges`. To tell Timeliner's
        own AI apart, match `ai.source` (`editor` / `supervisor`), never
        `agentName`. `author=ai` returns only AI notes, `author=human` only
        people's comments; unlike the other filters it decides per COMMENT
        (an AI reply under a person's thread comes back for `author=ai`),
        after the order is built.

        **Smith's notes are staff-only (1.172.0).** While the AI check is a
        staff beta, a note Smith wrote, and every reply under one, is left out
        of this list and of `GET /api/v1/tasks/{id}/comments/{commentId}` (a
        `404`, as for a comment of another task); a `parentId` naming one, a
        resolve of one and a voice-memo transcript of one are a `404` too, the
        batch transcription skips them, no `comment.created` is sent for one,
        and the events feed (`GET /api/v1/tasks/events`) leaves out any it
        recorded earlier.

        **Ronald's notes are staff-only (1.178.0).** Ronald's notes are left
        out exactly like Smith's: a note or reply he wrote, and every reply
        under a note of his, is missing from this list and from the single
        read (a `404`); a `parentId` naming one, a resolve of one and a
        voice-memo transcript of one are a `404`; the batch transcription
        skips them; no `comment.created` is sent for one; and the events feed
        leaves out any it recorded earlier. His lines in the task chat are
        left out of `GET /api/v1/tasks/{id}/chat` too. An API key is never
        Timeliner staff, so this holds for every key.

        The task's **chat** is a separate, internal surface and never appears
        here (nor do replies to it). Read it at
        `/api/v1/tasks/{id}/chat`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
        - name: version
          in: query
          required: false
          description: >-
            Only the threads on this version: `current` (the task's current
            version — every comment on a task with no file) or a version's
            file id (`version.fileId`). Comments saved with no version belong
            to every version and always come back.
          schema:
            type: string
          examples:
            current:
              value: current
        - name: resolved
          in: query
          required: false
          description: Only open threads, or only resolved ones. Omit for both.
          schema:
            type: string
            enum: [open, resolved]
        - name: sort
          in: query
          required: false
          description: >-
            `created` — oldest first (the default); `timecode` — timeline order
            by each thread's first comment (untimed threads last), each reply
            right under its thread.
          schema:
            type: string
            enum: [created, timecode]
        - name: author
          in: query
          required: false
          description: >-
            `ai` — only AI notes (`authorKind: ai`); `human` — only people's
            comments, clients included. Decided per comment (since 1.137.0).
          schema:
            type: string
            enum: [ai, human]
      responses:
        "200":
          description: The task's comments.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CommentList"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Tasks]
      operationId: createTaskComment
      summary: Post a comment on a task
      description: |
        Posts a comment on the task's review thread, authored by the API key's
        creator (`created_by`). Silent unless `notify: true` — no `@mentions`
        are parsed, so no mention notification fires. Returns the created
        comment.

        Client visibility follows the author's workspace role, exactly like an
        in-app comment: a comment posted with an admin- or supervisor-created
        key is **public** by default (clients see it on the portal and share
        pages); an editor-created key posts an **internal** comment
        (team-only). Since 1.137.0 `visibility` asks for either side, still
        within the role's lock: an admin or supervisor key may choose either,
        an editor key gets `public` only where the workspace lets editors post
        publicly, a guest key is always `public`. The response's `visibility`
        is what was saved.

        **Where (1.137.0).** `fileId` picks the version (another task's or an
        unknown file → `404`); `timecode` (seconds) makes a timeline note on a
        video or audio version — `400` on any other version — and
        `endTimecode` a range; `drawings` mark the picture in the SAME shape
        the read endpoints return (`type` pin / rectangle / circle / arrow /
        freehand, normalised 0-1 on the picture with the letterbox excluded,
        optional `color` `#RRGGBB`, `lineThickness` 1-20, `opacity`), and
        `page` puts them on a PDF page. A value outside 0-1 is a `400` —
        never clamped. Limits: `text` 10,000 characters, 20 drawings, 500
        points per freehand stroke, timecodes 0-86,400 s.

        **Notify (1.137.0).** `notify: true` tells the task's assigned editors
        a comment was added — the same opt-in notification an in-app comment
        sends them (their notification settings decide the channels; an
        internal comment never reaches a guest).

        **Replies to Ronald (1.171.0).** A `parentId` reply by a team member's
        key under a note where Ronald asks (`ai.source` `editor`, and a
        question or a note that tags someone) is his answer: it resumes or
        starts his work on the task, after the response. While the task is in
        review (out of To Do, In Progress and In Revision) nothing starts: he
        replies once in that thread and reads the answer when the task moves
        to In Revision. A reply under any other note of his, or under a
        resolved thread, starts nothing; his next round still reads a reply
        under an open note. The request, the response and the
        status codes do not change, and no `@mention` is parsed.

        **AI notes — bring your own AI (1.137.0).** When the caller is an AI
        reviewing the work, `aiLabel` (its name: one line of plain text, up to
        40 characters, never a name starting with "Timeliner" and never
        "Ronald" or "Smith" — Ronald and Smith are Timeliner's own AI, and
        both are refused with a `400`: "Ronald" since 1.152.0, "Smith" since
        1.168.0) posts an **AI
        note**: the app shows it with an AI badge, signed with that name, and
        the team's AI notes summary ranks it by `aiSeverity` (`mustFix` /
        `suggestion` / `note`); `extraRanges` (up to 20 `{start, end}` in
        seconds, beside the note's own `timecode`) lists more places it
        applies. An AI note is ALWAYS **internal** (`team`) —
        `visibility: public` beside `aiLabel` is a `400`, and a key whose
        person is a client (guest) gets `403`. It is ALWAYS silent —
        `notify: true` beside `aiLabel` is a `400` — and never runs the
        workspace's "When a comment is added" automations; it does send the
        `comment.created` webhook, marked `authorKind: ai` with the label as
        `agentName` (`authorId` / `authorName` stay the key's person), so an AI
        reacting to new comments can skip its own. `aiSeverity` and a
        non-empty `extraRanges` without `aiLabel` → `400`; an empty
        `extraRanges` reads as none, so a plain comment carrying it posts
        (1.187.1).

        **Budget (1.137.0).** Posting is metered per key and per workspace —
        60 comments per minute per key, 2,000 per 24 h per key and 5,000 per
        24 h per workspace — on top of the key's general request limit. Every
        POST counts (a `400` too, an AI note, a reply, a `notify: true` post
        alike). Past any window the call is `429` with `Retry-After` and
        nothing is posted or sent: wait that long, never retry in a loop.

        **Version (1.126.2).** A new top-level comment is left on the task's
        CURRENT version — the returned `fileId` — exactly like a comment left in
        the app while that version is on screen, so it stays with that version
        and does not appear on versions uploaded later. A task with no file
        (a document or parent task, or nothing uploaded yet) returns
        `fileId: null`, and such a comment shows on every version. Before
        1.126.2 every top-level comment was saved with `fileId: null`.

        **Replies (since 1.111.0).** Pass `parentId` — any review comment on
        the SAME task, a team comment or a client's share-link comment — to
        reply inside its thread: the reply shows nested under it in the app
        and inherits its type, timecode and version. Threads are one level
        deep, so a reply to a reply joins that thread's first comment. A reply
        follows the thread's visibility, still clamped by the author's role
        (an editor-created key stays internal) — and stays internal when the
        comment it answers is an internal reply. A `parentId` that is not a
        review comment of this task (another task's, a chat post, unknown)
        → `404`. A reply sits in its thread, so `timecode`, `endTimecode`,
        `fileId`, `drawings` and `page` beside `parentId` → `400`.

        **A reply's visibility (1.146.0).** `visibility` beside `parentId`
        chooses the reply's own side instead of the thread's, within the same
        role lock: `team` posts an internal reply inside a client-visible
        thread (clients see the thread, never that reply). `public` inside an
        INTERNAL thread is a `400` and nothing is posted — clients never see
        that thread, so post a new top-level comment to reach them. Before
        1.146.0 `visibility` beside `parentId` was a `400`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCommentInput"
            examples:
              default:
                value:
                  text: Looks great — approved on my end.
              reply:
                value:
                  text: Fixed in v2 — the logo now holds for the full 3 seconds.
                  parentId: 3f0c2a8e-5b1d-4c7a-9e2f-6d8b1a4c0e93
              internalReply:
                value:
                  text: "Internal: the client asked for this twice — keep the intro short."
                  parentId: 3f0c2a8e-5b1d-4c7a-9e2f-6d8b1a4c0e93
                  visibility: team
              timecodedWithPin:
                value:
                  text: The lower third covers the speaker's chin here.
                  timecode: 14.2
                  endTimecode: 16
                  visibility: team
                  notify: true
                  drawings:
                    - type: rectangle
                      bounds: { x: 0.1, y: 0.72, width: 0.5, height: 0.14 }
              aiNote:
                value:
                  text: The end card shows last year's price ($49) — the brief says $59.
                  timecode: 41.5
                  aiLabel: Acme Review Bot
                  aiSeverity: mustFix
                  extraRanges:
                    - { start: 12, end: 13.5 }
      responses:
        "201":
          description: The created comment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CommentResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/CommentBudgetExceeded"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/comments/{commentId}:
    get:
      tags: [Tasks]
      operationId: getTaskComment
      summary: Get one task comment with its replies
      description: |
        Returns ONE comment of the task's review thread — a team comment or a
        client's share-link comment — in the full `Comment` shape (see
        `GET /api/v1/tasks/{id}/comments`), plus `replies`: every reply in its
        thread, oldest first. A reply's own id returns that reply with
        `replies: []` (threads are one level deep). Since 1.132.0.

        A `commentId` that is not a review comment of this task (another
        task's, a chat post, unknown) → `404`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
        - name: commentId
          in: path
          required: true
          description: The comment's UUID — from `GET /api/v1/tasks/{id}/comments`.
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The comment and its replies.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CommentWithRepliesResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Tasks]
      operationId: resolveTaskComment
      summary: Resolve or reopen a task comment
      description: |
        Marks a review thread resolved (`resolved: true`) or reopens it
        (`resolved: false`) — the check box on the thread in the app — as the
        API key's creator. Works on a team comment or a client's share-link
        comment (since 1.111.0).

        Only a thread's first comment can be resolved: a reply → `400`. The
        key's user must be allowed to resolve comments, exactly as in the app
        (a guest viewer cannot) — `403` otherwise. A `commentId` that is not a
        review comment of this task (another task's, a chat post, unknown) →
        `404`. No notification or webhook fires.
      parameters:
        - $ref: "#/components/parameters/TaskId"
        - name: commentId
          in: path
          required: true
          description: The comment's UUID — from `GET /api/v1/tasks/{id}/comments`.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ResolveCommentInput"
            examples:
              resolve:
                value:
                  resolved: true
              reopen:
                value:
                  resolved: false
      responses:
        "200":
          description: The updated comment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CommentResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: |
            No review comment on this task has that id, and nothing was
            written. An unknown id, another task's or workspace's comment and a
            task-chat message all answer this same body: they are deliberately
            indistinguishable, and no body echoes the id back. Since 1.169.0
            the body carries `"reason": "comment_not_found"`. Get the id again
            (`GET /api/v1/tasks/{id}/comments`, on this same task) and send all
            36 characters. A `404` naming the task (`Task not found`) means the
            task id is the wrong one.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaskCommentResolveNotFoundError"
              examples:
                unknownComment:
                  summary: No review comment on this task has that id
                  value:
                    error: Comment not found
                    reason: comment_not_found
                unknownTask:
                  summary: No task in your workspace has that id
                  value:
                    error: Task not found
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/tasks/{id}/comments/{commentId}/attachments/{attachmentId}/transcript:
    post:
      tags: [Tasks]
      operationId: transcribeCommentVoiceMemo
      summary: Transcribe a comment's voice memo
      description: |
        Returns the speech-to-text of a voice memo attached to a review comment
        (a team comment or a client's share-link comment) — an attachment whose
        `mimeType` is `audio/*` (since 1.138.0).

        When the memo was already transcribed (in the app, on the share page or
        by an earlier call) the cached text is returned with `cached: true` and
        nothing is charged. Otherwise the memo is transcribed once and the text
        is saved on the comment, exactly like the app's **Generate transcript**
        button, so every later read (`attachments[].transcript`) carries it. A
        POST because the first call writes that cache: a key without
        `write:tasks` (a read-only key) → `403 insufficient_scope`.

        A memo with no recognizable speech (silence, music, noise) answers
        `200` with `transcript: ""` and `noSpeech: true` — an answer, not a
        failure: do not retry it. Nothing is cached for it.

        `404` when the comment is not a review comment of this task or carries
        no finished audio attachment with that id; a memo a cancelled
        workspace's media purge removed → `404` with `code:
        file_content_missing` and `purgedAt`. To transcribe every memo on a
        task at once use `POST /api/v1/tasks/{id}/comments/voice-memos/transcribe`.
      parameters:
        - $ref: "#/components/parameters/TaskId"
        - name: commentId
          in: path
          required: true
          description: The comment carrying the memo — from `GET /api/v1/tasks/{id}/comments`.
          schema:
            type: string
            format: uuid
        - name: attachmentId
          in: path
          required: true
          description: The memo's `attachments[].id` on that comment.
          schema:
            type: string
            maxLength: 200
      responses:
        "200":
          description: The memo's transcript.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    $ref: "#/components/schemas/VoiceMemoTranscript"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
        "502":
          description: The transcription itself failed — safe to retry.
        "503":
          description: Transcription is unavailable right now — retry later.

  /api/v1/tasks/{id}/comments/voice-memos/transcribe:
    post:
      tags: [Tasks]
      operationId: transcribeTaskVoiceMemos
      summary: Transcribe a task's voice memos
      description: |
        Fills the transcript of every voice memo on the task's review thread
        that has none yet — team and client share-link comments, replies
        included — so `GET /api/v1/tasks/{id}/comments` then carries what each
        reviewer said in `attachments[].transcript` (since 1.138.0). Voice memos
        are the most common way reviewers leave notes, and a memo-only comment
        has empty `text`: call this before reading a thread to act on it.

        Narrow it with `fileId` (one version's threads, or `current`) or
        `commentIds`. Memos are transcribed one after another, up to 10 per
        call and within a time budget; `remaining` counts the memos still
        waiting — call again until it is `0`. Memos that already have a
        transcript cost nothing and are only counted (`alreadyTranscribed`).
        Each transcript is saved on its comment exactly like the app's
        **Generate transcript** button. `noSpeech: true` (with `transcript:
        ""`) means the memo holds no recognizable speech — it is not retried
        as a failure. A failure on one memo (`failed[]`, with its status — a
        `502` is safe to retry) never stops the rest.

        A write (it fills that cache): a key without `write:tasks` → `403
        insufficient_scope`. An empty body (or `{}`) means every memo.
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                fileId:
                  type: string
                  description: Only memos on this version's threads — a file id, or `current` for the task's current version.
                commentIds:
                  type: array
                  minItems: 1
                  maxItems: 100
                  description: Only memos on these comments.
                  items: { type: string, format: uuid }
      responses:
        "200":
          description: What was transcribed, what failed and what is left.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [transcribed, failed, alreadyTranscribed, removed, remaining]
                    properties:
                      transcribed:
                        type: array
                        items:
                          $ref: "#/components/schemas/VoiceMemoTranscript"
                      failed:
                        type: array
                        items:
                          type: object
                          required: [commentId, attachmentId, status, error]
                          properties:
                            commentId: { type: string, format: uuid }
                            attachmentId: { type: string }
                            status:
                              type: integer
                              description: The status the single-memo route would answer (502 = safe to retry, 404 = gone or removed).
                            error: { type: string }
                      alreadyTranscribed:
                        type: integer
                        description: Memos in scope that already had a transcript (no charge).
                      removed:
                        type: integer
                        description: Memos in scope a cancelled workspace's media purge removed.
                      remaining:
                        type: integer
                        description: Memos still without a transcript after this call — call again.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
        "503":
          description: Transcription is unavailable right now — retry later.

  /api/v1/tasks/{id}/chat:
    get:
      tags: [Tasks]
      operationId: listTaskChat
      summary: Read a task's chat
      description: |
        Returns the task's **chat** — the conversation about the task (updates,
        questions, decisions), oldest-first. Returns the **newest** `limit`
        posts (default 30, max 100), presented oldest-first.

        This is not the review thread. Use `/api/v1/tasks/{id}/comments` for
        timecoded feedback on a cut; the two are separate surfaces in the app
        and never mix.
        Ronald's chat lines are staff-only and never appear here (1.178.0):
        an API key is never Timeliner staff. They are dropped before `limit`
        is applied, so they never take a place on the page.
      parameters:
        - $ref: "#/components/parameters/TaskId"
        - name: limit
          in: query
          required: false
          description: >-
            How many of the newest chat posts to return. Out-of-range values
            are rejected with 400.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 30
      responses:
        "200":
          description: The task's chat messages.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatMessageList"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Tasks]
      operationId: createTaskChatMessage
      summary: Post in a task's chat
      description: |
        Posts a message in the task's chat, authored by the API key's creator
        (`created_by`). Silent — no `@mentions`, so no notification fires.

        Client visibility follows the author's workspace role, exactly like an
        in-app message: an admin- or supervisor-created key posts a **public**
        message (clients see it), an editor-created key posts an **internal**
        one (team-only).
      parameters:
        - $ref: "#/components/parameters/TaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTaskChatInput"
            examples:
              default:
                value:
                  text: Client moved the deadline to Friday — flagging here.
      responses:
        "201":
          description: The created message.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatMessageResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/chat/channels:
    get:
      tags: [Chat]
      operationId: listChatChannels
      summary: List chat channels
      description: |
        Returns the **chat** channels the API key's creator can see: the
        workspace-wide channel plus standalone channels such as `#marketing`.
        Brand and project channels are addressed by their own ids and are not
        listed here.

        Not to be confused with `/api/v1/channels`, which lists **social**
        posting accounts.

        Access is per-person, not per-workspace: standalone channels can be
        private, so the list is filtered to what the key's creator may read. A
        private or client-facing channel is listed only when its creator was
        added to that channel — a workspace admin seat grants no exception. A
        key with no associated user returns `400`.
      responses:
        "200":
          description: The chat channels the key's creator can see.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatChannelList"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/chat/messages:
    get:
      tags: [Chat]
      operationId: listChatMessages
      summary: Read a chat channel
      description: |
        Returns recent messages in one chat channel, oldest-first.

        A channel the key's creator cannot read returns `404` rather than `403`,
        so a private channel's existence is never confirmed. That includes a
        private or client-facing standalone channel the creator was never added
        to, even when the creator is a workspace admin.

        Team-only messages (`teamOnly: true`, which includes the app's own
        system posts) come back only when the key's creator is a team member of
        that channel's scope — the endpoint returns exactly what that person
        sees in the app.
      parameters:
        - name: scopeType
          in: query
          required: true
          schema:
            $ref: "#/components/schemas/ChatScopeType"
          description: Channel kind. `global` is the workspace-wide channel.
        - name: scopeId
          in: query
          required: false
          schema:
            type: string
            format: uuid
          description: >-
            Brand / project / conversation / standalone-channel id. Omit for
            `global`; required for every other scope.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 30
          description: How many messages to return.
      responses:
        "200":
          description: The channel's messages.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatMessageList"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Chat]
      operationId: createChatMessage
      summary: Post a chat message
      description: |
        Posts a message into a chat channel, authored by the API key's creator
        (`created_by`). Silent — nothing beyond the channel's own unread badge
        fires.

        The creator must be able to post in the channel: an archived channel, a
        private channel they are not a member of, or a DM they are not in all
        return `404`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateChatMessageInput"
            examples:
              default:
                value:
                  scopeType: custom
                  scopeId: 6f1d2c34-5b6a-7c8d-9e0f-1a2b3c4d5e6f
                  text: Deploy is out — please sanity-check the landing page.
      responses:
        "201":
          description: The created message.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatMessageResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/chat/messages/{id}:
    patch:
      tags: [Chat]
      operationId: updateChatMessage
      summary: Edit a chat message
      description: |
        Changes the text of one chat message the API key's creator
        (`created_by`) wrote — the message's **Edit** in the app, which marks
        it as edited (1.227.0). `text` is a full replace; only `text` can
        change. Someone else's message, or an app activity post, is `403`
        ("Cannot edit this message"). A message in another workspace, or in a
        channel the creator can no longer see, is `404`. Like a post made
        through the API, the new text carries no @mentions or entity links.
        Silent — no one is notified.
      parameters:
        - name: id
          in: path
          required: true
          description: The chat message's id (from `GET /api/v1/chat/messages`).
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateChatMessageInput"
            examples:
              default:
                value:
                  text: Deploy is out — landing page checked, all good.
      responses:
        "200":
          description: The edited message.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatMessageResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards:
    get:
      tags: [HQ]
      operationId: listHqBoards
      summary: List HQ boards
      description: |
        Returns every HQ board in the workspace — including archived boards
        (check `archivedAt`) and `access: restricted` boards (the workspace API
        key is admin-equivalent; per-board restricted membership does not
        filter this list). Ordered by the in-app gallery order. Not paginated:
        active boards are capped per plan.
      responses:
        "200":
          description: The workspace's HQ boards.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/HqBoard"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [HQ]
      operationId: createHqBoard
      summary: Create an HQ board
      description: |
        Creates an internal HQ board, optionally seeded from a template preset
        (`companyOps`, `salesPipeline`, `sops`, `assetLibrary`, `onboarding`,
        `blank`). A template seeds its stages and custom fields with their
        **English** names (they become plain user-editable strings); the API
        has no locale context, unlike the in-app create flow which seeds in
        the creator's language. Without a `template`, the board gets a single
        "To do" stage and no fields. `icon` / `color` / `kind` default to the
        template's values when omitted.

        Active boards are capped per plan — archived and trashed boards do not
        count, and grade-2+ plans (elite/agency/scale, enterprise) are
        unlimited. Beyond the cap the endpoint returns 409 until boards are
        archived or deleted. The in-app supervisor-level creation rule does not
        apply here: the workspace API key is a workspace-level, admin-equivalent
        credential.

        Returns the full board (stages + fields + members) — use the returned
        stage ids to create items.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateHqBoardInput"
            examples:
              fromTemplate:
                summary: Seed a sales pipeline from the template
                value:
                  name: Sales Pipeline
                  template: salesPipeline
              blank:
                summary: A blank board with a single "To do" stage
                value:
                  name: Studio Ops
                  icon: "🏢"
                  color: blue
                  access: restricted
      responses:
        "201":
          description: Board created (stages, fields, and members inline).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqBoardDetail"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "409":
          description: The workspace is at its plan's active-HQ-board cap.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}:
    get:
      tags: [HQ]
      operationId: getHqBoard
      summary: Retrieve an HQ board
      description: |
        Returns one board with its stages (the kanban columns), its custom
        field definitions (+select options), and its members. Restricted
        boards are returned too (the key is admin-equivalent).
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
      responses:
        "200":
          description: The board with stages, fields, and members.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqBoardDetail"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [HQ]
      operationId: updateHqBoard
      summary: Update an HQ board
      description: |
        Updates one or more of the allow-listed fields: `name`, `description`,
        `icon`, `color`, `access`, `archived`. `archived: true` archives the
        board (reversible — archived boards stop counting toward the plan
        cap); `archived: false` restores it. Invalid `color` tokens are
        coerced to null. Returns the full updated board.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateHqBoardInput"
            examples:
              rename:
                value:
                  name: Company Ops 2027
              archive:
                value:
                  archived: true
      responses:
        "200":
          description: The updated board.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqBoardDetail"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [HQ]
      operationId: deleteHqBoard
      summary: Delete an HQ board
      description: |
        **Permanently** deletes the board and everything on it — items,
        stages, fields, values, comments, and doc versions cascade. This
        cannot be undone; prefer `PATCH … { "archived": true }` for reversible
        removal. Refused with 409 while the board still holds files (remove
        them in the app first).

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
      responses:
        "204":
          description: Board permanently deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: The board still holds files.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: Remove the board's files before deleting it
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/items:
    get:
      tags: [HQ]
      operationId: listHqItems
      summary: List a board's items
      description: |
        Returns the board's active (non-archived) items, newest first,
        cursor-paginated like `GET /api/v1/tasks`. Each item embeds its
        custom-field `values`; the doc body (`contentText`) is only on the
        single-item fetch. Filter by `stageId` (must be a stage of this board)
        and/or `assigneeId` (items whose assignees include that member).
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/Limit"
        - $ref: "#/components/parameters/Before"
        - name: stageId
          in: query
          required: false
          description: Restrict to one stage (column) of the board.
          schema:
            type: string
            format: uuid
        - name: assigneeId
          in: query
          required: false
          description: Restrict to items assigned to this team member.
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Page of items.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqItemPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [HQ]
      operationId: createHqItem
      summary: Create an item on a board
      description: |
        Creates an item (card) in one of the board's stages, appended at the
        bottom of that column. Get the stage ids from
        `GET /api/v1/hq/boards/{id}`. Assignees, due date, and field values
        are set afterward via `PATCH /api/v1/hq/items/{id}` and
        `POST /api/v1/hq/items/{id}/values`.

        Pass `contentHtml` to write the item's **document body in this same
        call** — no follow-up `PUT /api/v1/hq/items/{id}/doc` needed. The
        response then also carries `contentText` and `docSaved` (see the
        request schema).
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateHqItemInput"
            examples:
              default:
                value:
                  title: Renew gear insurance
                  stageId: 6f5b0d2e-3a4c-4d5e-8f90-1a2b3c4d5e6f
                  icon: "📋"
              withDocBody:
                summary: Create the item and write its document in one call
                value:
                  title: Q3 client brief
                  stageId: 6f5b0d2e-3a4c-4d5e-8f90-1a2b3c4d5e6f
                  contentHtml: "<h2>Q3 brief</h2><p>Three hero films, one cutdown each.</p>"
      responses:
        "201":
          description: |
            Item created. When the request carried `contentHtml` the body also
            includes `contentText` (the saved document) and `docSaved`.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqItemCreated"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/items/{id}:
    get:
      tags: [HQ]
      operationId: getHqItem
      summary: Retrieve an HQ item
      description: |
        Returns one item with its custom-field `values` and `contentText` —
        the item's doc body as HTML (SOPs / notes; `null` when the item has no
        doc).
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      responses:
        "200":
          description: The item, including its doc body.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqItemDetail"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/HqItemNotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [HQ]
      operationId: updateHqItem
      summary: Update an HQ item
      description: |
        Updates one or more of the allow-listed fields: `title`, `icon`,
        `stageId` (moves the item to another stage of the **same** board),
        `assigneeIds`, `dueDate` (`YYYY-MM-DD` or null), `sortOrder`,
        `archived`.

        `assigneeIds` is a **full replace** of the item's assignees: send the
        complete list you want, `[]` to clear. Every id you **add** must be an
        **active team member** of the workspace (member ids from
        `GET /api/v1/members`) — guests can never be given HQ work; any other
        added id is rejected with 400. People already on the item may stay on it,
        even if they have been deactivated since, so they never block a change
        to the list.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateHqItemInput"
            examples:
              moveStage:
                summary: Move the item to another column
                value:
                  stageId: 7a6b5c4d-3e2f-4a1b-9c8d-7e6f5a4b3c2d
              assign:
                value:
                  assigneeIds:
                    - "11111111-1111-1111-1111-111111111111"
                  dueDate: "2026-08-01"
      responses:
        "200":
          description: The updated item (doc body included).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqItemDetail"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/HqItemNotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [HQ]
      operationId: deleteHqItem
      summary: Delete an HQ item
      description: |
        **Permanently** deletes the item — its doc body, field values, and
        comments cascade. There is no HQ trash; prefer
        `PATCH … { "archived": true }` for reversible removal.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      responses:
        "204":
          description: Item permanently deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/items/{id}/values:
    post:
      tags: [HQ]
      operationId: setHqItemFieldValues
      summary: Bulk-set an item's field values
      description: |
        Sets one or more custom-field values on the item. Get the board's
        field definitions (ids, kinds, select options) from
        `GET /api/v1/hq/boards/{id}`; each entry's declared `kind` must match
        its field's kind. Value by kind: `text`/`email`/`phone` → a string
        (email/phone are pattern-checked); `number`/`currency` → a number;
        `date` → `YYYY-MM-DD`; `select` → the `id` of one of THAT field's own
        `options` (an option id belongs to one field of one board — never
        another field's option, never the label); `link` →
        an http(s) URL; `user` → an **active team-member** id; `timeTracker` →
        the **total logged seconds** (non-negative number; a running in-app
        timer is unaffected). A `null` value clears the cell; so does an
        empty (or blank) string for a `select` field (since 1.116.0).

        All entries are validated before anything is written — one bad entry
        fails the whole call with 400 and no partial write happens. Returns
        the item's full value set after the write.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SetHqItemValuesInput"
            examples:
              default:
                value:
                  values:
                    - fieldId: 5d4c3b2a-1f0e-4d9c-8b7a-6f5e4d3c2b1a
                      kind: currency
                      value: 4500
                    - fieldId: 9a8b7c6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d
                      kind: email
                      value: buyer@example.com
              clear:
                summary: Clear a cell
                value:
                  values:
                    - fieldId: 5d4c3b2a-1f0e-4d9c-8b7a-6f5e4d3c2b1a
                      kind: currency
                      value: null
      responses:
        "200":
          description: The item's full value set after the write.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqItemValuesResult"
        "400":
          description: |
            An entry failed validation, and nothing was written. For a select
            field whose value is not one of THAT field's options, `error`
            starts with `Option does not belong to field <fieldId>`
            (unchanged), then names the mistake — an option of another field
            on the same board, an option of a field on another HQ board, a
            field's own id, a stage id, or an id that is no option in your
            workspace — and lists the field's valid `label = optionId` pairs
            (the first 20, in the field's order; the rest are on
            `GET /api/v1/hq/boards/{id}`). The value you sent is never echoed
            back. An option id from another workspace reads exactly like an
            unknown id.

            A select value that is not an id at all — the option's label,
            free text — starts with `select values must be an option UUID or
            null (fieldId <fieldId>)` (unchanged). Since 1.116.0 it goes on
            to name the option when the value is one of that field's labels
            (trimmed, any letter case) together with that option's id, or
            otherwise asks for an option's id rather than its text, and lists
            the same valid `label = optionId` pairs. For an item outside your
            workspace, or a field that is not a select on the item's board,
            the text stops after the prefix.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              examples:
                selectOptionOfAnotherField:
                  summary: An option of a different select field was sent
                  value:
                    error: >-
                      Option does not belong to field
                      a0bceae0-d1da-4b3e-84ff-12b9e74ebb3c — that id is an
                      option of this board's "Shoot type" field, not of this
                      one. Valid option ids for "Priority": Critical =
                      aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa, High =
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb.
                selectOptionUnknown:
                  summary: An id that is no option in your workspace
                  value:
                    error: >-
                      Option does not belong to field
                      a0bceae0-d1da-4b3e-84ff-12b9e74ebb3c — no option in this
                      workspace has that id. Valid option ids for "Priority":
                      Critical = aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa, High =
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb.
                selectLabel:
                  summary: The option's label was sent instead of its id
                  value:
                    error: >-
                      select values must be an option UUID or null (fieldId
                      a0bceae0-d1da-4b3e-84ff-12b9e74ebb3c) — that value is
                      this field's option "High" — send exactly its option id
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb. Valid option ids
                      for "Priority": Critical =
                      aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa, High =
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb.
                selectFreeText:
                  summary: Text that is no option of the field
                  value:
                    error: >-
                      select values must be an option UUID or null (fieldId
                      a0bceae0-d1da-4b3e-84ff-12b9e74ebb3c) — send an option's
                      id (a uuid), not its text. Valid option ids for
                      "Priority": Critical =
                      aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa, High =
                      bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb.
                wrongValueType:
                  summary: A value of the wrong shape for the field's kind
                  value:
                    error: >-
                      date values must be 'YYYY-MM-DD' or null (fieldId
                      a0bceae0-d1da-4b3e-84ff-12b9e74ebb3c)
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/HqItemNotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/items/{id}/comments:
    get:
      tags: [HQ]
      operationId: listHqItemComments
      summary: List an item's comments
      description: |
        Returns the item's comment thread, oldest first, each comment with its
        author `{ id, name }` (`null` when the author's profile is gone). HQ
        comments are team-internal — clients and guests can never see them.
        Not paginated.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      responses:
        "200":
          description: The item's comments.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/HqComment"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [HQ]
      operationId: createHqItemComment
      summary: Comment on an HQ item
      description: |
        Posts a comment on the item's thread, authored by the API key's
        creator (`created_by`; 400 when the key has no associated user).
        Silent — no notifications fire.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateHqCommentInput"
            examples:
              default:
                value:
                  text: Renewed — the new policy doc is on the board.
      responses:
        "201":
          description: The created comment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqComment"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/items/{id}/doc:
    put:
      tags: [HQ]
      operationId: writeHqItemDoc
      summary: Write an HQ item's document
      description: |
        Replaces the item's document body (the Notion-style Document tab) with
        the given HTML. The previous body is snapshotted as a doc **version**
        first, so it stays recoverable from the item's version history. This is
        a full replace — read the item (`getHqItem` returns `contentText`) and
        carry over anything that should stay. To change only part of the
        document (add a paragraph under a heading, fix one passage), use
        `POST /api/v1/hq/items/{id}/doc/edits` instead. Silent — no
        notifications fire.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [contentHtml]
              properties:
                contentHtml:
                  type: string
                  minLength: 1
                  maxLength: 1000000
                  description: |
                    The full new document body as HTML — at most 1,000,000
                    characters, the same ceiling as a task's document (it was
                    200,000 before 1.220.0).
            examples:
              default:
                value:
                  contentHtml: "<h2>Editing SOP</h2><p>Always export in 4K.</p>"
      responses:
        "200":
          description: The document was written.
          content:
            application/json:
              schema:
                type: object
                required: [itemId, docRev, previousVersionSaved]
                properties:
                  itemId:
                    type: string
                    format: uuid
                  docRev:
                    type: integer
                    description: The item's document revision after the write.
                  previousVersionSaved:
                    type: boolean
                    description: |
                      Whether the prior (non-empty) body was snapshotted as a
                      version before the write. `false` when there was nothing
                      to keep, or when the snapshot could not be taken — the
                      write itself still succeeded either way.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/items/{id}/doc/edits:
    post:
      tags: [HQ]
      operationId: editHqItemDoc
      summary: Edit part of an HQ item's document
      description: |
        Changes PART of an HQ item's document body (the Document tab — SOPs,
        notes) without resending the whole thing. Since 1.129.0.

        Takes the same edits as `POST /api/v1/tasks/{id}/doc/edits`:

        - **`append`** (`html`) — adds `html` at the end of the document.
        - **`prepend`** (`html`) — adds `html` at the start of the document.
        - **`replaceSection`** (`heading`, `html`) — replaces the section: the
          heading AND everything after it up to the next top-level heading of
          the same or a higher level (or the end). Start `html` with the
          heading to keep it; `""` deletes the section.
        - **`appendToSection`** (`heading`, `html`) — adds `html` at the end
          of that section, before the next heading that ends it.
        - **`replaceText`** (`find`, `html`) — replaces `find`, a piece of the
          stored HTML (`contentText` of `GET /api/v1/hq/items/{id}`) that
          occurs exactly once. `""` deletes it. Copying it exactly is safest;
          since 1.134.2 a `find` that occurs nowhere verbatim is looked up
          once more ignoring how `&` / `"` / `'` / a hard space are spelled,
          runs of whitespace, and line breaks or indents between tags — the
          same rule as `POST /tasks/{id}/doc/edits`.

        `heading` matches a heading (`<h1>`–`<h6>`) on its visible text,
        case and spacing ignored. A top-level heading is looked up first;
        only when none matches, since 1.205.1, a heading inside a toggle
        (`<details>`), callout or quote anchors a section too, and that
        section ends where the block's content ends — so an SOP whose whole
        body sits in one toggle can be edited by section. A heading inside a
        table or a list, or a toggle's title, is not a section anchor.

        Edits apply in order — each to the result of the one before — and all
        or nothing, to whatever the document holds when the request lands: a
        teammate editing another part of the document in the app meanwhile
        does not make the request fail and is not overwritten. Every byte
        outside an edit's range is kept exactly as stored, comment highlights
        included. Pass `baseRev` only to require that the document is still at
        that `docRev` (a mismatch answers **409**).

        HQ documents cap at **1,000,000** characters, the same ceiling as a
        task's document (200,000 before 1.220.0): `html`, `find` and the
        resulting document are all held to it. Like `PUT /hq/items/{id}/doc`,
        the body before the edit is snapshotted as a doc **version** labelled
        "Before API edit", and no notifications fire.

        An anchor that is missing or matches more than once answers **422**
        with `code` and the failing edit's `index`; nothing is written.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                edits:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    $ref: "#/components/schemas/DocEdit"
                baseRev:
                  type: [integer, "null"]
                  minimum: 0
                  description: |
                    Optional. Apply only if the document is still at this
                    `docRev` (returned by a previous write or edit) — **409**
                    otherwise. Omit it to apply the edits to the current
                    content.
              required: [edits]
            examples:
              appendToSection:
                summary: Add a step under one heading of an SOP
                value:
                  edits:
                    - op: appendToSection
                      heading: Editing steps
                      html: "<p>Color-grade before export.</p>"
              fixPassage:
                summary: Fix one passage
                value:
                  edits:
                    - op: replaceText
                      find: "<p>Export in 1080p.</p>"
                      html: "<p>Export in 4K.</p>"
      responses:
        "200":
          description: The edits were applied and saved.
          content:
            application/json:
              schema:
                type: object
                required: [itemId, docRev, previousVersionSaved, applied]
                properties:
                  itemId:
                    type: string
                    format: uuid
                  docRev:
                    type: integer
                    description: The item's document revision after the write.
                  previousVersionSaved:
                    type: boolean
                    description: |
                      Whether the body before the edit (when non-empty) was
                      snapshotted as a version. `false` when there was nothing
                      to keep, or when the snapshot could not be taken — the
                      edit itself was saved either way.
                  applied:
                    type: integer
                    description: How many edits were applied (always all of them on success).
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: |
            Nothing was written. With `reason: stale_base_rev`, `baseRev` was
            sent and the document is no longer at that rev: send the same edits
            again WITHOUT `baseRev` to apply them to what it holds now (with the
            same `baseRev` it fails the same way). With
            `reason: doc_still_changing` (rare), no `baseRev` was sent and other
            writers kept saving while the edits were being applied, more times
            than the request re-applies them: send the same edits again. The
            body never carries the document; read it with `GET /hq/items/{id}`
            only if your edits depend on what changed. `reason` and `error`
            since 1.193.0.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocEditConflict"
              example:
                conflict: true
                reason: stale_base_rev
                error: "Nothing was saved: the document is at rev 12, not the baseRev 9 you sent, so it changed after you read it (a successful write returns the new rev — your own earlier write counts too). Send the same edits again without baseRev to apply them to what it holds now; read it with GET /hq/items/{id} (contentText) first only if they depend on what changed."
                currentRev: 12
        "422":
          description: |
            An edit could not be applied as sent; nothing was written.
            `anchorNotFound` — the heading or `find` text is not in the
            document; on a `replaceText` edit `reason` says why
            (`find_text_absent` or `find_markup_differs`, since 1.224.0).
            `anchorAmbiguous` — it occurs more than once (`matches`
            says how often). `docNotSectionable` — the stored HTML is
            malformed, so sections cannot be located safely (use
            `replaceText`, `append` or `prepend`). `docTooLarge` — the result
            would exceed 1,000,000 characters; sending the same edits again
            fails the same way, so shorten the `html` or move content to
            another item.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocEditError"
              example:
                error: 'edits[0]: no top-level heading reads "Missing section" — headings match on their visible text (case and spacing ignored); read the document with GET /hq/items/{id} (contentText)'
                code: anchorNotFound
                index: 0
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/reorder:
    post:
      tags: [HQ]
      operationId: reorderHqBoards
      summary: Reorder HQ boards
      description: |
        Sets the order boards are listed in (the HQ home and the in-board
        boards panel). `boardIds` must name **every** non-trashed board of
        the workspace exactly once — archived boards included.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [boardIds]
              properties:
                boardIds:
                  type: array
                  minItems: 1
                  maxItems: 500
                  uniqueItems: true
                  items:
                    type: string
                    format: uuid
      responses:
        "204":
          description: Boards reordered.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/stages:
    post:
      tags: [HQ]
      operationId: createHqStage
      summary: Create an HQ stage
      description: |
        Adds a stage — a kanban column, and a group in the list view — at the
        end of the board. `outcome` marks Done / Won / Lost columns (cards in
        them stop reading as late). Capped per board: 409 at the cap.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/HqStageInput"
            examples:
              default:
                value:
                  name: In review
                  color: amber
      responses:
        "201":
          description: The created stage.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqStage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/stages/reorder:
    post:
      tags: [HQ]
      operationId: reorderHqStages
      summary: Reorder HQ stages
      description: |
        Sets the order of the board's stages (kanban columns). `stageIds`
        must name every stage of the board exactly once. Returns the board.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [stageIds]
              properties:
                stageIds:
                  type: array
                  minItems: 1
                  uniqueItems: true
                  items:
                    type: string
                    format: uuid
      responses:
        "200":
          description: The board with its stages in the new order.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqBoardDetail"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/stages/{stageId}:
    patch:
      tags: [HQ]
      operationId: updateHqStage
      summary: Update an HQ stage
      description: Renames, recolors, or changes the outcome of one stage.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqStageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/HqStageInput"
              minProperties: 1
            examples:
              markDone:
                value:
                  outcome: done
      responses:
        "200":
          description: The updated stage.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqStage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [HQ]
      operationId: deleteHqStage
      summary: Delete an HQ stage
      description: |
        Deletes a stage. If it still holds items, `targetStageId` (another
        stage of the same board) is required and they move there. A board's
        last stage can never be deleted (409).

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqStageId"
        - name: targetStageId
          in: query
          required: false
          description: The stage the deleted stage's items move to.
          schema:
            type: string
            format: uuid
      responses:
        "204":
          description: Stage deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/fields:
    post:
      tags: [HQ]
      operationId: createHqField
      summary: Create an HQ field
      description: |
        Adds a custom field — a list-view column and an item-page detail.
        Select fields may seed their options; currency fields take an ISO
        4217 `currency`, which is stored and returned here, while HQ screens
        and public links always show the workspace currency (`defaultCurrency`
        on `GET /api/v1/workspace`). Capped per board: 409 at the cap. Field names are
        unique per board, ignoring case and surrounding spaces: a `name`
        another field on the board already uses is a 409 and nothing is
        created. Set values with `POST /api/v1/hq/items/{id}/values`.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateHqFieldInput"
            examples:
              select:
                value:
                  kind: select
                  name: Priority
                  options:
                    - label: High
                      color: red
                    - label: Low
                      color: slate
      responses:
        "201":
          description: The created field (with option ids).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqField"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/fields/{fieldId}:
    patch:
      tags: [HQ]
      operationId: updateHqField
      summary: Update an HQ field
      description: |
        Renames a field (its column title) and/or changes a currency field's
        stored currency (HQ screens and public links always show the workspace
        currency). Field names are unique per board, ignoring case and
        surrounding spaces: renaming onto a name another field on the board
        already uses is a 409 and the field keeps its name. Changing only the
        case of the field's own name is allowed.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqFieldId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              minProperties: 1
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 60
                currency:
                  type: string
                  pattern: "^[A-Z]{3}$"
                  description: Currency fields only. Stored and returned here; HQ screens and public links always show the workspace currency.
            examples:
              rename:
                value:
                  name: Deal size
      responses:
        "200":
          description: The updated field.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqField"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [HQ]
      operationId: deleteHqField
      summary: Delete an HQ field
      description: |
        Deletes the field. **Every item's value in it is deleted with it** —
        this cannot be undone.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqFieldId"
      responses:
        "204":
          description: Field deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/fields/{fieldId}/options:
    post:
      tags: [HQ]
      operationId: createHqFieldOption
      summary: Add a select option
      description: Adds an option to a select field (appended last). Capped per field — 409 at the cap.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqFieldId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/HqFieldOptionInput"
            examples:
              default:
                value:
                  label: Urgent
                  color: rose
      responses:
        "201":
          description: The created option.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqFieldOption"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/fields/{fieldId}/options/reorder:
    post:
      tags: [HQ]
      operationId: reorderHqFieldOptions
      summary: Reorder select options
      description: |
        Sets a select field's option order (pickers and column sorts follow
        it). `optionIds` must name every option of the field exactly once.
        Returns the field.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqFieldId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [optionIds]
              properties:
                optionIds:
                  type: array
                  minItems: 1
                  uniqueItems: true
                  items:
                    type: string
                    format: uuid
      responses:
        "200":
          description: The field with its options in the new order.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqField"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/boards/{id}/fields/{fieldId}/options/{optionId}:
    patch:
      tags: [HQ]
      operationId: updateHqFieldOption
      summary: Update a select option
      description: Renames or recolors one option of a select field.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqFieldId"
        - $ref: "#/components/parameters/HqOptionId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/HqFieldOptionInput"
              minProperties: 1
            examples:
              recolor:
                value:
                  color: emerald
      responses:
        "200":
          description: The updated option.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqFieldOption"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [HQ]
      operationId: deleteHqFieldOption
      summary: Delete a select option
      description: |
        Deletes the option. Items that held it are left empty in that field.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/HqBoardId"
        - $ref: "#/components/parameters/HqFieldId"
        - $ref: "#/components/parameters/HqOptionId"
      responses:
        "204":
          description: Option deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/items/{id}/comments/{commentId}:
    patch:
      tags: [HQ]
      operationId: updateHqItemComment
      summary: Edit an HQ comment
      description: |
        Edits a comment's text. Only comments authored by the API key's
        creator can be edited — `403` otherwise.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
        - $ref: "#/components/parameters/HqCommentId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateHqCommentInput"
            examples:
              default:
                value:
                  text: Updated — the new policy doc is on the board.
      responses:
        "200":
          description: The edited comment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqComment"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [HQ]
      operationId: deleteHqItemComment
      summary: Delete an HQ comment
      description: |
        Deletes a comment and its replies. The workspace key is
        admin-equivalent, so it may remove any comment on the item.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
        - $ref: "#/components/parameters/HqCommentId"
      responses:
        "204":
          description: Comment deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/items/{id}/files:
    get:
      tags: [HQ]
      operationId: listHqItemFiles
      summary: List an item's files
      description: |
        Returns the files attached to the item (its Files tab), newest
        first, each with a presigned `downloadUrl` valid for 7 days.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      responses:
        "200":
          description: The item's files.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/HqFile"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [HQ]
      operationId: uploadHqItemFileFromUrl
      summary: Attach a file to an HQ item by URL
      description: |
        The server downloads a **public** http(s) URL (private / internal
        hosts are refused; size-capped) and stores it on the item's Files
        tab — exactly like a file dropped there in the app: the item is
        marked changed and "file attached" board automations run. Counts
        toward workspace storage (`403` when it would exceed the plan). Needs
        a key with an associated user (the uploader).

        A workspace whose uploads are paused answers
        **403** `code: UPLOADS_PAUSED` (see *Uploads paused*, since 1.110.1).
        Nothing is pulled.
      parameters:
        - $ref: "#/components/parameters/HqItemId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [url]
              properties:
                url:
                  type: string
                  format: uri
                  description: A public http(s) URL to the file.
                fileName:
                  type: string
                  maxLength: 255
                  description: Name to store it under; inferred from the response when omitted.
            examples:
              default:
                value:
                  url: https://example.com/brand/logo-pack.zip
      responses:
        "201":
          description: The attached file.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HqFile"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hq/files/{id}:
    delete:
      tags: [HQ]
      operationId: deleteHqFile
      summary: Delete an HQ file
      description: |
        Removes an HQ file — an item attachment or a board-shelf file. Same
        as deleting it in the app: the file moves to the board's trash, and
        removing an attachment marks its item changed.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - name: id
          in: path
          required: true
          description: The HQ file's UUID.
          schema:
            type: string
            format: uuid
      responses:
        "204":
          description: File removed.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/webhooks:
    get:
      tags: [Webhooks]
      operationId: listWebhooks
      summary: List webhook subscriptions
      description: |
        Returns every webhook subscription in the workspace. Signing secrets are
        never returned — only the non-sensitive `secretPrefix`.
      responses:
        "200":
          description: The workspace's webhook subscriptions.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookList"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Webhooks]
      operationId: createWebhook
      summary: Create a webhook subscription
      description: |
        Registers an HTTPS endpoint to receive the given events. The response
        includes the plaintext signing `secret` **once** — store it immediately,
        it is never shown again. A workspace may hold at most 20 subscriptions.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateWebhookInput"
            examples:
              default:
                value:
                  url: https://example.com/timeliner/webhooks
                  events: [task.completed, post.status_changed]
      responses:
        "201":
          description: Subscription created. The `secret` field is present here only.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreatedWebhook"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/webhooks/{id}:
    get:
      tags: [Webhooks]
      operationId: getWebhook
      summary: Retrieve a webhook subscription
      parameters:
        - $ref: "#/components/parameters/WebhookId"
      responses:
        "200":
          description: The subscription (without the secret).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookSubscription"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Webhooks]
      operationId: updateWebhook
      summary: Update a webhook subscription
      description: Change the `url`, `events`, or `active` flag. Provide at least one.
      parameters:
        - $ref: "#/components/parameters/WebhookId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateWebhookInput"
            examples:
              disable:
                summary: Pause deliveries without deleting the subscription
                value:
                  active: false
      responses:
        "200":
          description: The updated subscription.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookSubscription"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Webhooks]
      operationId: deleteWebhook
      summary: Delete a webhook subscription
      description: |
        Removes the subscription — deliveries stop immediately and the signing
        secret is discarded. Re-subscribing mints a new secret.

        Counts against the shared `DELETE` budget — see the `429` response.
      parameters:
        - $ref: "#/components/parameters/WebhookId"
      responses:
        "204":
          description: Subscription deleted.
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/webhooks/{id}/rotate-secret:
    post:
      tags: [Webhooks]
      operationId: rotateWebhookSecret
      summary: Rotate a webhook signing secret
      description: |
        Generates a new signing secret for the subscription and returns it
        **once**. The previous secret stops verifying immediately, so update
        your endpoint before relying on the new one.
      parameters:
        - $ref: "#/components/parameters/WebhookId"
      responses:
        "200":
          description: The new secret (returned only here).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RotatedSecret"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/hooks/automations/{token}:
    post:
      tags: [Automations]
      operationId: fireInboundHook
      summary: Fire an automation rule's inbound URL (catch hook)
      security: []
      # Token-authenticated public endpoint, not an API-key operation — the MCP
      # registry (lib/mcp/registry.ts) deliberately has no tool for it.
      x-mcp: false
      description: |
        Runs the actions of the ONE rule whose `inboundHook` trigger carries
        `{token}` on the task named in the body. No API key: the token is the
        credential (mint it by creating a rule with an `inboundHook` trigger;
        the rule's `url` field is this endpoint). Rate limit: 60 calls per
        minute per token. The rule's stage / task-type / tag conditions and its
        brand scope still apply — a task outside them returns `fired: false`.
        (1.80.0)
      parameters:
        - name: token
          in: path
          required: true
          schema: { type: string, pattern: "^[A-Za-z0-9_-]{24,64}$" }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Exactly one of the two.
              properties:
                taskId: { type: string, format: uuid }
                taskRef:
                  type: string
                  description: The task's human ID, e.g. `TL-1042` (case-insensitive).
                  example: TL-1042
      responses:
        "200":
          description: The rule ran (or did not apply).
          content:
            application/json:
              schema:
                type: object
                required: [taskId, taskTitle, fired, results]
                properties:
                  taskId: { type: string, format: uuid }
                  taskTitle: { type: string, nullable: true }
                  fired:
                    type: boolean
                    description: False when the rule is out of scope for the task or its conditions did not hold.
                  results:
                    type: array
                    description: Per-rule run results (one entry when fired), same shape as the Settings run history.
                    items: { type: object }
        "400":
          description: "The body names no task, both fields, or a malformed one (`code: invalid_body`)."
        "404":
          description: "Unknown or malformed token, or a task that is not in the rule's workspace (`code: task_not_found`)."
        "409":
          description: "The rule is switched off (`code: rule_disabled`)."
        "429":
          $ref: "#/components/responses/TooManyRequests"
  /api/v1/api-key:
    get:
      tags: [Workspace]
      operationId: getApiKeyInfo
      summary: Introspect the calling API key
      description: |
        Returns what the key you are calling with is allowed to do: its
        `scopes` (`read:<resource>` / `write:<resource>`), its expiry, and its
        per-minute rate limit. Any valid key may call this regardless of scope —
        use it to discover a missing scope before a call fails with 403
        `insufficient_scope`. Never returns the secret.
      responses:
        "200":
          description: The calling key.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiKeyInfo"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/webhooks/{id}/test:
    post:
      tags: [Webhooks]
      operationId: sendTestWebhook
      summary: Send a test event to a webhook now
      description: |
        POSTs one signed sample delivery to the subscription's URL immediately
        and reports the endpoint's answer (HTTP status, latency, error). The
        envelope carries `test: true` and a representative sample payload for
        the chosen event. Not queued, never retried, and never counts toward
        the subscription's auto-disable — use it to verify an endpoint before
        real events flow. Scope: `write:webhooks`.
      parameters:
        - $ref: "#/components/parameters/WebhookId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookTestRequest"
      responses:
        "200":
          description: The delivery was attempted; `ok` tells you whether the endpoint answered 2xx.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookTestResult"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/webhooks/{id}/deliveries:
    get:
      tags: [Webhooks]
      operationId: listWebhookDeliveries
      summary: List recent deliveries for a webhook
      description: |
        The most recent deliveries attempted for one subscription, newest
        first — event type, status (`pending` / `delivered` / `failed` /
        `dead`), attempt count, last HTTP status and error, and the next retry
        time. The first place to look when an event did not arrive. Payload
        bodies are not included. Scope: `read:webhooks`.

        Sends from `POST /api/v1/webhooks/{id}/test` are listed here too, with
        `isTest: true`. A test is delivered once and never retried, so its row
        is already terminal — `delivered` on 2xx, `dead` otherwise — and its
        `nextAttemptAt` is never acted on.
      parameters:
        - $ref: "#/components/parameters/WebhookId"
        - name: limit
          in: query
          required: false
          description: Rows to return, 1-200. Defaults to 50.
          schema:
            type: integer
            minimum: 1
            maximum: 200
      responses:
        "200":
          description: Deliveries, newest first.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/WebhookDeliveryLogItem"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/uploads:
    post:
      tags: [Files]
      operationId: startFileUpload
      summary: Start a multipart file upload
      description: |
        The write half of the file story for bytes that are NOT on a public
        URL — a render on your machine, a file in a watched folder, an export
        from your editor. Mirrors the in-app uploader's flow so one client
        library serves both:

        1. **Start** here. You get presigned `PUT` URLs for each part (valid
           6 hours).
        2. **PUT** each part's bytes straight to its URL (the app never
           proxies bytes). Every part except the last must be at least
           **5 MiB** and all of them **exactly the same size** (storage
           refuses unequal non-last parts): the start answer's `partBytes`.
           Cut the file back to back: part N holds bytes
           (N-1) x partBytes up to N x partBytes, the last part the rest.
           Keep the `ETag` response header of every PUT exactly as returned.
        3. **Complete** with `POST /api/v1/files/uploads/{id}/complete`,
           passing the `{ partNumber, etag }` pairs and the destination.

        ### Network requirement

        Because step 2 is a direct upload, the part URLs point at Cloudflare
        R2 — `https://<bucket>.<account>.r2.cloudflarestorage.com` — and
        **not** at `timeliner.io`. That host must be reachable from wherever
        your client runs. A caller behind an outbound allowlist (a CI runner,
        a locked-down container, an agent sandbox) must permit
        `*.r2.cloudflarestorage.com` before starting: steps 1 and 3 talk only
        to `timeliner.io` and will succeed, so a blocked egress shows up as
        every PUT failing with your own proxy's error while the upload looks
        started. If you cannot reach the host, the `abort` endpoint below
        discards the upload so it does not count against the storage plan.

        One destination is required at start: `projectId` (a raw project
        file) or `taskId` (the file is bound for that task — the project is
        derived and editor-source extensions such as project files from your
        NLE are refused up front as a version). With `taskId`, `target` picks
        where on the task (1.159.0): `version` (default), `taskFiles` (the
        Project files tab's "Files on this task") or `projectFile` (the tab's
        team-only backup — project files only, media tasks only; complete it
        like any upload and it becomes the Current backup). Omit `parts` to let the server pick a count
        from `size`.

        ### The part size to cut at

        Since 1.214.0 the answer says how to cut the file: `partsTotal` parts,
        every one but the last exactly `partBytes` long. With `parts` sent,
        `partBytes` is the equal size that fits that count — `size / parts`
        rounded up, never under 5 MiB (one part: `size`); with `parts`
        omitted it is the recommended 64 MiB. A `parts` count no equal size
        of at least 5 MiB can fill (for example 10 parts of a 19.5 MB file)
        answers `400` *`parts` is too large: every part but the last must be
        at least 5 MiB* before anything is started or stored; more than 5 GiB
        per part answers *`parts` is too small*. Before 1.214.0 such a count
        was accepted and failed only at complete, after every byte was sent.

        The upload counts toward the workspace's storage plan;
        a full plan returns 403, and so does a workspace whose uploads are
        paused (`code: UPLOADS_PAUSED`, see *Uploads paused*). Scope:
        `write:files`.

        ### `taskId` must be a task that holds a file

        A **parent** task is a container — it has no deliverable of its own,
        its variants each carry theirs. Passing a parent task's id answers
        `400` whose `error` reads: *`taskId` is a parent task, which holds no
        file of its own — upload to one of its variants instead*, and no
        upload is started. Point `taskId` at one of the parent's variants (or at an
        ordinary task) instead. The same refusal is applied again at
        complete-time, so a caller that skipped this step still cannot attach
        a file to a parent.

        ### A file type Timeliner does not accept

        The type is read from `fileName`'s extension, or from `mimeType` when
        one is sent (lowercased, parameters such as `; codecs=…` ignored). A
        type Timeliner does not accept answers `400` with
        `reason: file_type_not_allowed` before anything is started or stored.
        Since 1.155.0 its `error` still opens *File type not allowed.* and
        then names what was read — the extension and `mimeType`, or that the
        name has no extension — lists the accepted families and links the
        [supported formats](https://timeliner.io/help-center/supported-formats)
        page. A name with **no extension** and no `mimeType` cannot be typed
        at all: send the file's real name (`clip.mp4`) or its `mimeType`.
        Branch on `reason`, never on the text.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StartUploadRequest"
      responses:
        "201":
          description: The upload was started; PUT the parts, then complete it.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StartedUpload"
        "400":
          description: |
            The body failed validation (a missing `fileName`, a bad `size` or
            `parts` — since 1.214.0 also a `parts` count no equal part size of
            at least 5 MiB can fill —, a malformed id, a parent task, an
            editor-source file sent with `taskId`), or the file type is not one
            Timeliner accepts —
            that one answers `reason: file_type_not_allowed` (since 1.155.0).
            Nothing is started or stored.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StartUploadError"
              examples:
                noExtension:
                  summary: A file name with no extension and no mimeType
                  value:
                    error: >-
                      File type not allowed. The file name has no extension
                      and no mimeType was sent, so the file type cannot be
                      told. Send the file's real name with its extension (for
                      example clip.mp4 for an MP4 video) or its real mimeType
                      (for example video/mp4). Accepted: video, audio, images,
                      PDF, Word, PowerPoint, Excel and text documents,
                      subtitles, fonts, ZIP archives, and pro source files
                      (camera and cinema RAW, editor projects, design files,
                      LUTs) — full list:
                      https://timeliner.io/help-center/supported-formats.
                      Nothing was started or stored, and the same call will be
                      refused again until the name or mimeType changes.
                    reason: file_type_not_allowed
                typeNotAccepted:
                  summary: An extension Timeliner does not accept
                  value:
                    error: >-
                      File type not allowed. Timeliner does not accept .html
                      files (mimeType text/html). Accepted: video, audio,
                      images, PDF, Word, PowerPoint, Excel and text documents,
                      subtitles, fonts, ZIP archives, and pro source files
                      (camera and cinema RAW, editor projects, design files,
                      LUTs) — full list:
                      https://timeliner.io/help-center/supported-formats.
                      Nothing was started or stored, and the same call will be
                      refused again until the name or mimeType changes.
                    reason: file_type_not_allowed
                projectFileOnly:
                  summary: An editor-source file sent with taskId
                  value:
                    error: This file type can only be uploaded as a project file.
                partsTooMany:
                  summary: A parts count no equal 5 MiB cut can fill (since 1.214.0)
                  value:
                    error: "`parts` is too large: every part but the last must be at least 5 MiB"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: |
            The `taskId` (or `projectId`) is not in your workspace, and
            nothing was started or stored. When the `taskId` is instead
            another row your OWN workspace owns — a project, a brand/folder,
            or a custom column (since 1.110.2), or an HQ item or a file
            (since 1.112.1) — `error` names which and where it belongs: the
            commonest mistake on this endpoint is a project id sent as
            `taskId`, which belongs in `projectId`, and an HQ item takes files
            through `POST /api/v1/hq/items/{id}/files` instead. Since 1.149.4
            a `taskId` that looks **shortened** — its first 8 characters match
            a task of your workspace, the rest padded or made up — names that
            task's full id when exactly one matches (a task id is always the
            full 36 characters); since 1.159.1 a `taskId` with one or two
            characters wrong (mistyped) names the task it is that close to,
            the same way. An unknown id, or a task in another workspace
            (mistyped, padded or not), keeps the plain `Task not found` error:
            the two are deliberately indistinguishable, and no body echoes the
            id back. Since 1.161.0 that plain body also carries
            `"reason": "task_not_found"` — the one machine-readable marker of
            "no task with this id in your workspace" (a named mistake above has
            no `reason`) — and a task lookup that FAILS on our side answers
            `500`, never this `404`. Get the task's id again (`GET
            /api/v1/tasks`) and send all 36 characters, or upload without a task.

            Since 1.159.2 a `projectId` sent WITHOUT a `taskId` gets a similar
            recovery (a `projectId` has no mistyped-id check): when it is
            another row your OWN workspace owns — a task, a sub-folder (task
            group), a folder inside a project's files, a brand/folder, an HQ
            item or a file — `error` names which and where it belongs (a task's
            id goes in `taskId`, or its project's id, named in the body, in
            `projectId`; a project folder's project id is named the same way
            and the folder goes in `folderId`; a sub-folder's project id is
            named too). A `projectId` that looks
            **shortened** — its first 8 characters match a project of your
            workspace, the rest padded or made up — names that project's full
            id when exactly one matches (a project id is always the full 36
            characters). An unknown id, or a project in another workspace
            (padded or not), keeps the plain `{"error":"Project not found"}`
            body, and no body echoes the id back.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadTaskNotFoundError"
              examples:
                unknownTask:
                  summary: Unknown task id, or a task in another workspace
                  value:
                    error: Task not found
                    reason: task_not_found
                projectIdInTaskId:
                  summary: A project id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is a project in this workspace —
                      pass it as `projectId` instead to save the file as a raw
                      project file, or pass one of its task ids (from
                      list_tasks, or GET /api/v1/tasks?projectId=…) as `taskId`
                      to add the file as that task's new version.
                brandIdInTaskId:
                  summary: A brand or folder id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is a brand or folder in this
                      workspace — `taskId` takes a task id (from list_tasks, or
                      GET /api/v1/tasks) and `projectId` takes a project id
                      (from list_projects, or GET /api/v1/projects).
                hqItemIdInTaskId:
                  summary: An HQ item id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is an HQ item in this workspace —
                      attach a file to an HQ item with
                      upload_hq_item_file_from_url (POST
                      /api/v1/hq/items/{id}/files). `taskId` takes a project
                      task's id (from list_tasks, or GET /api/v1/tasks).
                shortenedTaskId:
                  summary: A shortened id whose first 8 characters match one of your tasks
                  value:
                    error: >-
                      Task not found. No task has that exact id, but one task in
                      this workspace has an id starting with the same 8
                      characters: 3f2a9c10-5b7e-4d21-9a8c-1e6f0b2d4c55. The id
                      sent looks shortened and filled back out — a task id is
                      always the full 36 characters, exactly as list_tasks,
                      get_task or create_task returned it, never shortened or
                      padded. If that is the task you meant, retry with its full
                      id.
                unknownProject:
                  summary: Unknown project id, or a project in another workspace
                  value:
                    error: Project not found
                taskIdInProjectId:
                  summary: A task id was sent as projectId
                  value:
                    error: >-
                      Project not found. That id is a task in this workspace —
                      pass it as `taskId` instead to add the file as that
                      task's new version, or pass its project's id,
                      7c41e2d0-9a3b-4f6e-8d15-2b0c9e4f7a61, as `projectId` to
                      save the file as a raw project file.
                projectFolderIdInProjectId:
                  summary: A folder inside a project's files was sent as projectId
                  value:
                    error: >-
                      Project not found. That id is a folder inside a project's
                      files in this workspace — pass its project's id,
                      7c41e2d0-9a3b-4f6e-8d15-2b0c9e4f7a61, as `projectId`, then
                      pass the folder's id as `folderId` to complete_file_upload
                      (POST /api/v1/files/uploads/{id}/complete) to file the
                      upload in it.
                shortenedProjectId:
                  summary: A shortened id whose first 8 characters match one of your projects
                  value:
                    error: >-
                      Project not found. No project has that exact id, but one
                      project in this workspace has an id starting with the
                      same 8 characters: 7c41e2d0-9a3b-4f6e-8d15-2b0c9e4f7a61.
                      The id sent looks shortened and filled back out — a
                      project id is always the full 36 characters, exactly as
                      list_projects, get_project or create_project returned it,
                      never shortened or padded. If that is the project you
                      meant, retry with its full id.
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/uploads/{id}/complete:
    post:
      tags: [Files]
      operationId: completeFileUpload
      summary: Complete a multipart file upload
      description: |
        Finishes the upload once every part has been PUT: the object is
        assembled, videos are validated, and the same post-upload steps the
        in-app uploader runs are executed — `taskId` attaches the file as
        that task's new version (version row, "version uploaded" automations,
        reviewer notification, Activity Log entry, `version.uploaded`
        webhook); `taskId` with `target: "taskFiles"` files it on the task's
        Project files tab (its folder is made on first use); `folderId` files
        a project upload into a folder (`file.uploaded` webhook). Never pass
        `folderId` with `taskId`. An upload started with
        `target: "projectFile"` completes as that task's Current project-file
        backup — no notification, no webhook — and only a matching `taskId` /
        `target` (or none) is accepted. Media is queued for
        transcoding exactly as an in-app upload would be.

        **Images get their card thumbnail here too** (since 1.163.6). JPEG,
        PNG, GIF, TIFF, WebP and HEIC are rendered server-side from the
        assembled object, so the file shows its picture on its task card, in
        the post composer's preview and carousel slides and on the calendar,
        and `media.thumbnailUrl` is populated on the very next read. A
        project-file backup gets none. BMP and SVG are stored and downloadable
        as before but get no thumbnail. A thumbnail that cannot be rendered
        never fails the completion: the file still lands, without one. An
        image completed through this call before 1.163.6 gets its thumbnail
        the first time it is shown in the app.

        Retry-safe: repeating the call for an already-completed upload
        returns `200` with the same body instead of an error. A workspace
        whose uploads are paused answers **403** `code: UPLOADS_PAUSED` for an
        upload not yet completed (see *Uploads paused*); a retried completion
        of one that already completed still answers `200`. Scope:
        `write:files`.

        ### When the parts hold fewer bytes than the declared size

        Since 1.156.0 a video upload is checked BEFORE it is completed: when
        the parts you list add up to fewer bytes than the `size` you declared
        at start, the call answers `400` with `error` *`Upload is incomplete
        (<n> of <m> bytes received).`*, `reason: parts_short_of_declared_size`,
        `receivedBytes`, `declaredBytes` and `missingPartNumbers` (every part
        number from 1 to the part count that is not both listed and stored).
        Nothing is completed and nothing is discarded — the upload stays open
        under the same id. Two causes, two fixes:

        - A part is missing (`missingPartNumbers` is not empty): PUT it
          (`POST .../part-urls` if its URL expired), then complete again
          listing every part.
        - Every byte was sent (`missingPartNumbers` is empty): the `size` you
          declared was wrong — usually a rounded figure ("143 MB") instead of
          the file's exact byte count. Abort the upload and start again with
          the exact size.

        ### When the uploaded bytes are rejected

        Video uploads are checked again once storage has assembled them,
        before anything is attached. A rejection is your error, not ours, so
        it answers `400` with the reason in `error` and the upload is
        DISCARDED — the file never appears in the project and the id cannot
        be completed again. Retrying the same call cannot change the outcome;
        start a new upload instead. The reasons:

        - `Upload is incomplete (<n> of <m> bytes received).` — fewer bytes
          reached storage than the `size` you declared at start, found only
          after assembly (when storage could not list the parts beforehand;
          otherwise the check above answers first and discards nothing).
        - `Uploaded file is empty.` — nothing arrived.
        - `This file isn't a recognized video format.` — the bytes are not
          any container we accept.

        ### When storage refuses the part list

        The `parts` you send must describe the parts you actually uploaded:
        every listed part finished its PUT, each `etag` is the `ETag` that
        PUT returned, and every part except the last is the same size and at
        least 5 MiB. When storage refuses the list it answers `400` (since
        1.134.1) whose `error` starts *`Storage rejected the list of uploaded
        parts (<code>).`* — `<code>` is storage's own reason (`InvalidPart`,
        `InvalidPartOrder` or `EntityTooSmall`) — and nothing is discarded:
        the upload stays open, so complete it again with a corrected list
        (wait out the `409` + `Retry-After` the one-completion-at-a-time rule
        may answer first). Parts may be listed in any order; they are sorted
        by `partNumber` before storage sees them.

        Since 1.214.0 a refused list is checked against storage's OWN record
        of the parts it holds. When that record proves the whole file is
        there — every part from 1 to the upload's part count, the sizes adding
        up to the declared `size`, every part before the last the same size
        and at least 5 MiB — the upload is completed from it with storage's
        own ETags and answers `201` as usual: an `etag` you mistyped or kept
        from an earlier PUT of the same part costs nothing, because storage
        builds the file from the bytes it actually holds for each part (video
        uploads are still checked once assembled). Otherwise the `400` adds
        `reason: "part_list_refused"` and names what is wrong:
        `missingPartNumbers` (listed parts storage holds nothing for),
        `unequalPartNumbers` (parts before the last that are not
        `expectedPartBytes` long) and `etagMismatchPartNumbers` (listed parts
        whose `etag` is not the one storage holds). Parts are cut back to
        back, so a part of the wrong size means that part and every later one
        must be PUT again at `expectedPartBytes` — or abort and start again.

        ### When `taskId` cannot hold a file

        A **parent** task holds no file of its own — its variants each carry
        theirs — so passing a parent task's id answers `400` whose `error`
        reads: *`taskId` is a parent task, which holds no file of its own —
        upload to one of its variants instead*. Nothing is attached and no
        version is recorded; complete the same upload again against one of the
        parent's variants, or omit `taskId` to keep it as a project file.

        A `500` from this endpoint means the failure was ours (storage
        unreachable, the completion recorded late, or the file could not be
        attached to the task) and IS worth retrying — the call is retry-safe
        by design.
      parameters:
        - $ref: "#/components/parameters/UploadId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompleteUploadRequest"
      responses:
        "201":
          description: The file was stored and attached.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadedFile"
        "200":
          description: The upload had already been completed; the same file is returned.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadedFile"
        "400":
          description: |
            The body failed validation, the listed parts hold fewer bytes than
            the declared size (see *When the parts hold fewer bytes than the
            declared size* — the upload stays open), the uploaded bytes were
            rejected (see *When the uploaded bytes are rejected*), the `taskId`
            cannot hold a file, or storage refused the part list (see *When
            storage refuses the part list* — the upload stays open for a
            corrected retry).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompleteUploadError"
              examples:
                partsShort:
                  summary: The parts hold fewer bytes than the declared size (since 1.156.0)
                  value:
                    error: Upload is incomplete (141903880 of 143000000 bytes received).
                    reason: parts_short_of_declared_size
                    receivedBytes: 141903880
                    declaredBytes: 143000000
                    missingPartNumbers: []
                partListRefused:
                  summary: Storage refused the part list, naming the wrong part (since 1.214.0)
                  value:
                    error: >-
                      Storage rejected the list of uploaded parts (InvalidPart).
                      Every listed part must have finished uploading, each
                      `etag` must be the ETag that part's upload returned, and
                      every part except the last must be the same size and at
                      least 5 MiB.
                    reason: part_list_refused
                    missingPartNumbers: []
                    unequalPartNumbers: [2]
                    etagMismatchPartNumbers: []
                    expectedPartBytes: 6291456
                partsRejected:
                  summary: Storage refused the part list (since 1.134.1)
                  value:
                    error: >-
                      Storage rejected the list of uploaded parts (InvalidPart).
                      Every listed part must have finished uploading, each
                      `etag` must be the ETag that part's upload returned, and
                      every part except the last must be the same size and at
                      least 5 MiB.
                incomplete:
                  summary: Fewer bytes arrived than the declared size
                  value:
                    error: Upload is incomplete (18831 of 30000 bytes received).
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          description: |
            The upload, the `taskId` or the `folderId` is not in your workspace,
            and nothing was attached. When the `taskId` is instead another row your OWN
            workspace owns — a project, a brand/folder, or a custom column
            (since 1.110.2), or an HQ item or a file (since 1.112.1) — `error`
            names which; an HQ item takes files through
            `POST /api/v1/hq/items/{id}/files`, not this upload. This endpoint takes no
            `projectId`: the project was fixed when the upload started, so a
            project id sent as `taskId` is told to omit `taskId` (keeping the
            upload as a raw project file) or to send one of that project's
            task ids. Since 1.149.4 a `taskId` that looks **shortened** — its
            first 8 characters match a task of your workspace, the rest padded
            or made up — names that task's full id when exactly one matches;
            since 1.159.1 a `taskId` with one or two characters wrong
            (mistyped) names the task it is that close to, the same way.
            An unknown id, or a task in another workspace (mistyped, padded or not),
            keeps the plain `Task not found` error, and no body echoes the id
            back. Since 1.161.0 that plain body also carries
            `"reason": "task_not_found"` (a named mistake has no `reason`), and
            a task lookup that FAILS on our side answers `500`, never this
            `404`. Send the task's full id again, or omit `taskId` to keep the
            upload as a raw project file.

            Since 1.187.0 a `folderId` that is no folder of the upload's project
            gets the same kind of recovery. The upload was not completed: it is
            still open, its parts do not need sending again, and this refusal
            holds no lock, so a corrected retry goes straight through. When the
            id is a folder of another project or of a brand header's raw files
            in your workspace, `error` names that project or brand: complete
            without `folderId`, then `POST /api/v1/files/{id}/move` with
            `projectId` or `brandId` + `folderId`. A sub-folder of tasks, a brand
            or sidebar folder, or a project is named as such; a shortened id
            names the project's folder it matches. An unknown id, or a folder in
            another workspace, reads exactly
            `{"error":"Folder not found","reason":"folder_not_found"}`, and no
            body echoes the id back. On an upload that is already completed the
            same miss answers `{"error":"Folder not found"}` alone.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadTaskNotFoundError"
              examples:
                unknownFolder:
                  summary: Unknown folder id, or a folder in another workspace
                  value:
                    error: Folder not found
                    reason: folder_not_found
                brandFolderInFolderId:
                  summary: A brand header's folder was sent as folderId
                  value:
                    error: >-
                      Folder not found. That id is a folder of a brand header's
                      raw files in this workspace, and an upload can only be
                      filed in a folder of a project. The upload was not
                      completed — it is still open, and its parts do not need
                      sending again. Complete it without `folderId`, then file
                      it there with move_file (POST /api/v1/files/{id}/move),
                      passing the brand's id,
                      7c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f, as `brandId` and this
                      folder's id as `folderId`.
                otherProjectFolderInFolderId:
                  summary: A folder of another project was sent as folderId
                  value:
                    error: >-
                      Folder not found. That id is a folder of another project in
                      this workspace, and an upload can only be filed in a folder
                      of the project it was started in. The upload was not
                      completed — it is still open, and its parts do not need
                      sending again. Complete it without `folderId`, then file it
                      there with move_file (POST /api/v1/files/{id}/move), passing
                      that project's id, 3f8a1c2e-5b7d-4e9f-a1c3-6d8e0f2b4a97, as
                      `projectId` and this folder's id as `folderId`.
                unknownTask:
                  summary: Unknown task id, or a task in another workspace
                  value:
                    error: Task not found
                    reason: task_not_found
                projectIdInTaskId:
                  summary: A project id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is a project in this workspace —
                      omit `taskId` to keep this upload as a raw file of the
                      project it was started in, or pass one of that project's
                      task ids (from list_tasks, or GET
                      /api/v1/tasks?projectId=…) as `taskId` to add it as that
                      task's new version.
                hqItemIdInTaskId:
                  summary: An HQ item id was sent as taskId
                  value:
                    error: >-
                      Task not found. That id is an HQ item in this workspace —
                      an upload started here cannot be attached to one; attach
                      the file to the HQ item with upload_hq_item_file_from_url
                      (POST /api/v1/hq/items/{id}/files). `taskId` takes a
                      project task's id (from list_tasks, or GET
                      /api/v1/tasks); omit it to keep this upload as a raw
                      project file.
                shortenedTaskId:
                  summary: A shortened id whose first 8 characters match one of your tasks
                  value:
                    error: >-
                      Task not found. No task has that exact id, but one task in
                      this workspace has an id starting with the same 8
                      characters: 3f2a9c10-5b7e-4d21-9a8c-1e6f0b2d4c55. The id
                      sent looks shortened and filled back out — a task id is
                      always the full 36 characters, exactly as list_tasks,
                      get_task or create_task returned it, never shortened or
                      padded. If that is the task you meant, retry with its full
                      id.
                unknownUpload:
                  summary: The upload id is not in your workspace
                  value:
                    error: Upload not found
        "409":
          description: |
            Another completion of this same upload is still running (only one
            runs at a time). The `Retry-After` header gives the seconds to
            wait; nothing was done on this call. A completion that FAILED —
            for example the 400 when storage refused the list of parts — frees
            the upload at once, so a corrected retry is never answered 409.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
              example:
                error: A completion for this upload is already running — retry in a moment
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/uploads/{id}/part-urls:
    post:
      tags: [Files]
      operationId: refreshUploadPartUrls
      summary: Refresh presigned part URLs
      description: |
        Re-presigns `PUT` URLs for parts you have not sent yet (up to 100 per
        call). Part URLs expire 6 hours after the upload was started; a large
        file on a slow link needs fresh ones. The fresh URLs point at the same
        Cloudflare R2 host as the originals (see the network requirement on
        `POST /api/v1/files/uploads`), so re-presigning does not help a client
        whose network blocks `*.r2.cloudflarestorage.com`. A workspace whose uploads are paused answers
        **403** `code: UPLOADS_PAUSED` (see *Uploads paused*). Scope:
        `write:files`.
      parameters:
        - $ref: "#/components/parameters/UploadId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RefreshPartUrlsRequest"
      responses:
        "200":
          description: Fresh URLs for the requested parts.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RefreshedPartUrls"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/files/uploads/{id}/abort:
    post:
      tags: [Files]
      operationId: abortFileUpload
      summary: Abort an in-progress upload
      description: |
        Discards an upload that has not been completed: the parts already
        stored are freed and the file record is marked failed. Returns `409`
        once the upload has completed — trash the file instead. This is the
        one write a billing-locked workspace may still call (it frees storage
        and never creates content). Scope:
        `write:files`.

        **Idempotent.** An upload id that no longer has anything in
        progress — never started, already aborted, or discarded by the
        server because `complete` rejected the bytes — also answers `204`.
        Abort's goal state ("this upload is not in progress") already holds,
        so a cleanup call after a failed upload always succeeds and is safe
        to repeat. An id belonging to another workspace answers `204` too,
        without reading or changing anything, because ids are never
        enumerable across workspaces. The only remaining `404` is an
        upload of yours that lives in a workspace this key does not cover.
      parameters:
        - $ref: "#/components/parameters/UploadId"
      responses:
        "204":
          description: |
            Nothing is in progress under that id any more — either this
            call discarded the upload, or there was nothing left to
            discard.
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/storage:
    get:
      tags: [Storage]
      operationId: getStorageOverview
      summary: Get the workspace storage overview
      description: |
        Bytes used against the plan's capacity plus the per-brand /
        per-project byte breakdown split by storage category:
        `deliverableCurrent` (tasks' current files), `versionOld` (superseded
        task versions — usually the biggest reclaimable chunk), `raw` (project
        raw files & assets), `headerAttachment`, `brandFile`,
        `commentAttachment`, `hqFile` (HQ board files — workspace-level, so
        those rows carry a null `brandId`/`projectId`), and `trashed` (already
        in Trash, hard-deleted 30 days after trashing). Matches the in-app
        Storage page: summing `breakdown[].totalBytes` equals `usedBytes`.
        Media removed after the workspace's subscription ended (see *Removed
        media*) does not count toward `usedBytes` or any category. A removed
        file never did; since 1.109.0, comment attachments and HQ board files
        are removed too, and a removed one no longer counts toward `usedBytes`
        or its `commentAttachment` / `hqFile` category.
        Since 1.218.2, `breakdown` lists EVERY bucket, however many the
        workspace has — it was cut to the first 1,000 (in no fixed order), so
        a workspace with more than 1,000 brand / project / category buckets
        got a breakdown that summed to less than `usedBytes`. The response is
        not paginated; the rows still come in no guaranteed order.
        Since 1.223.1, a stored file shared by several copies (a duplicated
        post, a task made from a raw file) counts ONCE in `breakdown`, as it
        always did in `usedBytes`: one copy carries its bytes — the copy in
        the most active category (`deliverableCurrent`, then `versionOld`,
        `headerAttachment`, `raw`, `trashed` last), then the oldest — and
        every other copy keeps its `fileCount` with no bytes of its own.
        Before, each copy was counted, so a workspace holding copies got a
        breakdown that summed to MORE than `usedBytes`.
      responses:
        "200":
          description: The storage overview.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorageOverview"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/storage/items:
    get:
      tags: [Storage]
      operationId: listStorageItems
      summary: List storage items
      description: |
        Every ACTIVE stored file (project + brand) with size (original +
        transcoded proxies), media metadata (duration, fps, width/height),
        storage category, and task/project lifecycle context. Keyset-paginated:
        echo `nextCursor` back as `cursor` for the next page. `totalCount` /
        `totalBytes` describe the FULL filtered set and are returned on the
        first (cursor-less) page only. Trashed items are not listed — browse
        those in the app's Trash.
      parameters:
        - name: brandId
          in: query
          description: >-
            Scopes to this brand or folder AND everything nested beneath it, so
            a parent brand also returns the files of its sub-brands and of the
            projects inside its sub-folders. Combine with `projectId` to narrow
            to a single project.
          schema: { type: string, format: uuid }
        - { name: projectId, in: query, schema: { type: string, format: uuid } }
        - name: category
          in: query
          description: Comma-separated subset of deliverableCurrent, versionOld, raw, headerAttachment, brandFile.
          schema: { type: string }
        - name: mimeClass
          in: query
          schema: { type: string, enum: [video, image, audio, doc, other] }
        - { name: search, in: query, schema: { type: string } }
        - { name: minSize, in: query, schema: { type: integer, minimum: 0 } }
        - { name: maxSize, in: query, schema: { type: integer, minimum: 0 } }
        - { name: minDuration, in: query, schema: { type: number, minimum: 0 } }
        - { name: minFps, in: query, schema: { type: number, minimum: 0 } }
        - { name: minHeight, in: query, schema: { type: integer, minimum: 0 } }
        - { name: maxHeight, in: query, schema: { type: integer, minimum: 0 } }
        - { name: createdBefore, in: query, schema: { type: string, format: date-time } }
        - { name: createdAfter, in: query, schema: { type: string, format: date-time } }
        - { name: approvedBefore, in: query, schema: { type: string, format: date-time } }
        - { name: approvedAfter, in: query, schema: { type: string, format: date-time } }
        - { name: postedBefore, in: query, schema: { type: string, format: date-time } }
        - { name: postedAfter, in: query, schema: { type: string, format: date-time } }
        - { name: archivedBefore, in: query, schema: { type: string, format: date-time } }
        - { name: archivedAfter, in: query, schema: { type: string, format: date-time } }
        - name: taskStatus
          in: query
          description: Comma-separated task statusGroup values (e.g. approved,posted).
          schema: { type: string }
        - { name: projectArchived, in: query, schema: { type: boolean } }
        - name: sort
          in: query
          description: |
            size_desc (default), size_asc, created_desc, created_asc, name_asc,
            name_desc, duration_desc, duration_asc, approved_desc, approved_asc,
            posted_desc, posted_asc, archived_desc, archived_asc, brand_asc,
            brand_desc, project_asc, project_desc.
          schema: { type: string }
        - { name: cursor, in: query, schema: { type: string } }
        - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 200, default: 100 } }
      responses:
        "200":
          description: One page of storage items.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorageItemsPage"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/storage/suggestions:
    get:
      tags: [Storage]
      operationId: getStorageCleanupSuggestions
      summary: Get cleanup suggestions
      description: |
        Rule-based cleanup picks with reclaimable byte totals. Rules overlap,
        so the synthetic `_total` row (the DISTINCT union across rules) is the
        honest "reclaimable" figure — never sum the rule rows. Feed a
        `ruleKey` into `POST /api/v1/storage/cleanup` to act on one.
      parameters:
        - name: keepVersions
          in: query
          description: "oldVersions rule: superseded versions to keep per task (default 0)."
          schema: { type: integer, minimum: 0, maximum: 50, default: 0 }
        - name: ageMonths
          in: query
          description: Age cutoff used by the age-based rules (default 6).
          schema: { type: integer, minimum: 1, maximum: 120, default: 6 }
        - name: largeBytes
          in: query
          description: largeStaleFiles size threshold in bytes (default 1000000000).
          schema: { type: integer, minimum: 1, default: 1000000000 }
      responses:
        "200":
          description: The suggestion rows (plus the `_total` union row).
          content:
            application/json:
              schema:
                type: object
                required: [suggestions]
                properties:
                  suggestions:
                    type: array
                    items:
                      $ref: "#/components/schemas/StorageSuggestion"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/storage/cleanup:
    post:
      tags: [Storage]
      operationId: cleanupStorage
      summary: Move storage to Trash
      description: |
        Frees space by moving items into the standard Trash — **nothing is
        deleted permanently**; trashed items are restorable in-app for 30 days
        and only the trash purge hard-deletes them. Two modes, exactly one per
        call: `selection` trashes explicit ids (a task's CURRENT file can only
        be reclaimed by trashing the whole task via `taskIds`); `rule` resolves
        and trashes ONE batch (≤500 items) of a cleanup rule and returns
        `remainingCount` — repeat the call until it reaches 0. `dryRun: true`
        validates and returns counts/bytes without changing anything. Requires
        a write-scope API key.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StorageCleanupRequest"
      responses:
        "200":
          description: What was (or would be, for dryRun) moved to Trash.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorageCleanupResult"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/ServerError"

  /api/v1/hook-tests:
    get:
      tags: [Trial Reels]
      operationId: listHookTests
      summary: List Instagram hook tests
      description: |
        **New in 1.201.0.** The workspace's Instagram hook tests, newest
        first. A hook test posts 2-3 video variants of one parent task (the
        same video with different openings) as Instagram trial reels at the
        same time, then picks the winner by the numbers. Cancelled tests are
        not listed.
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum: [running, decided]
        - name: brandId
          in: query
          required: false
          description: Only tests on this brand's posts.
          schema:
            type: string
            format: uuid
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 20
            default: 10
      responses:
        "200":
          description: The hook tests.
          content:
            application/json:
              schema:
                type: object
                required: [hookTests]
                properties:
                  hookTests:
                    type: array
                    items:
                      $ref: "#/components/schemas/HookTest"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "422":
          description: Trial reels aren't available on this deployment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"
    post:
      tags: [Trial Reels]
      operationId: startHookTest
      summary: Start an Instagram hook test
      description: |
        **New in 1.201.0.** Posts 2-3 video variants of a parent task as
        Instagram trial reels (shown to non-followers first) at ONE time,
        and lets the numbers pick the winning hook. Read the candidates and
        the brand's Instagram accounts first with
        `GET /api/v1/posts/{taskId}/hook-tests`.

        Each hook is saved as an Instagram-only Reel with a MANUAL trial (so
        Instagram never shares a losing hook to followers on its own) and
        scheduled through the same gates as any post — approval, plan,
        one post plan per deliverable. If any hook cannot be scheduled,
        nothing stays scheduled and the test is not created (`409`).

        Every hook is a trial reel, so the Instagram account is checked
        before anything is claimed: an account Instagram refused a trial reel
        from in the last 14 days, or one with fewer than about 1,000 followers
        as last synced, is refused with `409` (pick another account). An
        account whose follower count was never read is not refused here, and
        since 1.233.1 neither is an account Timeliner has lifted the follower
        limit for, because Instagram unlocked trial reels for it early.

        Rule fields left out (`metric`, `windowHours`, `onWin`) come from the
        workspace default. `saveAsDefault: true` also stores the rule as the
        default. Instagram's API cannot share a trial reel to followers: the
        winner is shared from the Instagram app, then recorded with
        `POST /api/v1/hook-tests/{id}/shared`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [taskId, hookTaskIds, scheduledAt, socialAccountId]
              properties:
                taskId:
                  type: string
                  format: uuid
                  description: The parent task, or one of its variants.
                hookTaskIds:
                  type: array
                  minItems: 2
                  maxItems: 3
                  items:
                    type: string
                    format: uuid
                  description: The hooks, in order A, B, C — active video variants of the parent with no posting plan.
                caption:
                  type: string
                  maxLength: 2200
                  description: One caption for every hook. Send this or `captions`.
                captions:
                  type: object
                  additionalProperties:
                    type: string
                    maxLength: 2200
                  description: One caption per hook, keyed by hook task id.
                scheduledAt:
                  type: string
                  format: date-time
                  description: When every hook goes live — at least 5 minutes from now.
                socialAccountId:
                  type: string
                  format: uuid
                  description: The brand's connected Instagram account.
                metric:
                  $ref: "#/components/schemas/HookTestMetric"
                windowHours:
                  type: integer
                  enum: [24, 48, 72]
                  description: How long the hooks are measured once the last one is live.
                onWin:
                  type: string
                  enum: [notify, remind]
                  description: "`remind` keeps a share-the-winner to-do open until it is marked shared."
                saveAsDefault:
                  type: boolean
            example:
              taskId: "6f1c2b8e-1a2b-4c3d-9e8f-0a1b2c3d4e5f"
              hookTaskIds: ["7a1c2b8e-1a2b-4c3d-9e8f-0a1b2c3d4e5f", "8b1c2b8e-1a2b-4c3d-9e8f-0a1b2c3d4e5f"]
              caption: "Most video agencies get this wrong."
              scheduledAt: "2026-11-03T16:00:00Z"
              socialAccountId: "9c1c2b8e-1a2b-4c3d-9e8f-0a1b2c3d4e5f"
              metric: shares
              windowHours: 24
      responses:
        "201":
          description: The test was started and every hook is scheduled.
          content:
            application/json:
              schema:
                type: object
                required: [hookTest]
                properties:
                  hookTest:
                    $ref: "#/components/schemas/HookTest"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: A hook already has a posting plan or is in another test, the parent has its own plan, Instagram refused a trial reel from `socialAccountId` in the last 14 days, the account has fewer than about 1,000 followers (unless Timeliner has lifted that limit for the account), or a hook could not be scheduled (nothing was posted).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "422":
          description: Trial reels aren't available on this deployment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/hook-tests/{id}:
    get:
      tags: [Trial Reels]
      operationId: getHookTest
      summary: Read one hook test
      description: |
        **New in 1.201.0.** Each hook's number on the test's metric, its gap
        to the best hook, its Instagram status and permalink, how far the
        measuring window is, and — once decided — the winner.
      parameters:
        - $ref: "#/components/parameters/HookTestId"
      responses:
        "200":
          description: The hook test.
          content:
            application/json:
              schema:
                type: object
                required: [hookTest]
                properties:
                  hookTest:
                    $ref: "#/components/schemas/HookTest"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    patch:
      tags: [Trial Reels]
      operationId: updateHookTest
      summary: Change what a running hook test is decided on
      description: |
        **New in 1.201.0.** `{ metric }` — the in-app card's "Pick the winner
        by". Only a RUNNING test (`409` once decided).
      parameters:
        - $ref: "#/components/parameters/HookTestId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [metric]
              properties:
                metric:
                  $ref: "#/components/schemas/HookTestMetric"
            example:
              metric: saves
      responses:
        "200":
          description: The test after the change.
          content:
            application/json:
              schema:
                type: object
                required: [hookTest]
                properties:
                  hookTest:
                    $ref: "#/components/schemas/HookTest"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Trial Reels]
      operationId: stopHookTest
      summary: Stop a running hook test
      description: |
        **New in 1.201.0.** The test is removed and never decided. The hooks'
        posts stay exactly as they are — a scheduled hook still posts unless
        you unschedule it (`DELETE /api/v1/posts/{taskId}/schedule`).
        `409` once the test is decided.
      parameters:
        - $ref: "#/components/parameters/HookTestId"
      responses:
        "200":
          description: The test was stopped.
          content:
            application/json:
              schema:
                type: object
                required: [stopped, id]
                properties:
                  stopped:
                    type: boolean
                  id:
                    type: string
                    format: uuid
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/hook-tests/{id}/shared:
    post:
      tags: [Trial Reels]
      operationId: markHookTestShared
      summary: Record that the winning hook was shared to followers
      description: |
        **New in 1.201.0.** Instagram's API cannot share a trial reel to
        followers, so a person shares the winner from the Instagram app;
        this records it and closes the test's "share the winner" to-do. Only
        a decided test with a winner that is not marked yet (`409` else).
      parameters:
        - $ref: "#/components/parameters/HookTestId"
      responses:
        "200":
          description: The test after the change.
          content:
            application/json:
              schema:
                type: object
                required: [hookTest]
                properties:
                  hookTest:
                    $ref: "#/components/schemas/HookTest"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/posts/{taskId}/hook-tests:
    get:
      tags: [Trial Reels]
      operationId: getPostHookTests
      summary: What a hook test on this post can use, and its tests
      description: |
        **New in 1.201.0.** For a parent task (or one of its variants): every
        variant with `blockedReason` (`notVideo`, `alreadyPlanned`,
        `inAnotherTest`) or null when it can be a hook, the brand's connected
        Instagram accounts, the workspace's default rule, whether the parent
        has its own posting plan (then it cannot run a test), and its last 5
        tests. A plain task answers `400`.
      parameters:
        - name: taskId
          in: path
          required: true
          description: The parent task, or one of its variants.
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The post's hook-test state.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostHookTests"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "422":
          description: Trial reels aren't available on this deployment.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/posts/{taskId}/trial-repost:
    get:
      tags: [Trial Reels]
      operationId: getTrialRepost
      summary: Read a post's "Repost as trial" rule
      description: |
        **New in 1.201.0.** Whether this post can carry the rule (a published
        Instagram Reel — a carousel never can), its rule, and — when this post
        IS a trial-reel copy the rule made — which edits it still needs before
        it can be scheduled.
      parameters:
        - $ref: "#/components/parameters/TrialRepostTaskId"
      responses:
        "200":
          description: The post's repost-as-trial state.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TrialRepost"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
    put:
      tags: [Trial Reels]
      operationId: setTrialRepost
      summary: Set a post's "Repost as trial" rule
      description: |
        **New in 1.201.0.** On a PUBLISHED Instagram Reel: make a trial-reel
        copy as a DRAFT every `intervalDays` days (1-90), or once the reel
        passes `viewsThreshold` views. Replaces and restarts any rule
        already on the post. A copy cannot be scheduled until a person
        changes its opening line AND its cover or video — Instagram flags a
        near-identical re-post as unoriginal.
      parameters:
        - $ref: "#/components/parameters/TrialRepostTaskId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [trigger]
              properties:
                trigger:
                  type: string
                  enum: [interval, views]
                intervalDays:
                  type: ["integer", "null"]
                  minimum: 1
                  maximum: 90
                viewsThreshold:
                  type: ["integer", "null"]
                  minimum: 1
            example:
              trigger: interval
              intervalDays: 14
      responses:
        "200":
          description: The post's state after the change.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TrialRepost"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          description: The post is not a published Instagram Reel, or it posts as a carousel.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorEnvelope"
        "500":
          $ref: "#/components/responses/ServerError"
    delete:
      tags: [Trial Reels]
      operationId: removeTrialRepost
      summary: Remove a post's "Repost as trial" rule
      description: |
        **New in 1.201.0.** Copies the rule already made stay, each still
        waiting for its edit. `404` when the post has no rule.
      parameters:
        - $ref: "#/components/parameters/TrialRepostTaskId"
      responses:
        "200":
          description: The rule was removed.
          content:
            application/json:
              schema:
                type: object
                required: [removed]
                properties:
                  removed:
                    type: boolean
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"
  /api/v1/analytics/social/trial-reels:
    get:
      tags: [Trial Reels]
      operationId: getTrialReelAnalytics
      summary: Trial reels and hook tests in a window
      description: |
        **New in 1.201.0.** Analytics → Instagram → Trial reels: how many
        trial reels went live in the window (`from`/`to`, default the last
        30 days), up to 50 of them newest first with their latest views (each
        marked when it is a hook of a hook test), and the window's hook tests
        — running now, decided, with a clear winner, winners shared to
        followers, the winner's average lead over the runner-up — plus the 6
        most recent tests.
      parameters:
        - name: from
          in: query
          required: false
          schema:
            type: string
            format: date-time
        - name: to
          in: query
          required: false
          schema:
            type: string
            format: date-time
        - name: brandId
          in: query
          required: false
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The window's trial reels and hook tests.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TrialReelAnalytics"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/ServerError"
webhooks:
  task.completed:
    post:
      tags: [Webhooks]
      operationId: onTaskCompleted
      summary: task.completed
      description: |
        **Sent by Timeliner to your endpoint** when a task transitions into the
        `approved` status group. The request body is a signed `WebhookEnvelope`
        whose `data` is a `TaskCompletedData`. Respond `2xx` to acknowledge.


        Retries depend on WHY the delivery failed. A timeout, a dropped
        connection or a `5xx` — plus `408`, `425` and `429` — is treated as
        transient and retried with backoff (1m, 5m, 30m, 2h, 6h), dead after 6
        attempts. Any other `4xx`, and a `3xx` (redirects are never followed),
        says the request itself is wrong, so it is retried only twice more
        (~6 minutes) and then marked dead. Giving up auto-disables the
        subscription and emails the workspace admins; re-enable it with
        `PATCH /api/v1/webhooks/{id}` once the endpoint is fixed.


        Pausing a subscription (`active: false`) also stops deliveries that
        were ALREADY queued for it: each is closed out as `dead` with
        `subscription disabled` and never sent.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskCompletedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  post.status_changed:
    post:
      tags: [Webhooks]
      operationId: onPostStatusChanged
      summary: post.status_changed
      description: |
        **Sent by Timeliner to your endpoint** on any post status change — both
        the approval axis (`statusKind: approval`) and the scheduling axis
        (`statusKind: scheduling`). The request body is a signed
        `WebhookEnvelope` whose `data` is a `PostStatusChangedData`. A post that
        reaches `approved` emits both this event and `task.completed`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostStatusChangedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  task.created:
    post:
      tags: [Webhooks]
      operationId: onTaskCreated
      summary: task.created
      description: |
        **Sent by Timeliner to your endpoint** when a task is created. Body is a
        signed `WebhookEnvelope` whose `data` is a `TaskCreatedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskCreatedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  task.updated:
    post:
      tags: [Webhooks]
      operationId: onTaskUpdated
      summary: task.updated
      description: |
        **Sent by Timeliner to your endpoint** when a task's fields change. Body
        is a signed `WebhookEnvelope` whose `data` is a `TaskUpdatedData`
        (`data.changed` lists which fields moved).

        **Who made the change (1.127.0).** `data.actorId` is the workspace member
        who made it and `data.actorName` their display name — the same values
        the paired `task.status_changed` event carries for a status move. A
        change made through the API is credited to the member who created the
        API key. `actorId` is null when no member made it — a client reviewing
        through a share link, or an automation or approval window acting under a
        system name — and `actorName` then carries the client's or the system's
        name, so count `actorId` for per-member totals. Two automatic moves are
        credited to the member behind them: a version auto-submitted for review
        to its uploader, and a review-timeout revert to the member whose
        comment started it.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskUpdatedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  task.trashed:
    post:
      tags: [Webhooks]
      operationId: onTaskTrashed
      summary: task.trashed
      description: |
        **Sent by Timeliner to your endpoint** when a task is moved to Trash.
        Body is a signed `WebhookEnvelope` whose `data` is a `TaskTrashedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskTrashedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  project.trashed:
    post:
      tags: [Webhooks]
      operationId: onProjectTrashed
      summary: project.trashed
      description: |
        **Sent by Timeliner to your endpoint** when a project is moved to Trash
        (its tasks are cascaded; one event fires for the project). Body is a
        signed `WebhookEnvelope` whose `data` is a `ProjectTrashedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProjectTrashedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  custom.column_changed:
    post:
      tags: [Webhooks]
      operationId: onCustomColumnChanged
      summary: custom.column_changed
      description: |
        **Sent by Timeliner to your endpoint** when a task's custom-column cell
        value is set. Body is a signed `WebhookEnvelope` whose `data` is a
        `CustomColumnChangedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CustomColumnChangedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  payment.recorded:
    post:
      tags: [Webhooks]
      operationId: onPaymentRecorded
      summary: payment.recorded
      description: |
        **Sent by Timeliner to your endpoint** when a payment lands in the
        append-only ledger — a mark-paid settlement (`data.settlement: true`)
        or a free-form recorded payment (`false`). Body is a signed
        `WebhookEnvelope` whose `data` is a `PaymentRecordedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaymentRecordedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  payment.voided:
    post:
      tags: [Webhooks]
      operationId: onPaymentVoided
      summary: payment.voided
      description: |
        **Sent by Timeliner to your endpoint** when a ledger payment is
        cancelled by its reversal row (mark-unpaid or an explicit void). Both
        rows stay in the ledger. Body is a signed `WebhookEnvelope` whose
        `data` is a `PaymentVoidedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaymentVoidedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  task.status_changed:
    post:
      tags: [Webhooks]
      operationId: onTaskStatusChanged
      summary: task.status_changed
      description: |
        **Sent by Timeliner to your endpoint** on every status-group move, from every
        surface (board drag, review actions, share-link approvals, automations, the
        API). Narrower than `task.updated`, which also fires for assignee and field
        edits — subscribe here when the trigger is "a task moved". Body is a signed
        `WebhookEnvelope` whose `data` is a `TaskStatusChangedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskStatusChangedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  comment.created:
    post:
      tags: [Webhooks]
      operationId: onCommentCreated
      summary: comment.created
      description: |
        **Sent by Timeliner to your endpoint** when a review comment lands on a task —
        from a member (app or API) or from a share-link guest (`isGuest: true`,
        `authorId: null`). `text` is capped at 2,000 characters with @-mention markup
        stripped. Body is a signed `WebhookEnvelope` whose `data` is a
        `CommentCreatedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CommentCreatedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  version.uploaded:
    post:
      tags: [Webhooks]
      operationId: onVersionUploaded
      summary: version.uploaded
      description: |
        **Sent by Timeliner to your endpoint** when a new version lands on a task —
        browser uploads, API uploads (`source: api`) and the desktop drive
        (`source: desktop`) alike. Body is a signed `WebhookEnvelope` whose `data` is
        a `VersionUploadedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VersionUploadedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  file.uploaded:
    post:
      tags: [Webhooks]
      operationId: onFileUploaded
      summary: file.uploaded
      description: |
        **Sent by Timeliner to your endpoint** when a raw project file (not a task
        version) finishes uploading. Body is a signed `WebhookEnvelope` whose `data`
        is a `FileUploadedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FileUploadedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  project.created:
    post:
      tags: [Webhooks]
      operationId: onProjectCreated
      summary: project.created
      description: |
        **Sent by Timeliner to your endpoint** when a project is created, from the
        app or the API. Body is a signed `WebhookEnvelope` whose `data` is a
        `ProjectCreatedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProjectCreatedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  post.published:
    post:
      tags: [Webhooks]
      operationId: onPostPublished
      summary: post.published
      description: |
        **Sent by Timeliner to your endpoint** when a scheduled post's publish run
        finishes with at least one live channel. `partial` is true when another
        channel failed or was left for manual posting; `platforms[]` carries every
        channel's outcome and permalink. Also sent (1.102.0) when a team member
        marks a post they published themselves as posted in the app — then
        `partial` is false and every channel reports `published` with
        `error: null`, including one an earlier publish run left failed or for
        manual posting; `permalink` is set only on a channel Timeliner itself
        published, `null` on the rest. Body is a signed `WebhookEnvelope` whose
        `data` is a `PostPublishedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostPublishedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  post.failed:
    post:
      tags: [Webhooks]
      operationId: onPostFailed
      summary: post.failed
      description: |
        **Sent by Timeliner to your endpoint** when a scheduled post's publish run
        finishes with no live channel and at least one failure (channels left for
        manual posting alone do not fire it). `platforms[]` carries each channel's
        error. Body is a signed `WebhookEnvelope` whose `data` is a `PostFailedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PostFailedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  intake.submitted:
    post:
      tags: [Webhooks]
      operationId: onIntakeSubmitted
      summary: intake.submitted
      description: |
        **Sent by Timeliner to your endpoint** when a client submits (or resubmits)
        a brief through an intake form, before any auto-approval. Body is a signed
        `WebhookEnvelope` whose `data` is an `IntakeSubmittedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/IntakeSubmittedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  share.opened:
    post:
      tags: [Webhooks]
      operationId: onShareOpened
      summary: share.opened
      description: |
        **Sent by Timeliner to your endpoint** when a share link is opened. Throttled
        to one event per viewer per link per hour. `viewerUserId` is set when the
        viewer is a signed-in member; anonymous viewers arrive with both viewer
        fields null. Body is a signed `WebhookEnvelope` whose `data` is a
        `ShareOpenedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ShareOpenedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  member.invited:
    post:
      tags: [Webhooks]
      operationId: onMemberInvited
      summary: member.invited
      description: |
        **Sent by Timeliner to your endpoint** when a team member or guest is
        invited to the workspace. Body is a signed `WebhookEnvelope` whose `data` is
        a `MemberInvitedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MemberInvitedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  automation.triggered:
    post:
      tags: [Webhooks]
      operationId: onAutomationTriggered
      summary: automation.triggered
      description: |
        **Sent by Timeliner to the endpoint an automation rule names** each
        time a rule with a "Call a webhook" action fires. Not subscribable —
        the rule, not the subscription, decides the delivery. Body is a signed
        `WebhookEnvelope` whose `data` is an `AutomationTriggeredData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AutomationTriggeredEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  member.joined:
    post:
      tags: [Webhooks]
      operationId: onMemberJoined
      summary: member.joined
      description: |
        **Sent by Timeliner to your endpoint** when an invitation is accepted and the
        membership is live. Body is a signed `WebhookEnvelope` whose `data` is a
        `MemberJoinedData`.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MemberJoinedDataEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  time_entry.created:
    post:
      tags: [Webhooks]
      operationId: onTimeEntryCreated
      summary: time_entry.created
      description: |
        **Sent by Timeliner to your endpoint** when a timer is started on a task (a new entry, `running: true`) or a time entry is added by hand. Body is a signed `WebhookEnvelope` whose `data` is a `TimeEntry`. Since 1.207.0.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TimeEntryCreatedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  time_entry.updated:
    post:
      tags: [Webhooks]
      operationId: onTimeEntryUpdated
      summary: time_entry.updated
      description: |
        **Sent by Timeliner to your endpoint** when a time entry changes: a timer is paused, resumed, stopped (by its member, by starting a timer on another task, by trashing the task, or by the 24-hour auto-stop) or an entry is edited. Body is a signed `WebhookEnvelope` whose `data` is a `TimeEntry`. Since 1.207.0.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TimeEntryUpdatedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.
  time_entry.deleted:
    post:
      tags: [Webhooks]
      operationId: onTimeEntryDeleted
      summary: time_entry.deleted
      description: |
        **Sent by Timeliner to your endpoint** when a time entry is deleted, or a just-started timer is discarded. Not sent for entries removed with a permanently deleted task, project or brand (`GET /api/v1/time-entries?includeDeleted=true` lists a permanently deleted task's entries). Body is a signed `WebhookEnvelope` whose `data` is a `DeletedTimeEntry`. Since 1.207.0.
      parameters:
        - $ref: "#/components/parameters/SignatureHeader"
        - $ref: "#/components/parameters/EventHeader"
        - $ref: "#/components/parameters/DeliveryHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TimeEntryDeletedEvent"
      responses:
        "200":
          description: Acknowledged. Any 2xx marks the delivery successful.

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: tlsk_<48 hex chars>
      description: |
        Workspace API key issued from **Settings → Workspace → API Keys**.
        Pass as `Authorization: Bearer tlsk_…`.

        Keys have a **scope**: `full` (read + write) or `read` (read-only). A
        read-only key may call any `GET`, but any write (`POST`/`PATCH`/`DELETE`)
        is rejected with `401` (the key is valid but not permitted to mutate).

  parameters:
    HookTestId:
      name: id
      in: path
      required: true
      description: The hook test's UUID (from `GET /api/v1/hook-tests`).
      schema:
        type: string
        format: uuid
    TrialRepostTaskId:
      name: taskId
      in: path
      required: true
      description: The post's task UUID — a published Instagram Reel.
      schema:
        type: string
        format: uuid
    Limit:
      name: limit
      in: query
      required: false
      description: Number of items per page (1–100). Defaults to 50.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 50
    Before:
      name: before
      in: query
      required: false
      description: ISO 8601 timestamp cursor; pass the previous response's `nextBefore`.
      schema:
        type: string
        format: date-time
    ProjectId:
      name: id
      in: path
      required: true
      description: The project's UUID.
      schema:
        type: string
        format: uuid
    BatchLinkId:
      name: linkId
      in: path
      required: true
      description: The batch share link's id (from the list endpoint).
      schema:
        type: string
        format: uuid
    TaskId:
      name: id
      in: path
      required: true
      description: The task's UUID.
      schema:
        type: string
        format: uuid
    TranscriptIncludeSegments:
      name: includeSegments
      in: query
      required: false
      description: |
        `true` adds `segments`: the transcript's timed lines — the lines the
        Transcript tab shows — each with its `start` and `end` in seconds.
        Since 1.206.0.
      schema:
        type: boolean
        default: false
    TranscriptIncludeWords:
      name: includeWords
      in: query
      required: false
      description: |
        `true` adds `words`: every spoken word, in order, with its own `start`
        and `end` in seconds. Long — on a long video ask for a window with
        `fromSeconds` / `toSeconds`. Since 1.206.0.
      schema:
        type: boolean
        default: false
    TranscriptFromSeconds:
      name: fromSeconds
      in: query
      required: false
      description: |
        Keep only the lines and words still being spoken at or after this
        second. Needs `includeSegments` or `includeWords`; less than
        `toSeconds` when both are sent. Since 1.206.0.
      schema:
        type: number
        minimum: 0
    TranscriptToSeconds:
      name: toSeconds
      in: query
      required: false
      description: |
        Keep only the lines and words that start before this second. Needs
        `includeSegments` or `includeWords`. Since 1.206.0.
      schema:
        type: number
        minimum: 0
    CustomColumnId:
      name: id
      in: path
      required: true
      description: The custom column's UUID (from `GET /api/v1/custom-columns`).
      schema:
        type: string
        format: uuid
    MemberId:
      name: id
      in: path
      required: true
      description: The member's UUID.
      schema:
        type: string
        format: uuid
    WorkloadBlockId:
      name: id
      in: path
      required: true
      description: The workload block's UUID.
      schema:
        type: string
        format: uuid
    BrandId:
      name: id
      in: path
      required: true
      description: The brand's (Node) UUID.
      schema:
        type: string
        format: uuid
    BrandMemberId:
      name: memberId
      in: path
      required: true
      description: The member's UUID (from `GET /api/v1/members`).
      schema:
        type: string
        format: uuid
    ThumbnailPostId:
      name: taskId
      in: path
      required: true
      description: The post's task UUID.
      schema:
        type: string
        format: uuid
    ThumbnailGenerationId:
      name: generationId
      in: path
      required: true
      description: A generation id from `POST /api/v1/posts/{taskId}/thumbnails`.
      schema:
        type: string
        format: uuid
    BrandSpeakerId:
      name: speakerId
      in: path
      required: true
      description: A speaker id from `GET /api/v1/brands/{id}/speakers`.
      schema:
        type: string
        format: uuid
    UploadId:
      name: id
      in: path
      required: true
      description: The upload id returned by `POST /api/v1/files/uploads`.
      schema:
        type: string
        format: uuid
    WebhookId:
      name: id
      in: path
      required: true
      description: The webhook subscription's UUID.
      schema:
        type: string
        format: uuid
    HqBoardId:
      name: id
      in: path
      required: true
      description: The HQ board's UUID.
      schema:
        type: string
        format: uuid
    HqItemId:
      name: id
      in: path
      required: true
      description: The HQ item's UUID.
      schema:
        type: string
        format: uuid
    HqStageId:
      name: stageId
      in: path
      required: true
      description: A stage of the board — from `GET /api/v1/hq/boards/{id}`.
      schema:
        type: string
        format: uuid
    HqFieldId:
      name: fieldId
      in: path
      required: true
      description: A custom field of the board — from `GET /api/v1/hq/boards/{id}`.
      schema:
        type: string
        format: uuid
    HqOptionId:
      name: optionId
      in: path
      required: true
      description: An option of the select field.
      schema:
        type: string
        format: uuid
    HqCommentId:
      name: commentId
      in: path
      required: true
      description: A comment on the item — from `GET /api/v1/hq/items/{id}/comments`.
      schema:
        type: string
        format: uuid
    SignatureHeader:
      name: X-Timeliner-Signature
      in: header
      required: true
      description: |
        `t=<unixSeconds>,v1=<hex>`. `v1` is `HMAC-SHA256(secret, "<t>.<rawBody>")`
        as a hex digest, keyed by your subscription secret. Verify with a
        constant-time compare and reject if `t` is more than 300 seconds old.
      schema:
        type: string
      example: t=1717372800,v1=4f1e2d3c4b5a69788796a5b4c3d2e1f0a1b2c3d4e5f60718293a4b5c6d7e8f90
    EventHeader:
      name: X-Timeliner-Event
      in: header
      required: true
      description: The event type (mirrors the envelope `type`).
      schema:
        $ref: "#/components/schemas/WebhookEventType"
    DeliveryHeader:
      name: X-Timeliner-Delivery
      in: header
      required: true
      description: The delivery / event UUID (mirrors the envelope `id`); use it to dedupe.
      schema:
        type: string
        format: uuid

    BrandKitFileId:
      name: fileId
      in: path
      required: true
      description: A file of this brand (`GET /api/v1/brands/{id}/files`).
      schema:
        type: string
        format: uuid
    BrandChargeId:
      name: chargeId
      in: path
      required: true
      description: A one-off charge id (`GET /api/v1/brands/{id}/charges`).
      schema:
        type: string
        format: uuid
    BrandFactId:
      name: factId
      in: path
      required: true
      description: The rule's / example's / fact's id, as the brand's matching GET lists it.
      schema:
        type: string
        format: uuid
    CustomStatusId:
      name: id
      in: path
      required: true
      description: The custom status id (`GET /api/v1/custom-statuses`).
      schema:
        type: string
        format: uuid
  responses:
    BadRequest:
      description: The request body or a query parameter failed validation.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
    Unauthorized:
      description: Missing or invalid `Authorization` header.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
          example:
            error: Invalid or missing API key
    Forbidden:
      description: |
        The action requires a higher plan, the key lacks the needed scope
        (`code: insufficient_scope`), the workspace's billing is locked
        (`code: billing_locked` — every write, see *Billing lock* above), an
        upload endpoint's workspace has its uploads paused
        (`code: UPLOADS_PAUSED`, see *Uploads paused*), or the action is
        otherwise not permitted.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
          example:
            error: Dual deadline mode requires a Studio plan or higher
    OutOfCredits:
      description: |
        **New in 1.143.0.** The workspace is out of credits: the work this
        call needed costs credits — a raw file's transcription (a task's video
        is transcribed free since 1.228.4), or since 1.174.0 an AI caption or
        AI tag suggestions — Timeliner is charging for them, and
        what the workspace has left cannot cover it. This answer only comes
        once blocking is switched on. Nothing was started and
        nothing was written. `message` is Timeliner's own sentence
        for the API key's creator — a workspace admin is told the workspace's
        way to keep working (turn on extra usage, raise its cap, or when
        credits reset), anyone else to ask an admin. Relay it and stop calling
        until credits are available; the same call succeeds again afterwards.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OutOfCreditsFailure"
          example:
            status: failed
            reason: out_of_credits
            message: This workspace is out of credits. Turn on extra usage under Credits in Plan & Billing to keep working.
    NotFound:
      description: The resource does not exist in this workspace.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
    HqItemNotFound:
      description: |
        No HQ item with this id is in your workspace, and nothing was written.
        When the id looks **shortened** — its first 8 characters match an HQ
        item of your OWN workspace, but the rest was padded or made up
        (`faea17df-0000-0000-0000-000000000000`) — `error` says so and, when
        exactly one item matches, names that item's full id to retry with
        (since 1.118.1; on `POST /api/v1/hq/items/{id}/values` since 1.190.1).
        An item id is always the full 36 characters, exactly as it was
        returned. An unknown id, or an item in another workspace,
        keeps the plain `{"error":"Item not found"}` body: the two are
        deliberately indistinguishable, and no body echoes the sent id back.
        `DELETE` always answers the plain body.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
          examples:
            unknownItem:
              summary: Unknown item id, or an item in another workspace
              value:
                error: Item not found
            shortenedId:
              summary: A shortened id whose first 8 characters match one of your items
              value:
                error: >-
                  Item not found. No HQ item has that exact id, but one HQ item
                  in this workspace has an id starting with the same 8
                  characters: faea17df-aafd-4568-9e4c-26c5db1c819f. The id sent
                  looks shortened and filled back out — an HQ item id is always
                  the full 36 characters, exactly as list_hq_items, get_hq_item
                  or create_hq_item returned it, never shortened or padded. If
                  that is the item you meant, retry with its full id.
            shortenedAmbiguous:
              summary: A shortened id whose first 8 characters match several items
              value:
                error: >-
                  Item not found. No HQ item has that exact id, and several HQ
                  items in this workspace start with the same 8 characters, so
                  the id sent looks shortened — an HQ item id is always the full
                  36 characters, never shortened or padded. Take the item's full
                  id from list_hq_items (GET /api/v1/hq/boards/{id}/items) and
                  retry.
    TaskShareLinkNotFound:
      description: |
        No active task with this id is in your workspace, and nothing was
        written. Since 1.149.2 the body names the mistake when it can:
        - The id is a task of your workspace that is **in the Trash** (it
          shows in `GET /api/v1/tasks` with `status: "trashed"`): `error` says
          so and `reason` is `task_trashed`. A task in the Trash has no share
          link and the API cannot restore it — a person restores the task (or
          its project) from the app's Trash page. `task_deleted` is the same
          for a deleted task, which cannot be restored.
        - The id is another row of your workspace — a project, brand or
          folder, HQ item, file or custom column — and `error` says which.
        - The id looks **shortened** — its first 8 characters match a task of
          your workspace, the rest padded or made up — and `error` names that
          task's full id when exactly one matches.
        An unknown id, or any task in another workspace (trashed or not),
        keeps the plain `{"error":"Task not found"}` body: the two are
        deliberately indistinguishable, and no body echoes the sent id back.
        Every named body still starts `Task not found.`
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/TaskShareLinkNotFoundError"
          examples:
            unknownTask:
              summary: Unknown id, or a task in another workspace
              value:
                error: Task not found
            trashedTask:
              summary: A task of your workspace that is in the Trash
              value:
                error: >-
                  Task not found. That task is in the Trash (list_tasks and
                  get_task show it with status "trashed"), and a task in the
                  Trash has no share link. The API cannot restore it: a person
                  restores the task — or its project, if the whole project was
                  moved to the Trash — from the app's Trash page, and then this
                  call works. Otherwise share a task whose status is "active".
                reason: task_trashed
            projectIdInPath:
              summary: A project's id was sent in the task's place
              value:
                error: >-
                  Task not found. That id is a project in this workspace — pass
                  one of its task ids (from list_tasks, or GET
                  /api/v1/tasks?projectId=…) in the path.
            shortenedId:
              summary: A shortened id whose first 8 characters match one of your tasks
              value:
                error: >-
                  Task not found. No task has that exact id, but one task in
                  this workspace has an id starting with the same 8 characters:
                  3f2a9c10-5b7e-4d21-9a8c-1e6f0b2d4c55. The id sent looks
                  shortened and filled back out — a task id is always the full
                  36 characters, exactly as list_tasks, get_task or create_task
                  returned it, never shortened or padded. If that is the task
                  you meant, retry with its full id.
    ServerError:
      description: An unexpected server error occurred. Retry or contact support if it persists.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
          example:
            error: Internal server error
    Conflict:
      description: The request conflicts with a resource limit (e.g. the workspace's 20-webhook cap).
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
    RateLimited:
      description: |
        The destructive budget for this API key or workspace is exhausted.

        Every `DELETE` endpoint on this API draws on ONE shared budget, so
        alternating between resources does not raise the ceiling. Three windows
        apply, and the response names whichever one refused the call:

        | Window | Scope | Limit |
        |---|---|---|
        | Burst | API key | 20 deletes per minute |
        | Daily | API key | 200 deletes per 24 h |
        | Daily | Workspace | 500 deletes per 24 h |

        The budget counts ATTEMPTS, not successful deletions — a `404` and an
        idempotent repeat consume budget exactly as a real deletion does.

        Honour the `Retry-After` header (whole seconds); the same figure is
        repeated in the body as `retryAfterSeconds`. Do not retry in a tight
        loop. The two daily ceilings are tunable defaults; the per-minute burst
        is the documented contract.
      headers:
        Retry-After:
          description: Whole seconds to wait before retrying. Always at least 1.
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/RateLimitErrorEnvelope"
          example:
            error: Delete rate limit exceeded — too many deletes per minute for this API key
            retryAfterSeconds: 37
    CommentBudgetExceeded:
      description: |
        The comment budget for this API key or workspace is spent (since
        1.137.0). `POST /api/v1/tasks/{id}/comments` is metered by three
        windows, and the response names whichever one refused the call:

        | Window | Scope | Limit |
        |---|---|---|
        | Burst | API key | 60 comments per minute |
        | Daily | API key | 2,000 comments per 24 h |
        | Daily | Workspace | 5,000 comments per 24 h |

        The budget counts ATTEMPTS — a refused body spends it too. Nothing is
        posted and nobody is notified. Honour the `Retry-After` header (whole
        seconds; repeated in the body as `retryAfterSeconds`) and do not retry
        in a tight loop. The daily ceilings are tunable defaults. The key's
        general per-minute request limit also answers `429`, with the
        `rate_limited` body (`code`, `limit`, `windowSeconds`).
      headers:
        Retry-After:
          description: Whole seconds to wait before retrying. Always at least 1.
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/RateLimitErrorEnvelope"
          example:
            error: Comment rate limit exceeded — too many comments per minute for this API key
            retryAfterSeconds: 23
    TooManyRequests:
      description: |
        The key's per-minute rate limit was exceeded. Back off for
        `Retry-After` seconds. Headers: `Retry-After`, `X-RateLimit-Limit`,
        `X-RateLimit-Remaining`, `X-RateLimit-Reset`.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorEnvelope"
          example:
            error: Rate limit exceeded
            code: rate_limited
            limit: 300
            windowSeconds: 60
            retryAfterSeconds: 12

  schemas:
    HookTestMetric:
      type: string
      enum: [views, watchThrough, shares, saves, engagementRate]
      description: |
        What picks the winner. `watchThrough` is the share of viewers the
        opening kept (1 − skip rate) — the number that measures the hook
        itself; `engagementRate` is interactions per account reached. Rates
        need 100 views to count.
    HookTest:
      type: object
      required: [id, parentTaskId, status, metric, windowHours, onWin, scheduledAt, hooks]
      properties:
        id:
          type: string
          format: uuid
        parentTaskId:
          type: string
          format: uuid
        parentTitle:
          type: string
        status:
          type: string
          enum: [running, decided]
        phase:
          type: ["string", "null"]
          enum: [scheduled, measuring, settling, due, null]
          description: Where a running test stands; null once decided.
        metric:
          $ref: "#/components/schemas/HookTestMetric"
        windowHours:
          type: integer
          enum: [24, 48, 72]
        onWin:
          type: string
          enum: [notify, remind]
        scheduledAt:
          type: string
          format: date-time
        windowStartsAt:
          type: ["string", "null"]
          format: date-time
          description: When the last hook went live and measuring began; null before.
        windowEndsAt:
          type: ["string", "null"]
          format: date-time
        outcome:
          type: ["string", "null"]
          enum: [winner, tie, insufficient, null]
        winnerTaskId:
          type: ["string", "null"]
          format: uuid
        decidedAt:
          type: ["string", "null"]
          format: date-time
        sharedAt:
          type: ["string", "null"]
          format: date-time
          description: When someone recorded sharing the winner to followers.
        instagramAccount:
          type: ["object", "null"]
          properties:
            id:
              type: string
              format: uuid
            handle:
              type: string
            followerCount:
              type: ["integer", "null"]
        hooks:
          type: array
          description: Best first.
          items:
            type: object
            properties:
              taskId:
                type: string
                format: uuid
              label:
                type: string
                enum: [A, B, C]
              title:
                type: string
              value:
                type: ["number", "null"]
                description: The hook's number on the test's metric (a 0-1 fraction for rates); null when Instagram has not reported it.
              deltaVsBest:
                type: ["number", "null"]
                description: Relative to the best hook (−0.25 = 25 % behind).
              isWinner:
                type: boolean
              instagramStatus:
                type: ["string", "null"]
                enum: [pending, publishing, published, failed, canceled, null]
              postStatus:
                type: ["string", "null"]
              permalink:
                type: ["string", "null"]
    PostHookTests:
      type: object
      properties:
        parentTaskId:
          type: string
          format: uuid
        parentPlanned:
          type: boolean
          description: The parent has its own posting plan — its variants cannot run a test.
        candidates:
          type: array
          items:
            type: object
            properties:
              taskId:
                type: string
                format: uuid
              title:
                type: string
              blockedReason:
                type: ["string", "null"]
                enum: [notVideo, alreadyPlanned, inAnotherTest, null]
        instagramAccounts:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              handle:
                type: string
              followerCount:
                type: ["integer", "null"]
        defaultRule:
          type: object
          properties:
            metric:
              $ref: "#/components/schemas/HookTestMetric"
            windowHours:
              type: integer
            onWin:
              type: string
        canSetDefault:
          type: boolean
        tests:
          type: array
          items:
            $ref: "#/components/schemas/HookTest"
    TrialRepost:
      type: object
      properties:
        eligible:
          type: boolean
          description: The post is a published Instagram Reel that can carry the rule.
        carousel:
          type: boolean
        rule:
          type: ["object", "null"]
          properties:
            trigger:
              type: string
              enum: [interval, views]
            intervalDays:
              type: ["integer", "null"]
            viewsThreshold:
              type: ["integer", "null"]
            status:
              type: string
              enum: [active, done, stopped]
            copiesMade:
              type: integer
            nextSlotAt:
              type: ["string", "null"]
              format: date-time
        copy:
          type: ["object", "null"]
          description: Set when this post IS a trial-reel copy — the edits it still needs before it can be scheduled.
          properties:
            needsOpeningEdit:
              type: boolean
            needsVisualEdit:
              type: boolean
    TrialReelAnalytics:
      type: object
      properties:
        window:
          type: object
          properties:
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
        trialReels:
          type: object
          properties:
            posted:
              type: integer
            totalViews:
              type: ["integer", "null"]
            avgViews:
              type: ["integer", "null"]
            items:
              type: array
              items:
                type: object
                properties:
                  taskId:
                    type: string
                    format: uuid
                  title:
                    type: string
                  publishedAt:
                    type: string
                    format: date-time
                  permalink:
                    type: ["string", "null"]
                  accountHandle:
                    type: ["string", "null"]
                  views:
                    type: ["integer", "null"]
                  isHook:
                    type: boolean
        hookTests:
          type: object
          properties:
            running:
              type: integer
            decided:
              type: integer
            withWinner:
              type: integer
            shared:
              type: integer
            avgWinnerLead:
              type: ["number", "null"]
              description: Winner / runner-up − 1, averaged (0.4 = the winner did 40 % better).
            recent:
              type: array
              items:
                $ref: "#/components/schemas/HookTest"
    ErrorEnvelope:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.

    YouTubeUploadAnswersError:
      type: object
      description: >-
        A `422` for a YouTube leg the uploader's answers do not let Timeliner
        upload (since 1.232.0 — YouTube API Services Terms §9.1, Developer
        Policies III.C.1 / III.C.3). Nothing was scheduled or written.
      required: [error, code]
      properties:
        error:
          type: string
          description: Human-readable sentence naming what to fix.
        code:
          type: string
          enum: [youtube_made_for_kids_required, youtube_metadata_invalid, youtube_upload_consent_required]
        issue:
          type: string
          description: >-
            On `youtube_metadata_invalid` only: which field and why, as the
            metadata codes `PATCH /posts/{taskId}` answers
            (`youtubeTitleTooLong`, `youtubeTitleMissing`,
            `youtubeTitleInvalidChars`, `youtubeDescriptionTooLong`,
            `youtubeDescriptionInvalidChars`, `youtubeTagsTooLong`).
          enum:
            - youtubeTitleTooLong
            - youtubeTitleMissing
            - youtubeTitleInvalidChars
            - youtubeDescriptionTooLong
            - youtubeDescriptionInvalidChars
            - youtubeTagsTooLong

    UploadTaskNotFoundError:
      type: object
      description: >-
        A `404` from the three upload endpoints (`POST /api/v1/files/uploads`,
        `POST /api/v1/files/upload-from-url`,
        `POST /api/v1/files/uploads/{id}/complete`). `reason` is present only
        on a plain `Task not found` (`task_not_found`, since 1.161.0 — no task
        with that id in your workspace: unknown, or another workspace's) and a
        plain `Folder not found` (`folder_not_found`, since 1.187.0 — no folder
        of the upload's project has that id, and it is nothing else your
        workspace owns; the two endpoints that take `folderId` only). Every
        other 404 here (a named mistake, an unknown project or upload) carries
        `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [task_not_found, folder_not_found]

    TaskCommentResolveNotFoundError:
      type: object
      description: >-
        A `404` from `PATCH /api/v1/tasks/{id}/comments/{commentId}`. `reason`
        is present on `Comment not found` only — no review comment on this task
        has that id (unknown, another task's or workspace's, or a task-chat
        message), since 1.169.0; `Task not found` carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [comment_not_found]

    TaskUpdateNotFoundError:
      type: object
      description: >-
        A `404` from `PATCH /api/v1/tasks/{id}`. `reason` is present only on
        the plain `Task not found` — no task with that id in your workspace
        (unknown, or another workspace's), since 1.166.0; a named mistake
        carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [task_not_found]

    ProjectCreateNotFoundError:
      type: object
      description: >-
        A `404` from `POST /api/v1/projects`. `reason` is present only on the
        plain `Node not found` — no brand, client or folder with that id in your
        workspace (unknown, or another workspace's), since 1.204.0; a named
        mistake carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [node_not_found]

    TaskCreateNotFoundError:
      type: object
      description: >-
        A `404` from `POST /api/v1/tasks`. `reason` is present only on the plain
        `Project not found` — no project with that id in your workspace
        (unknown, or another workspace's), since 1.192.0; a named mistake
        carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [project_not_found]

    CaptionGenerateNotFoundError:
      type: object
      description: >-
        A `404` from `POST /api/v1/posts/{taskId}/caption/generate`. `reason`
        is `task_not_found` on the plain `Post not found` (no task with that id
        in your workspace — unknown, or another workspace's) and
        `task_trashed` / `task_deleted` on a task of your workspace that is not
        active, since 1.203.0; a named id mistake carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [task_not_found, task_trashed, task_deleted]

    ScheduleNotFoundError:
      type: object
      description: >-
        A `404` from `POST` or `DELETE /api/v1/posts/{taskId}/schedule`.
        `reason` is `task_not_found` on the plain `Post not found` (no task with
        that id in your workspace — unknown, or another workspace's) and
        `task_trashed` / `task_deleted` on a task of your workspace that is not
        active, since 1.205.0; a named id mistake carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [task_not_found, task_trashed, task_deleted]

    PostUpdateNotFoundError:
      type: object
      description: >-
        A `404` from `PATCH /api/v1/posts/{taskId}`. `reason` is present only on
        the plain `Post not found` — no task with that id in your workspace
        (unknown, or another workspace's), since 1.190.0; a named mistake
        carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [task_not_found]

    StartUploadError:
      type: object
      description: >-
        A `400` from `POST /api/v1/files/uploads`. `reason` is present only
        when the file type is not one Timeliner accepts (1.155.0); every other
        refusal carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [file_type_not_allowed]

    DocAttachmentUploadError:
      type: object
      description: >-
        A `400` from `POST /api/v1/doc-attachments/upload-from-url`. `reason`
        and `maxBytes` are present only when the file is over a document
        attachment limit (1.153.0); every other refusal carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [file_too_large]
        maxBytes:
          type: integer
          description: The limit the file went over, in bytes.

    CompleteUploadError:
      type: object
      description: >-
        A `400` from `POST /api/v1/files/uploads/{id}/complete`. `reason` and
        the fields after it are present only when the listed parts hold fewer
        bytes than the size declared at start (`parts_short_of_declared_size`,
        since 1.156.0: `receivedBytes`, `declaredBytes`, `missingPartNumbers`)
        or when storage refused the part list and its own record of the parts
        names why (`part_list_refused`, since 1.214.0:
        `missingPartNumbers`, `unequalPartNumbers`,
        `etagMismatchPartNumbers`, `expectedPartBytes`) — either way nothing
        was completed and the upload is still open; every other refusal
        carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [parts_short_of_declared_size, part_list_refused]
        receivedBytes:
          type: integer
          minimum: 0
          description: Bytes the listed parts hold in storage.
        declaredBytes:
          type: integer
          minimum: 1
          description: The `size` declared when the upload started.
        missingPartNumbers:
          type: array
          items:
            type: integer
            minimum: 1
          description: >-
            `parts_short_of_declared_size`: part numbers from 1 to the
            upload's part count that are not both listed and stored — empty
            when every part arrived, then the declared `size` was wrong.
            `part_list_refused`: listed parts storage holds nothing for.
        unequalPartNumbers:
          type: array
          items:
            type: integer
            minimum: 1
          description: >-
            `part_list_refused` only: listed parts before the last whose stored
            size is not `expectedPartBytes`. PUT that part and every later one
            again, cut back to back at `expectedPartBytes`.
        etagMismatchPartNumbers:
          type: array
          items:
            type: integer
            minimum: 1
          description: >-
            `part_list_refused` only: listed parts whose `etag` is not the ETag
            storage holds for that part.
        expectedPartBytes:
          type:
            - integer
            - "null"
          minimum: 1
          description: >-
            `part_list_refused` only: the byte count every part before the last
            must have — the size most of them share. Null when no stored part
            comes before the last.

    TaskShareLinkNotFoundError:
      type: object
      description: >-
        The `404` of `GET`/`POST /api/v1/tasks/{id}/share-link`. `reason` is
        present only when the id is a task of your workspace that is not
        active; every other miss carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [task_trashed, task_deleted]

    ScheduleConflictError:
      type: object
      description: >-
        The `409` of `POST /api/v1/posts/{taskId}/schedule`. `code`, `heldBy`
        and `blockingTask` are present only when the other side of the
        deliverable already holds the post plan (since 1.151.0); `reason` only
        on a refusal a partner should tell apart without reading the sentence
        (since 1.160.1); every other conflict carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: >-
            Human-readable error message. On the parent/variant conflict it is
            exactly "A variant of this task already has its own post scheduled
            — unschedule it before scheduling the parent" or "The parent task
            already has a post scheduled — unschedule it before scheduling this
            variant on its own".
        code:
          type: string
          enum: [postScopeTaken]
        heldBy:
          type: string
          enum: [parent, variant]
          description: >-
            Which side holds the plan — the parent (when you scheduled a
            variant) or a variant (when you scheduled the parent).
        blockingTask:
          type: object
          nullable: true
          description: >-
            The task holding the plan — when several variants hold posts, the
            first one found. Unschedule it with `DELETE
            /api/v1/posts/{taskId}/schedule` if the user wants this post
            instead.
          required: [taskId, title, scheduledAt, overallStatus]
          properties:
            taskId:
              type: string
              format: uuid
            title:
              type: string
            scheduledAt:
              type: string
              format: date-time
              nullable: true
            overallStatus:
              type: string
              nullable: true
              description: Its post's scheduling status (draft, pending, manual, missed, failed).
        reason:
          type: string
          enum: [linkedin_video_too_large]
          description: >-
            `linkedin_video_too_large` (since 1.160.1) — the video the LinkedIn
            post would upload is over LinkedIn's 500 MB limit; `error` names its
            size. Upload a smaller file as a new version, or schedule without
            LinkedIn. Retrying the same call answers the same 409.

    NotTagColumnError:
      type: object
      description: >-
        A validation `400` from the tag endpoints (`POST
        /api/v1/custom-columns/{id}/tags`, `POST /api/v1/tasks/{id}/suggest-tags`).
        `reason` is present only when the column exists but is not a tag
        column; every other refusal carries `error` alone.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message.
        reason:
          type: string
          enum: [not_tag_column]

    AutomationRuleValidationError:
      type: object
      description: >-
        A validation `400` from the automation-rule writes. `reason` is present
        only on a refusal the caller cannot fix by changing the payload.
      required: [error]
      properties:
        error:
          type: string
          description: Human-readable error message (the in-app builder's wording).
        reason:
          type: string
          enum: [slack_not_connected]
          description: >-
            `slack_not_connected` — a `postToSlack` or `sendReviewLinkToSlack`
            action while the workspace's Slack is not connected. Stop and ask a person to
            connect Slack in Settings → Integrations; do not retry the call.

    DocEdit:
      type: object
      description: |
        One partial edit to a document — a task's (`editTaskDoc`) or an HQ
        item's (`editHqItemDoc`) — both documents cap at 1,000,000 characters. `html` is required on every op;
        `heading` only on `replaceSection` / `appendToSection`, `find` only on
        `replaceText` — a field an op does not take is a 400. `html` may be
        `""` only on `replaceSection` and `replaceText` (a deletion).
      additionalProperties: false
      properties:
        op:
          type: string
          enum: [append, prepend, replaceSection, appendToSection, replaceText]
        heading:
          type: string
          maxLength: 500
          description: The section heading's visible text (`replaceSection`, `appendToSection`).
        find:
          type: string
          minLength: 1
          maxLength: 1000000
          description: >-
            A piece of the stored HTML that occurs once (`replaceText`). Exact
            is safest; since 1.134.2 entity spelling of `&` / `"` / `'` / a
            hard space, whitespace runs and whitespace between tags are
            ignored when the verbatim text occurs nowhere.
        html:
          type: string
          maxLength: 1000000
          description: The HTML to insert or put in place.
      required: [op, html]

    DocEditError:
      type: object
      required: [error, code, index]
      properties:
        error:
          type: string
          description: Human-readable message naming the failing edit.
        code:
          type: string
          enum: [anchorNotFound, anchorAmbiguous, docNotSectionable, docTooLarge]
        index:
          type: integer
          minimum: 0
          description: Position of the failing edit in `edits`.
        matches:
          type: integer
          description: How many places matched (`anchorAmbiguous` only).
        reason:
          type: string
          enum: [find_text_absent, find_markup_differs]
          description: |
            `replaceText` + `anchorNotFound` only (since 1.224.0) — why `find`
            was not found, even with `&amp;` / `&nbsp;` spelling and whitespace
            between tags tolerated. `find_text_absent`: the quoted words are
            not in the document at all — it changed since you read it, or the
            quote was paraphrased; read it again and quote from that copy.
            `find_markup_differs`: the words are there, but the tags,
            attributes or punctuation around them differ from the stored HTML
            (a list item is stored as `<li><p>…</p></li>`, a line break as
            `<br>`, a block may carry `dir`, quotes may be curly); copy `find`
            from the stored HTML exactly.

    DocEditConflict:
      type: object
      required: [conflict, reason, error, currentRev]
      properties:
        conflict:
          type: boolean
        reason:
          type: string
          enum: [stale_base_rev, doc_still_changing]
          description: |
            Machine-readable cause — branch on this, not on `error`.
            `stale_base_rev`: `baseRev` was sent and the document is no longer
            at that rev. `doc_still_changing`: no `baseRev` was sent and every
            attempt to save lost to another writer.
        error:
          type: string
          description: |
            Short explanation naming the rev and the way forward. Never carries
            document content.
        currentRev:
          type: integer
          description: The document's rev when the request gave up.

    RateLimitErrorEnvelope:
      type: object
      required: [error, retryAfterSeconds]
      properties:
        error:
          type: string
          description: |
            Human-readable message naming the window that refused the call.
        retryAfterSeconds:
          type: integer
          minimum: 1
          description: |
            Whole seconds to wait before retrying — the same value as the
            `Retry-After` header, repeated here for clients that cannot read
            response headers.

    Workspace:
      type: object
      required: [id, name, defaultCurrency, template, timezone]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        picture:
          type:
            - string
            - "null"
          description: URL of the workspace avatar, if set.
        defaultCurrency:
          type: string
          description: Three-letter ISO 4217 currency code used by default for budgets.
          example: USD
        template:
          type: string
          description: |
            The workspace's vertical / team template. One of `agency`,
            `agencyEnd` (agency with end-client tier), `inHouse`,
            `creator`, etc.
        timezone:
          type:
            - string
            - "null"
          description: |
            The workspace's IANA timezone (e.g. `America/New_York`), used for
            calendar / scheduling display. Every `scheduledAt` / `publishedAt`
            in `Post` responses is a UTC instant — interpret it in this zone.
            `null` means the workspace uses browser-detected time (no fixed zone).
          example: America/New_York

    AiCreditsBucket:
      type: object
      additionalProperties: false
      required: [granted, used, remaining]
      properties:
        granted:
          type: integer
          description: Credits this bucket holds this cycle.
        used:
          type: integer
        remaining:
          type: integer

    AiCredits:
      type: object
      additionalProperties: false
      description: The workspace's credits balance (`GET /api/v1/workspace/ai-credits`, 1.141.0; the base in credits and the price sheet, 1.145.0; on timeliner.io, 1.179.0).
      required:
        [cycleStart, resetsAt, available, availableWithoutOverage, held, included, base, committed, lots, overage, usage, rateCard]
      properties:
        cycleStart:
          type: string
          format: date-time
          description: >-
            Start of the current cycle: the workspace's latest billing date, or a UTC month
            start for a workspace with no billing date (1.228.2; until then always a UTC
            month start).
        resetsAt:
          type: string
          format: date-time
          description: >-
            When the cycle ends and the included credits reset: the workspace's next billing
            date, or the next UTC month start for a workspace with no billing date (1.228.2).
        available:
          type: integer
          description: Spendable now — every bucket plus the extra usage (`overage`) headroom, minus `held`. Negative when holds exceed it.
        availableWithoutOverage:
          type: integer
          description: "`available` without the extra usage (`overage`) headroom."
        held:
          type: integer
          description: Credits reserved by AI work still running.
        included:
          type: object
          additionalProperties: false
          description: >-
            What the plan includes each cycle (1.145.0 — the base in credits).
          required: [credits, committedBlocks]
          properties:
            credits:
              type: integer
              description: >-
                The plan's monthly base in credits, its extra seats included. A month the
                plan started or changed in is granted pro rata (`base.granted`).
            committedBlocks:
              type: integer
              description: >-
                Reads 0.
        base:
          allOf:
            - $ref: "#/components/schemas/AiCreditsBucket"
          description: The plan's included credits this cycle.
        committed:
          allOf:
            - $ref: "#/components/schemas/AiCreditsBucket"
          description: >-
            Reads 0.
        lots:
          type: object
          additionalProperties: false
          description: Extra credits granted by Timeliner, spent after base and committed and kept past the reset.
          required: [remaining, count, nextExpiresAt]
          properties:
            remaining:
              type: integer
            count:
              type: integer
              description: Grants with credits left.
            nextExpiresAt:
              type:
                - string
                - "null"
              format: date-time
              description: The soonest expiry among them; `null` when none expires.
        overage:
          type: object
          additionalProperties: false
          description: >-
            Extra usage — usage past every bucket, billed per credit, only while switched on, up to
            `cap` per cycle (1.173.0: the app names it "extra usage"; the field keeps its name).
          required: [enabled, cap, used, headroom, amountUsd]
          properties:
            enabled:
              type: boolean
            cap:
              type:
                - integer
                - "null"
              description: >-
                Most extra usage credits per cycle; `null` when no cap was ever set. The
                last cap set is kept when extra usage is switched off (`enabled: false`),
                and limits nothing then.
            used:
              type: integer
            headroom:
              type: integer
              description: Extra usage credits still allowed this cycle (0 while off).
            amountUsd:
              type: number
              description: This cycle's extra usage bill so far, in US dollars.
        usage:
          type: object
          additionalProperties: false
          description: This cycle's INCLUDED credits (base + committed) used.
          required: [usedCredits, includedCredits, percentUsed, alertThreshold]
          properties:
            usedCredits:
              type: integer
            includedCredits:
              type: integer
            percentUsed:
              type:
                - integer
                - "null"
              description: Whole percent used (0–100); `null` with no included credits.
            alertThreshold:
              enum: [75, 90, 100, null]
              description: The highest usage alert level crossed (once blocking is switched on, the admins are emailed at each); `null` below 75 %.
        rateCard:
          type: object
          additionalProperties: false
          description: >-
            This cycle's prices. A price for something this deployment does not offer is left out,
            never 0 (1.179.0).
          required:
            - creditUsd
            - transcriptionCreditsPerMinute
            - creditsPerEdit
            - creditsPerCheck
            - overageUsdPerCredit
            - prices
          properties:
            creditUsd:
              type: number
              description: The price of one credit, in US dollars.
            transcriptionCreditsPerMinute:
              type: integer
              description: Credits per started minute of transcribed media.
            creditsPerEdit:
              type: integer
              description: An AI edit of a 60-second video (no extra raw footage), in credits — read off `prices`.
            creditsPerCheck:
              type: integer
              description: An AI check of a 1-minute video, in credits — read off `prices`.
            overageUsdPerCredit:
              type: number
            prices:
              $ref: "#/components/schemas/AiCreditsPriceSheet"

    AiCreditsPriceSheet:
      type: object
      additionalProperties: false
      description: >-
        The price sheet of this cycle's rate card, in credits (1.145.0).
        An AI edit is priced per FINISHED second of the video; versions of an approved
        edit reuse its cut and cost a fraction of it. A job is never charged more than the
        estimate shown before it starts.
        A price for something this deployment does not offer is left out, never 0 (1.179.0).
      required:
        - editJobCredits
        - editFirstMinutePerSecond
        - editToThreeMinutesPerSecond
        - editBeyondPerSecond
        - editIncludedRevisionRounds
        - editRawMinutesPerFinishedMinute
        - editMinIncludedRawMinutes
        - editExtraRawMinute
        - versionAspectRatioPerSecond
        - versionHookOrCta
        - versionCutdownPerSecond
        - versionCutdownMin
        - versionMusicSwap
        - versionCaptionLanguagePerSecond
        - versionExtraRevisionPerSecond
        - aiShot
        - aiShotPremium
        - aiStill
        - checkRunCredits
        - checkPerMinute
        - checkRecheckShare
        - thumbnail
        - thumbnailSet
        - driveProxyPerHour
        - whatsAppMessage
        - xPost
        - xPostWithLink
      properties:
        editJobCredits: { type: integer, description: "Per AI edit job, on top of its seconds." }
        editFirstMinutePerSecond: { type: integer, description: "Per finished second, seconds 1–60." }
        editToThreeMinutesPerSecond: { type: integer, description: "Per finished second, seconds 61–180." }
        editBeyondPerSecond: { type: integer, description: "Per finished second beyond 3 minutes." }
        editIncludedRevisionRounds: { type: integer, description: "Revision rounds an edit's price includes (a round = every comment on one version)." }
        editRawMinutesPerFinishedMinute: { type: integer, description: "Raw-footage minutes included per finished minute." }
        editMinIncludedRawMinutes: { type: integer, description: "Raw-footage minutes every edit includes, however short." }
        editExtraRawMinute: { type: integer, description: "Per started raw-footage minute beyond what the edit includes." }
        versionAspectRatioPerSecond: { type: integer, description: "A new aspect ratio of an approved edit, re-laid out, per second." }
        versionHookOrCta: { type: integer, description: "A new hook or call-to-action variant (the body reused)." }
        versionCutdownPerSecond: { type: integer, description: "A shorter cut of an approved edit, per second of the cutdown." }
        versionCutdownMin: { type: integer, description: "The least a cutdown costs." }
        versionMusicSwap: { type: integer, description: "A music or voice-over swap only." }
        versionCaptionLanguagePerSecond: { type: integer, description: "A caption language version, per second." }
        versionExtraRevisionPerSecond: { type: integer, description: "A revision round beyond the included ones, per second of the video." }
        aiShot: { type: integer, description: "An AI-generated shot (up to 5 seconds, 1080p)." }
        aiShotPremium: { type: integer, description: "A premium AI-generated shot (lifelike people, complex motion)." }
        aiStill: { type: integer, description: "An AI-generated still or animated image." }
        checkRunCredits: { type: integer, description: "Per AI check, on top of its minutes." }
        checkPerMinute: { type: integer, description: "Per started minute of the checked video." }
        checkRecheckShare: { type: number, description: "A re-check after a revision costs this share of a full check (0–1)." }
        thumbnail: { type: integer, description: "An AI thumbnail." }
        thumbnailSet: { type: integer, description: "A set of three AI thumbnails." }
        driveProxyPerHour: { type: integer, description: "Drive editing proxies, per footage hour." }
        whatsAppMessage: { type: integer, description: "One WhatsApp notification message, charged when WhatsApp accepts it (a workspace invitation is free). Since 1.175.0." }
        xPost: { type: integer, description: "One post to X whose text carries no link, charged when X accepts it. Since 1.226.0." }
        xPostWithLink: { type: integer, description: "One post to X whose text carries a link (X's own link rule, a bare domain included), charged when X accepts it. Since 1.226.0." }

    AiCreditsResponse:
      type: object
      additionalProperties: false
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/AiCredits"

    Member:
      type: object
      required: [id, email, role, deactivated, pending, joinedAt]
      properties:
        id:
          type: string
          format: uuid
          description: The member's profile id — match this against task assignees.
        email:
          type: string
          format: email
        firstName:
          type:
            - string
            - "null"
        lastName:
          type:
            - string
            - "null"
        picture:
          type:
            - string
            - "null"
          description: URL of the member's avatar, if set.
        role:
          type: string
          description: |
            The member's team role. `admin` and `supervisor` manage work;
            `editor` does the editing. External reviewers surface as `guest`
            (only when `includeGuests=true`); their effective approver /
            commenter / viewer tier is resolved per-project, not here.
          enum: [admin, supervisor, editor, guest]
        subRole:
          type:
            - string
            - "null"
          description: Free-form editor specialty label set by a supervisor, e.g. "Rough Cut Editor".
        canSeeAllTasks:
          type:
            - boolean
            - "null"
          description: Per-member override for seeing all tasks. `null` = follow the workspace default.
        weeklyCapacityMinutes:
          type:
            - integer
            - "null"
          description: |
            Weekly workload capacity in minutes (`2400` = 40h). `null` =
            follow the workspace default (`defaultWeeklyCapacityMinutes`).
            Set via `PATCH /api/v1/members/{id}`.
        payModel:
          type: string
          enum: [perTask, perProject, monthly, pod]
          description: |
            How the member is paid: `perTask` (per-deliverable pay rows, the
            default), `perProject` (a fixed fee per project — set per project
            via `PUT /api/v1/projects/{id}/billing` `team.feeUpdates`),
            `monthly` (salary), or `pod` (1.91.0 — paid through a pod: one
            monthly figure for a group of members, paid to its lead; see
            `podId`). Set via `PATCH /api/v1/members/{id}` (`pod` is managed
            in the app only). Omitted (together with `monthlySalary` and
            `podId`) when the request used a read-scope API key —
            compensation is full-scope only.
        monthlySalary:
          type:
            - number
            - "null"
          description: Current monthly salary amount (`payModel` = `monthly` only; otherwise null).
        podId:
          type:
            - string
            - "null"
          format: uuid
          description: >-
            The pod the member is paid through (`payModel` = `pod` only;
            otherwise null). The pod's monthly figure is reported once, on its
            lead, under `GET /api/v1/pricing/payables` `salaries.byMember`.
        canCreateTasks:
          type:
            - boolean
            - "null"
          description: Per-member override for creating tasks. `null` = follow the workspace default.
        deactivated:
          type: boolean
          description: True if the member has been deactivated / removed (still listed for historical attribution).
        pending:
          type: boolean
          description: True if the member was invited but has not yet accepted.
        joinedAt:
          type: string
          format: date-time

    MemberPage:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Member"

    AddBrandMemberInput:
      type: object
      required: [memberId]
      properties:
        memberId:
          type: string
          format: uuid
          description: The workspace member's id (from `GET /api/v1/members`) to grant brand access.
        role:
          type: string
          description: Brand-level team role to grant. Defaults to `editor`.
          enum: [admin, supervisor, editor]

    BrandMembership:
      type: object
      required: [brandId, role, member]
      properties:
        brandId:
          type: string
          format: uuid
        role:
          type: string
          description: The member's brand-level team role.
          enum: [admin, supervisor, editor]
        automatic:
          type: boolean
          description: |
            `true` when this access was granted automatically rather than
            assigned. Every workspace **admin** receives access to every brand
            the moment the brand is created, so an admin appears here without
            ever having been added — and cannot be removed from a single brand.
            `false` for an ordinary supervisor/editor assignment.
        member:
          description: |
            The member that was granted access (same shape as `GET
            /api/v1/members`). `member.role` is the member's workspace role;
            the top-level `role` is the brand-level grant. `null` only in the
            rare case the member echo could not be re-read after a successful
            grant.
          anyOf:
            - $ref: "#/components/schemas/Member"
            - type: "null"

    BrandMembershipResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/BrandMembership"

    BrandMembershipListResponse:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/BrandMembership"

    DocLink:
      type: object
      description: |
        One hyperlink found in a task's document body / brief (`GET
        /api/v1/tasks/{id}/doc` → `links`).
      required: [text, url]
      properties:
        text:
          type: string
          description: |
            The link's visible text (formatting stripped). The url itself when
            the link has no text.
        url:
          type: string
          description: |
            The link target, decoded and ready to fetch — an `http(s)` or
            `mailto` address. A target saved without a scheme
            (`www.dropbox.com/s/abc123/lauren-vo.wav?dl=1`, `we.tl/t-Stems123`)
            is returned with `https://` added (since 1.153.1; before it such a
            link was not listed).
    DocAttachment:
      type: object
      description: |
        A file uploaded INTO a document's text — an attachment chip (a .docx
        or .pdf dropped into a brief), an inline image or video (since
        1.194.0). Its own address in the document
        (`/api/brief-attachment/…`) needs a signed-in Timeliner session, so an
        API caller downloads it from `downloadUrl` instead.
      required: [id, name, mimeType, size, downloadUrl]
      properties:
        id:
          type: string
          format: uuid
          description: |
            The upload's id. It is not a file id: `GET /api/v1/files/{id}/download`
            does not take it — read the document again for a fresh link.
        name:
          type: string
          description: The file name the document shows.
          example: Spring launch script.docx
        mimeType:
          type: string
          example: application/vnd.openxmlformats-officedocument.wordprocessingml.document
        size:
          type: integer
          description: Size in bytes.
        downloadUrl:
          type:
            - string
            - "null"
          format: uri
          description: |
            Presigned URL of the file, valid for 7 days — open it with no
            sign-in or Authorization header. `null` when the key does not hold
            the `read:files` scope, and `null` when the file's content was
            removed after the workspace's subscription ended.
    HeaderContent:
      type: object
      required: [scope, id, brief, docs, links, attachments, docAttachments, files, sections, cards]
      properties:
        scope:
          type: string
          enum: [project, brand]
        id:
          type: string
          format: uuid
        brief:
          type:
            - string
            - "null"
          description: |
            The scope's own brief, plain text: a project's Brief card, a
            brand's Guidelines card (then a "Brief" page added to the brand).
            `null` when that card is empty — since 1.154.0 never another
            page's text (before it, an empty brief fell back to the first doc
            with text). Since 1.148.0 a hyperlink in it keeps its target as
            `[text](url)` (just the url when the text is the url), e.g.
            `[Brand guidelines PDF](https://drive.google.com/file/d/1AbC/view)`;
            since 1.153.1 a target saved without a scheme
            (`drive.google.com/…`) is written with `https://` added rather
            than dropped.
        docs:
          type: array
          description: |
            Every doc card (brief / guidelines / moodboard / …) as plain text,
            hyperlinks kept as `[text](url)` like `brief`.
          items:
            type: object
            required: [title, text]
            properties:
              title:
                type: string
              text:
                type: string
        links:
          type: array
          items:
            type: object
            required: [title, url]
            properties:
              title:
                type: string
              url:
                type: string
        attachments:
          type: array
          description: |
            Files attached to "Documents & attachments" (fileAttach) cards
            (contracts, briefs, captions, …). Since 1.194.0 each carries its
            `id` and a `downloadUrl`.
          items:
            type: object
            required: [id, name, size, mime, downloadUrl]
            properties:
              id:
                type:
                  - string
                  - "null"
                description: |
                  The file's id — pass it to `GET /api/v1/files/{id}/download`
                  for a fresh link or another rendition. `null` only for an
                  entry stored without one.
              name:
                type: string
              size:
                type: integer
              mime:
                type: string
              downloadUrl:
                type:
                  - string
                  - "null"
                format: uri
                description: |
                  Presigned URL of the file, valid for 7 days. `null` when the
                  key does not hold the `read:files` scope, when the file's
                  content was removed after the workspace's subscription
                  ended, or when `id` is not a file of this workspace.
        docAttachments:
          type: array
          description: |
            Files uploaded INTO a doc card's text — e.g. a .docx dropped into
            the project Brief shows in `brief` only by its name; this lists it
            with a `downloadUrl` (since 1.194.0). At most 50.
          items:
            $ref: "#/components/schemas/DocAttachment"
        files:
          type: array
          description: Raw project/brand files (the Assets row), bounded.
          items:
            type: object
            required: [id, name, size, mimeType, downloadUrl]
            properties:
              id:
                type: string
                format: uuid
                description: |
                  The file's id — pass it to `GET /api/v1/files/{id}/download`
                  for a fresh link or another rendition.
              name:
                type: string
              size:
                type: integer
              mimeType:
                type: string
              downloadUrl:
                type:
                  - string
                  - "null"
                format: uri
                description: |
                  Presigned URL of the original file, valid for 7 days — the
                  same link `GET /api/v1/files/{id}/download` returns (since
                  1.134.0). `null` on every file when the key does not hold
                  the `read:files` scope (the header itself needs only
                  `read:projects`), and `null` when the file's content was
                  removed after the workspace's subscription ended.
        sections:
          type: array
          description: |
            The header's section names, in display order — a section with no
            card in it included (since 1.154.0). Pass one as `section` to
            `POST /api/v1/header-cards`.
          items:
            type: string
          example: [Production, Management]
        cards:
          type: array
          description: |
            The header canvas — every card, section by section, in display
            order (since 1.154.0; before it the sections were interleaved).
          items:
            type: object
            required: [id, type, title, section, visibility, hidden, isDefault]
            properties:
              id:
                type: string
                format: uuid
                description: |
                  The card's id — pass it to `PATCH /api/v1/header-cards/{cardId}`
                  to write a `doc` card's text or a `links` card's list, set
                  its `visibility` or hide a default card, or to
                  `DELETE /api/v1/header-cards/{cardId}` to remove a card that
                  is not a default one.
              type:
                type: string
                enum: [doc, links, assets, fileAttach, timeline, intake]
              title:
                type: string
              section:
                type:
                  - string
                  - "null"
                description: |
                  The name of the section the card sits in — the name
                  `POST /api/v1/header-cards` takes as `section` (since
                  1.154.0).
                example: Production
              visibility:
                $ref: "#/components/schemas/HeaderCardVisibilityRead"
              hidden:
                type: boolean
                description: |
                  `true` when the card is hidden from everyone (a default
                  card's Hide). Since 1.219.0.
              isDefault:
                type: boolean
                description: |
                  A default card (Brief, Guidelines, Brand Links, Raw files &
                  Assets): it can be hidden but never deleted. Any other card
                  can be deleted. Since 1.219.0.

    UpdateHeaderCardInput:
      type: object
      description: |
        A patch for one header card — at least one field. Content: `html` for
        a `doc` card or `links` for a `links` card (never both). Settings:
        `visibility` (any card but an intake form) and `hidden` (default cards
        only).
      additionalProperties: false
      minProperties: 1
      properties:
        visibility:
          $ref: "#/components/schemas/HeaderCardVisibility"
        hidden:
          type: boolean
          description: |
            Default cards only (`isDefault: true`) — `true` hides the card from
            everyone, `false` restores it. Any other card is deleted with
            `DELETE /api/v1/header-cards/{cardId}` instead (`400` here).
            Since 1.219.0.
        html:
          type: string
          maxLength: 200000
          description: |
            `doc` cards only — the FULL new HTML body (full replace; `""`
            clears it). Simple tags (`<h2>`, `<p>`, `<ul>`/`<li>`, `<strong>`)
            render as they do in the in-app editor.
        links:
          type: array
          maxItems: 50
          description: |
            `links` cards only — the FULL new link list (full replace, so
            include the entries that should stay; `[]` clears it).
          items:
            type: object
            required: [url]
            additionalProperties: false
            properties:
              title:
                type: string
                maxLength: 200
                description: Display label; defaults to the url when omitted.
              url:
                type: string
                maxLength: 2000

    CreateHeaderCardInput:
      type: object
      description: |
        A new header card. Exactly one of `projectId` / `brandId` names the
        header. `html` only with `type: doc`; `links` only with `type: links`.
      additionalProperties: false
      required: [type, title]
      properties:
        projectId:
          type: string
          format: uuid
          description: Add the card to this project's header. Never together with `brandId`.
        brandId:
          type: string
          format: uuid
          description: Add the card to this brand's (or client's) header. Never together with `projectId`.
        type:
          type: string
          enum: [doc, links]
        title:
          type: string
          minLength: 1
          maxLength: 120
          description: The card's name on the header (trimmed).
        html:
          type: string
          maxLength: 200000
          description: |
            `doc` cards only — the starting HTML body. Simple tags (`<h2>`,
            `<p>`, `<ul>`/`<li>`, `<strong>`) render as they do in the in-app
            editor. Omitted = an empty page.
        links:
          type: array
          maxItems: 50
          description: "`links` cards only — the starting link list. Omitted = an empty list."
          items:
            type: object
            required: [url]
            additionalProperties: false
            properties:
              title:
                type: string
                maxLength: 200
                description: Display label; defaults to the url when omitted.
              url:
                type: string
                maxLength: 2000
        section:
          type: string
          minLength: 1
          maxLength: 200
          description: |
            The name of the header section to add the card to (case-insensitive).
            Omitted = the header's first section.
        visibility:
          $ref: "#/components/schemas/HeaderCardVisibility"

    HeaderCard:
      type: object
      description: One header-canvas card after a write or a create.
      required: [id, type, title, content, updatedAt, visibility, hidden, isDefault]
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum: [doc, links, assets, fileAttach, timeline, intake]
        title:
          type: string
        content:
          type: object
          description: |
            The card's stored content payload, per type — a `doc` card carries
            `{ html, templateKey }`; a `links` card carries `{ items[] }`.
          additionalProperties: true
        updatedAt:
          type: string
          format: date-time
        section:
          type: [string, "null"]
          description: |
            Set on `POST /api/v1/header-cards` only — the name of the header
            section the new card was added to.
        visibility:
          $ref: "#/components/schemas/HeaderCardVisibilityRead"
        hidden:
          type: boolean
          description: "`true` when the card is hidden from everyone. Since 1.219.0."
        isDefault:
          type: boolean
          description: "A default card — hidden, never deleted. Since 1.219.0."

    HeaderCardVisibility:
      type: string
      enum: [everyone, team, approvers, adminsOnly]
      description: |
        Who sees a header card — the app's **Card permissions** presets
        (since 1.219.0): `everyone` (every role, guests included, sees and
        edits it), `team` (the internal team only — guests don't see it),
        `approvers` (the team edits, guests view — the default matrix) or
        `adminsOnly` (workspace admins only). On a create, omitted = the
        workspace's saved default for the card type.
      example: team

    HeaderCardVisibilityRead:
      type: string
      enum: [everyone, team, approvers, adminsOnly, custom]
      description: |
        Who sees the card — the **Card permissions** preset its settings match,
        or `custom` when someone set a combination in the app that matches no
        preset. A brand's Guidelines card that nobody has set lets approvers
        edit it, so it reads `custom` until a preset is chosen. Since 1.219.0.
      example: approvers

    HeaderCardResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/HeaderCard"

    HeaderContentResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/HeaderContent"

    BrandPackageFile:
      type: object
      description: A brand file (from the brand header's raw files) the package uses.
      required: [id, name, mimeType, size, downloadUrl]
      properties:
        id:
          type: string
          format: uuid
          description: The brand file's id — also accepted by `GET /api/v1/files/{id}/download`.
        name:
          type: string
        mimeType:
          type: string
        size:
          type: integer
          description: Bytes.
        downloadUrl:
          type:
            - string
            - "null"
          format: uri
          description: The original file, valid for 7 days; `null` when the key lacks `read:files`.

    BrandPackage:
      type: object
      required:
        [brandId, editDirection, ctaText, ctaUrl, endCardNotes, musicNotes, sfxNotes, colors, assets, fonts, updatedAt]
      properties:
        brandId:
          type: string
          format: uuid
        editDirection:
          type:
            - string
            - "null"
          enum: [replicate, improve, null]
          description: "`replicate` = match the brand's approved videos; `improve` = keep the look, raise the bar; `null` = not chosen yet."
        ctaText:
          type:
            - string
            - "null"
          maxLength: 200
        ctaUrl:
          type:
            - string
            - "null"
          format: uri
          maxLength: 500
        endCardNotes:
          type:
            - string
            - "null"
          maxLength: 2000
        musicNotes:
          type:
            - string
            - "null"
          maxLength: 2000
          description: Background-music notes for the editor (mood, tempo, what to avoid).
        sfxNotes:
          type:
            - string
            - "null"
          maxLength: 2000
          description: "**New in 1.222.0.** Sound-effects notes for the editor (which effects to use or avoid)."
        colors:
          type: array
          maxItems: 24
          description: Most important first.
          items:
            type: object
            required: [hex, name, role]
            properties:
              hex:
                type: string
                pattern: "^#[0-9A-F]{6}$"
              name:
                type:
                  - string
                  - "null"
              role:
                type:
                  - string
                  - "null"
                enum: [primary, secondary, accent, background, text, null]
        assets:
          type: array
          maxItems: 100
          description: Usable brand files only (completed, active, not purged, of this brand) — never a font file, never a file named after the Birzia font.
          items:
            type: object
            required: [category, variant, source, file]
            properties:
              category:
                type: string
                enum: [logo, productImage, broll, music, sfx, endCard, overlay, look, reference, doc, other, productRecording, screenshot, photo]
                description: "`productRecording` (a screen recording of the brand's product), `screenshot` and `photo` since 1.163.5."
              variant:
                type:
                  - string
                  - "null"
                description: A free label, e.g. "white" or "horizontal".
              source:
                type: string
                enum: [manual, brandHeader, assetRequest]
                description: Picked by hand, imported from the brand header, or supplied in answer to a request.
              file:
                $ref: "#/components/schemas/BrandPackageFile"
        fonts:
          type: array
          maxItems: 12
          items:
            type: object
            required: [family, usage, licenseStatus, usable, licenseNote, fallbackFamily, attestedAt, file]
            properties:
              family:
                type: string
              usage:
                type:
                  - string
                  - "null"
                enum: [heading, body, caption, null]
              licenseStatus:
                type: string
                enum: [ofl, commercialOk, userAttested, unknown, restricted]
              usable:
                type: boolean
                description: "`true` only for ofl, commercialOk and userAttested. Never use a font whose usable is false."
              licenseNote:
                type:
                  - string
                  - "null"
              fallbackFamily:
                type:
                  - string
                  - "null"
                description: The open-license font to use instead when this one cannot be used.
              attestedAt:
                type:
                  - string
                  - "null"
                format: date-time
                description: When a team member confirmed the brand holds a license (`userAttested` only).
              file:
                oneOf:
                  - $ref: "#/components/schemas/BrandPackageFile"
                  - type: "null"
                description: The font file among the brand's files — only when one was uploaded, the file is still usable, and the font itself is `usable` (never for an unknown or restricted font).
        updatedAt:
          type:
            - string
            - "null"
          format: date-time
          description: "`null` = nothing saved yet (every field is its default)."

    BrandPackageResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/BrandPackage"

    OutOfCreditsFailure:
      type: object
      description: |
        The body of a `402` (since 1.143.0): the workspace is out of credits
        for the work the call needed. `message` is Timeliner's own sentence for
        the API key's creator.
      required: [status, reason, message]
      properties:
        status:
          type: string
          enum: [failed]
        reason:
          type: string
          enum: [out_of_credits]
        message:
          type: string
    WorkspaceSettings:
      type: object
      description: |
        The curated workspace settings — effective values (view defaults applied).
        `downloadPolicy`, `defaultTaskDownloadable`, `archiveEnabled`,
        `adminApprovalScope`, `deliverableRequestsEnabled` and `billableFromStatus`
        are read-only here (change them in-app).
      required:
        - editorCanCreateTasks
        - editorCanCreateProjects
        - editorSeeAllProjectTasks
        - editorCanReachClientApproval
        - supervisorCanApprove
        - supervisorChartAccess
        - autoAddSupervisorsToNodes
        - supervisorCanArchiveBrands
        - dualDeadlineMode
        - automationsCenterEnabled
        - defaultRevisionLimit
        - defaultWeeklyCapacityMinutes
        - showFrameNumber
        - startMuted
        - autoplayOnOpen
        - enableTranscripts
        - transcriptSidePanel
        - autoTranscribeUploads
        - footageEnrichMode
        - footageEnrichTier
        - footageEnrichDailyCreditCap
        - footageEnrichWriteTaskTags
        - rawFilesCommentsEnabled
        - openTaskOnTitleClick
        - billableFromStatus
        - guestCanViewBrief
        - guestCanSchedulePosts
        - guestCanCreateEndClients
        - guestPortalLanding
        - guestCanMarkPosted
        - downloadPolicy
        - defaultTaskDownloadable
        - archiveEnabled
        - adminApprovalScope
        - deliverableRequestsEnabled
      properties:
        editorCanCreateTasks: { type: boolean }
        editorCanCreateProjects:
          type: boolean
          description: >-
            Whether editors may create projects inside brands they already have
            access to, and delete only the projects they created themselves.
            Creating or deleting brands and folders stays supervisor+ either way.
        editorSeeAllProjectTasks: { type: boolean }
        editorCanReachClientApproval: { type: boolean }
        supervisorCanApprove: { type: boolean }
        supervisorChartAccess: { type: boolean }
        autoAddSupervisorsToNodes: { type: boolean }
        supervisorCanArchiveBrands:
          type: boolean
          description: >-
            Whether supervisors may archive and unarchive the brands they have
            supervisor access to (default false — admins only). Archiving
            projects stays admin-only either way.
        dualDeadlineMode: { type: boolean, description: "Plan-gated to enable." }
        automationsCenterEnabled:
          type: boolean
          description: >-
            The Automations Center master toggle — rules only run while it is
            on. Plan-gated to enable.
        defaultRevisionLimit:
          type:
            - integer
            - "null"
          description: Plan-gated to set. null = unlimited.
        defaultWeeklyCapacityMinutes:
          type:
            - integer
            - "null"
          description: |
            Plan-gated to set. Workspace default weekly workload capacity in minutes
            (2400 = 40h); write null to reset to the default. Per-member
            overrides via PATCH /api/v1/members/{id}.
        showFrameNumber: { type: boolean }
        startMuted: { type: boolean }
        autoplayOnOpen: { type: boolean }
        enableTranscripts: { type: boolean, description: "Plan-gated to enable." }
        transcriptSidePanel:
          type: boolean
          description: >-
            Video review layout default. When true, team members on desktop
            see the transcript docked in its own panel to the left of the
            player, side by side with the comments, instead of as a tab of
            the right panel. Guests, share links and the mobile layout always
            keep the tab. Available on all plans; defaults to false.
        autoTranscribeUploads:
          type: boolean
          description: >-
            Whether every NEW video starts its transcript automatically when it
            finishes uploading — task versions and raw files in Raw Files &
            Assets (1.104.0). Plan-gated like `enableTranscripts` — every plan
            with transcripts may enable it (since 1.143.0; from 1.106.0 it was
            Scale plan and Enterprise only). Takes effect only while
            `enableTranscripts` is on. Files uploaded before it was turned on
            are never transcribed by it. A task version's transcript is free
            (since 1.228.4); each raw file's transcript uses the workspace's
            credits, and when they run out, new raw uploads are not transcribed.
            Defaults to false; the key is present for every workspace.
        footageEnrichMode:
          type: string
          enum: [off, manual, auto]
          description: >-
            AI footage tagging (1.160.0) — the Library's tags, timecoded
            moments and summaries written by the model from a clip's frames.
            `off` (default): nothing runs and nothing is charged. `manual`:
            team members tag footage on request (a file, a selection in the
            Library, or a whole brand), seeing the credit estimate first.
            `auto`: also every NEW video upload (task versions and raw project
            files), within `footageEnrichDailyCreditCap` per UTC day; nothing
            uploaded before it was turned on. Each run uses the workspace's
            credits (about 7 credits per minute of footage on the standard
            tier). A brand's own override (Edit Brand -> Footage tagging)
            beats this default. Plan-gated to enable like `enableTranscripts`;
            `off` is always accepted.
        footageEnrichTier:
          type: string
          enum: [standard, light]
          description: >-
            The model tier footage tagging runs on (1.160.0): `standard`
            (default, the most detail) or `light` (several times cheaper per
            minute, less detail). Applies to runs queued after the change.
        footageEnrichDailyCreditCap:
          type: integer
          minimum: 0
          maximum: 100000
          description: >-
            The most credits AUTOMATIC footage tagging may reserve per UTC
            day (1.160.0; default 2000). Uploads past it are not tagged that
            day and can still be tagged on request; manual requests are never
            capped here. 0 means automatic runs spend nothing.
        footageEnrichWriteTaskTags:
          type: boolean
          description: >-
            When the AI tags a task deliverable, also add those tags to the
            task's Tags column so the List and Board views show them
            (1.160.0; default true). Raw footage is unaffected.
        rawFilesCommentsEnabled:
          type: boolean
          description: >-
            Whether raw files in Raw Files & Assets carry a task-review-style
            comment mode — timecoded comments, ranges and drawings on raw
            footage, with unread badges per file. Available on all plans.
            Defaults to false so the raw-files area never reads as the
            deliverables surface.
        openTaskOnTitleClick:
          type: boolean
          description: >-
            What a click on a task's name does for team members. false (the
            default) keeps click-to-rename in the List view and on Board
            cards; true makes a single click open the task, with rename on
            double-click. Guests are unaffected. Available on all plans.
        billableFromStatus:
          type: string
          description: >-
            The status from which a task's client price and team pay count as
            owed ("approved") in /pricing/receivables, /pricing/payables,
            /analytics and project P&L. "approved" (the default) = approved,
            posted and archive. Otherwise a review gate onward
            (supervisorApproval, adminApproval, clientApproval,
            endClientApproval, posted) or "cs:<customStatusId>" for a custom
            status on Approved or Posted — that status and every later one
            count, earlier ones stay pending, revisions never count. Read-only
            here; set it in the app (Settings -> Workflow -> Pricing). (1.198.0)
        guestCanViewBrief:
          type: boolean
          description: >-
            Whether guests and share-link visitors may read task/project briefs.
            Plan-gated to enable. Defaults to false — the brief is written
            for the editing team. A per-brand override (set in-app) can force it
            visible or hidden for a single client and wins over this value.
        guestAllStagesVisible:
          type: boolean
          description: >-
            "Show clients every workflow stage" — the workspace default
            (false). When true, client-tier guests (signed in and on share
            links) see tasks in EVERY non-archive workflow stage — to-do, in
            progress, internal approvals and internal revision rounds. An
            early-stage media task (and every other non-document type) is a
            view-only placeholder card: title, stage name, deadlines, planned
            posting time and a thumbnail if one exists — no playable preview,
            versions, download, transcript, post caption, comments, approval or
            other client action until it reaches client review (a cut already
            presented to the client stays watchable). A signed-in guest the
            task already reaches through an assignment — listed in its editors,
            in the parent's editors for a variant, or in a child variant's
            editors for a parent — is not narrowed by this setting: it keeps
            the rights it had before it (playback, download, transcript and
            post caption on early-stage media; comments, suggestions and, with
            guest document editing on, edits on an internal revision round).
            Early-stage documents
            follow `guestEarlyStageDocAccess`; at its default `placeholder` a
            signed-in client gets no document card at all (only its name, in
            the progress tracker). End-client-tier guests are never widened.
            Plan-gated (Studio and up) to enable; setting it false is always
            accepted. A brand's own `guestAllStagesVisible`
            (`PATCH /brands/{id}`) overrides it per brand, and the brand's share
            links inherit the brand.
        guestEarlyStageDocAccess:
          type: string
          enum: [placeholder, view, comment, edit]
          description: >-
            How far a client may go with a DOCUMENT task in a stage before
            client review while `guestAllStagesVisible` is on. `placeholder`
            (default) — no content: a signed-in client does not get the
            document on Grid, List or Board (only its name, not clickable, in
            the progress tracker), and a share-link visitor sees a placeholder
            card (title, stage, deadlines) with no body. `view` — the body can
            be read; no comments, no editing. `comment` — read + comment, for
            clients who can comment (commenter / approver roles and share
            links; a viewer reads only). `edit` — read + comment + edit,
            including live co-editing, for commenter / approver clients and
            commenter / approver / editor share links while the document is in
            To Do, In Progress, Supervisor Approval, Admin Approval or an
            internal revision round; in any other pre-review stage it is read +
            comment only. Suggestion mode is not offered on an early-stage
            document. Media and every other task type are a placeholder in
            those stages. These limits bind a client the setting alone lets see
            the task: a signed-in guest the task already reaches through an
            assignment (see `guestAllStagesVisible`) keeps the rights it had
            before the setting — on an internal revision round that includes
            comments, suggestions and, with guest document editing on, edits.
            Plan-gated (Studio and up) past `placeholder`.
            Per-brand override on `PATCH /brands/{id}`.
        guestCanCreateEndClients:
          type: boolean
          description: >-
            Whether a client's approvers may add their own end clients (sub-brands)
            under their brand from the client portal — agency-of-agencies
            workspaces only. Defaults to true. Workspace-wide: the Edit Brand →
            Guest Access switch writes this same setting (1.199.0).
        guestPortalLanding:
          type: ["string", "null"]
          enum: [media, firstView, null]
          description: >-
            "Where clients land" — the first screen a client sees each time
            they open the portal, a brand or a brand / project share link (all
            plans). `null` (default) — each client's own last choice. `media` —
            always All media, opened on what needs their review. `firstView` —
            always the first view in Client views. A brand's own
            `portal.landing` (`PATCH /brands/{id}/settings`) overrides it
            (1.227.0).
        guestCanMarkPosted:
          type: boolean
          description: >-
            Whether a client approver may move their own approved work to
            Posted — the status menu, the board drag and the share-link Post
            action (all plans; default true). `false`: only the team, or an
            automation, moves work to Posted (1.227.0).
        guestCanSchedulePosts:
          type: boolean
          description: >-
            Whether a client APPROVER may schedule and publish content they have
            already approved — opening the post composer from their client-portal
            calendar or an approver share link and queuing the post to go live on
            the brand's connected social accounts. Requires a posting plan
            (Studio, Agency, Scale, or Enterprise) to enable — a lower plan's
            403 names Studio. Defaults to false. Strictly
            stronger than letting clients edit an existing post plan: only tasks
            the client already approved qualify, the post must still clear the
            caption/thumbnail/schedule review checks with no open feedback, and
            every client-scheduled post is written to the activity log.
        downloadPolicy:
          type:
            - string
            - "null"
          description: Read-only. How downloads are gated (afterApproval / manualToggle / alwaysAllow).
        defaultTaskDownloadable: { type: boolean, description: "Read-only." }
        archiveEnabled: { type: boolean, description: "Read-only." }
        adminApprovalScope:
          type: string
          enum: [all, internal, client, none]
          description: >-
            Read-only. Which brands get the Admin Approval stage on the
            Agency + 2 approvers workflow — `all` (the default), `internal`
            (internal projects only, i.e. brands of type `brand`), `client`
            (client brands only), or `none` (no brand by default; each one opts
            in with its own `adminApprovalMode: "on"`). A brand's own
            `adminApprovalMode` overrides it in every case. No effect on other
            workflows. Read-only here because narrowing it moves tasks out of
            the Admin Approval stage; change it in-app, where the affected count
            is shown and confirmed first.
        deliverableRequestsEnabled: { type: boolean, description: "Read-only." }

    WorkspaceSettingsResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/WorkspaceSettings"

    IntakeFormSummary:
      type: object
      required: [id, name, language, isWorkspaceDefault, createdAt, updatedAt]
      properties:
        id: { type: string, format: uuid }
        name: { type: string }
        language:
          type: string
          enum: [en, es, pt, de, nl, fr, hi, ru, zh, he, ar]
        isWorkspaceDefault: { type: boolean }
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }

    IntakeFormDetail:
      allOf:
        - $ref: "#/components/schemas/IntakeFormSummary"
        - type: object
          required: [sections, goalOptions, questions, settings, items]
          properties:
            sections:
              type: object
              required: [goal, centralMessage, requiredInclusions, deadline, freeNotes, catalog]
              properties:
                goal: { type: boolean }
                centralMessage: { type: boolean }
                requiredInclusions: { type: boolean }
                deadline: { type: boolean }
                freeNotes: { type: boolean }
                catalog: { type: boolean }
            goalOptions:
              type:
                - array
                - "null"
              items: { type: string }
            questions:
              type: array
              items:
                type: object
                required: [id, type, label, required]
                properties:
                  id: { type: string }
                  type:
                    type: string
                    enum: [shortText, longText, singleSelect, multiSelect, date, files, links, deliverables]
                  label: { type: string }
                  required: { type: boolean }
                  help:
                    type:
                      - string
                      - "null"
                  options:
                    type:
                      - array
                      - "null"
                    items:
                      type: object
                      required: [id, label]
                      properties:
                        id: { type: string }
                        label: { type: string }
            settings:
              type: object
              required: [thankYouMessage, redirectUrl, showProgress, destination]
              properties:
                thankYouMessage:
                  type:
                    - string
                    - "null"
                redirectUrl:
                  type:
                    - string
                    - "null"
                showProgress:
                  type:
                    - boolean
                    - "null"
                destination:
                  type:
                    - string
                    - "null"
            items:
              type: array
              items:
                type: object
                required:
                  [
                    id,
                    title,
                    description,
                    unitPrice,
                    showPrice,
                    badgeName,
                    collectBrief,
                    briefPrompt,
                    briefRequired,
                    collectTaskName,
                    maxQuantity,
                    sortOrder,
                  ]
                properties:
                  id: { type: string, format: uuid }
                  title: { type: string }
                  description:
                    type:
                      - string
                      - "null"
                  unitPrice:
                    type:
                      - number
                      - "null"
                  showPrice: { type: boolean }
                  badgeName:
                    type:
                      - string
                      - "null"
                  collectBrief:
                    type: boolean
                    description: >
                      When true, the client is asked for a brief for each unit
                      of this deliverable they order, and each brief is written
                      into the corresponding media task's brief on approval.
                      Below a quantity of 10 that is one brief per unit; at 10
                      or above the order becomes one parent task with variants
                      and a single brief covers the group.
                  briefPrompt:
                    type:
                      - string
                      - "null"
                    description: >
                      The question shown above the client's brief box. Null uses
                      the localized default.
                  briefRequired:
                    type: boolean
                    description: >
                      When true the client cannot submit until every brief slot
                      for this deliverable is filled.
                  collectTaskName:
                    type: boolean
                    description: >
                      When true, the client is asked to NAME each unit of this
                      deliverable they order, and that name becomes the created
                      task's title on approval. Independent of collectBrief and
                      always optional — a name the client leaves blank falls
                      back to the deliverable's own title. Slots follow the same
                      layout as the briefs: one name per unit below a quantity
                      of 10, and a single group name at 10 or above (carried by
                      the parent task and prefixed onto every variant).
                  maxQuantity:
                    type: integer
                    minimum: 1
                    maximum: 50
                    description: >
                      The largest quantity of this deliverable a single brief
                      may request, set per catalog item by the agency
                      (1-50, default 20). A submitted request line above the
                      cap is rejected, not truncated - mirror this ceiling in
                      any quantity control you render.
                  sortOrder: { type: integer }

    IntakeFormList:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/IntakeFormSummary"

    IntakeFormResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/IntakeFormSummary"

    IntakeFormDetailResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/IntakeFormDetail"

    CreateIntakeFormInput:
      type: object
      required: [name]
      properties:
        name: { type: string, minLength: 1, maxLength: 120 }
        language:
          type: string
          enum: [en, es, pt, de, nl, fr, hi, ru, zh, he, ar]
          description: >-
            Authoring language — any language Timeliner supports. Drives the
            form's text direction and every built-in string the client sees.
            Defaults to en.
        setAsDefault:
          type: boolean
          description: Make this the workspace default form.

    ReviewWorkflowAutomations:
      type: object
      required:
        - autoAdvanceVariantReview
        - reviewRevertTimeout
        - autoSubmitForReviewTimeout
        - guestRevertWindow
        - guestApprovalRevertWindow
      properties:
        autoAdvanceVariantReview: { type: boolean }
        reviewRevertTimeout: { type: integer, description: "Minutes; 0 = off." }
        autoSubmitForReviewTimeout: { type: integer, description: "Minutes; 0 = off." }
        guestRevertWindow: { type: integer, description: "Minutes; 0 = off, -1 = forever." }
        guestApprovalRevertWindow: { type: integer, description: "Minutes; 0 = off, -1 = forever." }

    NotificationAutomationsRead:
      type: object
      description: Read-only quiet / batch / catch-up notification automations (null = not configured).
      required: [quiet, batch, catchUp]
      properties:
        quiet:
          anyOf:
            - type: object
              required: [enabled, days, from, to, tz]
              properties:
                enabled: { type: boolean }
                days:
                  type: array
                  items: { type: integer }
                from:
                  type:
                    - string
                    - "null"
                to:
                  type:
                    - string
                    - "null"
                tz:
                  type:
                    - string
                    - "null"
            - type: "null"
        batch:
          anyOf:
            - type: object
              required: [enabled, groups, everyMinutes]
              properties:
                enabled: { type: boolean }
                groups:
                  type: array
                  items:
                    type: string
                    enum: [assignments, deadlines, approvals, comments]
                everyMinutes: { type: integer }
            - type: "null"
        catchUp:
          anyOf:
            - type: object
              required: [enabled, day, time]
              properties:
                enabled: { type: boolean }
                day: { type: integer }
                time: { type: string }
            - type: "null"

    Automations:
      type: object
      required: [reviewWorkflow, notifications]
      properties:
        reviewWorkflow:
          $ref: "#/components/schemas/ReviewWorkflowAutomations"
        notifications:
          $ref: "#/components/schemas/NotificationAutomationsRead"

    AutomationsResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/Automations"

    AutomationRulesResponse:
      type: object
      required: [data, automationsCenterEnabled]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/AutomationRule"
        automationsCenterEnabled:
          type: boolean
          description: >-
            The Automations master toggle. While `false`, every rule is stored
            but dormant — surface that to the user before promising a rule
            will run.

    AutomationStageCondition:
      type: object
      description: >-
        One stage condition. Several may be present: conditions on the SAME
        column are alternatives (either matches); conditions on DIFFERENT
        columns must all hold.
      required: [columnId, optionId]
      properties:
        columnId: { type: string, format: uuid }
        optionId: { type: string, format: uuid }

    HqFieldCondition:
      type: object
      description: >-
        One HQ board select-field condition. Several may be present: conditions
        on the SAME field are alternatives (either matches); conditions on
        DIFFERENT fields must all hold. A condition FAILS CLOSED against an
        empty cell — a rule never fires on a blank. (1.76.0)
      required: [fieldId, optionId]
      properties:
        fieldId: { type: string, format: uuid }
        optionId: { type: string, format: uuid }

    HqActionFieldValue:
      description: >-
        What an `hqSetField` action writes, narrowed by the field's real kind.
        `date` is RELATIVE (offset days from the trigger's anchor, or from the
        fire moment) for the same reason every other date action is: an
        absolute date would give every item the rule touches one shared day.
        Time-tracker fields cannot be written by a rule. (1.76.0)
      oneOf:
        - type: object
          title: Select
          required: [kind, optionId]
          properties:
            kind: { type: string, enum: [select] }
            optionId: { type: string, format: uuid }
        - type: object
          title: Date
          required: [kind, offsetDays]
          properties:
            kind: { type: string, enum: [date] }
            offsetDays: { type: integer, minimum: -365, maximum: 365 }
        - type: object
          title: Person
          required: [kind, memberId]
          properties:
            kind: { type: string, enum: [user] }
            memberId: { type: string, format: uuid }
        - type: object
          title: Text
          required: [kind, text]
          properties:
            kind: { type: string, enum: [text] }
            text: { type: string, minLength: 1, maxLength: 500 }
        - type: object
          title: Number
          required: [kind, number]
          properties:
            kind: { type: string, enum: [number] }
            number: { type: number }
        - type: object
          title: Clear
          description: Empty the cell.
          required: [kind]
          properties:
            kind: { type: string, enum: [clear] }

    AutomationRuleInput:
      type: object
      required: [trigger, actions]
      properties:
        trigger:
          $ref: "#/components/schemas/AutomationTrigger"
        actions:
          type: array
          minItems: 1
          maxItems: 20
          description: Executed in order against the triggering task.
          items:
            $ref: "#/components/schemas/AutomationAction"
        enabled:
          type: boolean
          default: true
        brandId:
          type: string
          format: uuid
          nullable: true
          description: >-
            Scope the rule to one brand. Omit (or `null`) for a workspace-global
            rule. Must be a brand in this workspace — a folder id, or a brand
            from another workspace, is rejected with 400.
        hqBoardId:
          type: string
          format: uuid
          nullable: true
          description: >-
            Scope the rule to one HQ board. The trigger and EVERY action must
            then come from the `hq*` vocabulary — mixing a deliverable trigger
            with a board scope (or the reverse) is rejected with 400. Must be a
            live board in this workspace; a trashed, archived or foreign board
            is rejected with 400. Mutually exclusive with `brandId`. (1.76.0)
      description: >-
        Write payloads use the same vocabulary reads return (`statuses`,
        `optionId`, `stageConditions`). On the deprecated read-side fields:
        `status` is accepted when `statuses` is absent, and a single
        `onlyWhenStage` object is accepted when `stageConditions` is absent.

    AutomationRuleUpdateInput:
      type: object
      minProperties: 1
      description: >-
        Recipe edits must include BOTH `trigger` and `actions`; `enabled` may
        be sent alone.
      properties:
        trigger:
          $ref: "#/components/schemas/AutomationTrigger"
        actions:
          type: array
          minItems: 1
          maxItems: 20
          items:
            $ref: "#/components/schemas/AutomationAction"
        enabled:
          type: boolean
          description: >-
            `true` alone is refused while the rule is off and a stage it uses,
            or the date field it watches, has been deleted (1.188.0).

    AutomationRuleWriteResponse:
      type: object
      required: [data, automationsCenterEnabled]
      properties:
        data:
          $ref: "#/components/schemas/AutomationRule"
        automationsCenterEnabled:
          type: boolean

    AutomationFlow:
      type: object
      required: [id, name, description, status, archived, folderId, publishedVersion, publishedAt, draftUpdatedAt, createdAt, replacesRuleId]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type: [string, "null"]
        status:
          type: string
          enum: [draft, published, paused, dormant]
          description: draft = never ran; dormant = needs attention (a reference broke or the plan changed).
        archived:
          type: boolean
        folderId:
          type: [string, "null"]
          format: uuid
        publishedVersion:
          type: [integer, "null"]
        publishedAt:
          type: [string, "null"]
          format: date-time
        draftUpdatedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        replacesRuleId:
          type: [string, "null"]
          format: uuid
          description: The classic rule this flow replaces; publishing the flow turns that rule off.
        summary:
          type: string
          description: The draft as one plain-English sentence.
        triggers:
          type: array
          items:
            type: string
        stepCount:
          type: integer
        activity:
          type: object
          required: [runs7d, failures7d, lastRunAt, liveEnrollments]
          properties:
            runs7d:
              type: integer
            failures7d:
              type: integer
            lastRunAt:
              type: [string, "null"]
              format: date-time
            liveEnrollments:
              type: integer
              description: Tasks / HQ cards in the flow right now (running or waiting).
    AutomationFlowDetail:
      allOf:
        - $ref: "#/components/schemas/AutomationFlow"
        - type: object
          required: [outline, draftGraph, publishedGraph, check]
          properties:
            outline:
              type: array
              items:
                type: string
              description: The draft step by step, branches indented two spaces.
            draftGraph:
              $ref: "#/components/schemas/AutomationFlowGraph"
            publishedGraph:
              oneOf:
                - $ref: "#/components/schemas/AutomationFlowGraph"
                - type: "null"
            check:
              oneOf:
                - $ref: "#/components/schemas/AutomationFlowCheck"
                - type: "null"
    AutomationFlowGraph:
      type: object
      description: |
        A tree of steps hanging off one or more OR'd triggers, plus explicit
        `goTo` jumps. Every step names its successor(s) by id; `null` is END.
        Trigger and action payloads use the same vocabulary as automation
        rules. Step kinds: action, find, ifElse, wait, goal, split, goTo,
        addToFlow, removeFromFlow, stop. Every loop must pass through a wait
        that holds at least one hour. Custom notification copy (message
        slots on notify steps) may not contain links, emails, phone numbers,
        mass mentions, markup or shouting.

        What a 400 checks on a write or validate (1.189.2): each step's own
        fields for its kind, a trigger node holding only the fields below,
        each `filters` group's `match` and `conditions`, each condition's
        `field` and `op` (and the value, on a field with a fixed list), and
        the lists and who-objects inside a payload (`recipients`, `target`,
        `pool`, `value`, `statusIds`, `memberIds`, `weekdays`). Whether a
        status, column or member exists is a finding in `check`, not a 400.
      required: [version, triggers, root, steps]
      properties:
        version:
          type: integer
          enum: [1]
        triggers:
          type: array
          maxItems: 10
          items:
            type: object
            required: [id, trigger]
            additionalProperties: false
            properties:
              id:
                type: string
              label:
                type: [string, "null"]
              trigger:
                type: object
                additionalProperties: true
              boardId:
                type: [string, "null"]
              filters:
                type: [object, "null"]
                required: [match, conditions]
                additionalProperties: true
                properties:
                  match:
                    type: string
                    enum: [all, any]
                  conditions:
                    type: array
                    items:
                      type: object
                      required: [field, op]
                      additionalProperties: true
        root:
          type: [string, "null"]
        steps:
          type: object
          additionalProperties:
            type: object
            required: [id, kind]
            additionalProperties: true
            properties:
              id:
                type: string
              kind:
                type: string
                enum: [action, find, ifElse, wait, goal, split, goTo, addToFlow, removeFromFlow, stop]
    AutomationFlowWriteInput:
      type: object
      required: [name]
      properties:
        name:
          type: string
          maxLength: 120
        description:
          type: [string, "null"]
          maxLength: 500
        graph:
          $ref: "#/components/schemas/AutomationFlowGraph"
    AutomationFlowUpdateInput:
      type: object
      properties:
        name:
          type: string
          maxLength: 120
        description:
          type: [string, "null"]
          maxLength: 500
        graph:
          $ref: "#/components/schemas/AutomationFlowGraph"
        expectedDraftUpdatedAt:
          type: string
          format: date-time
    AutomationFlowWriteResponse:
      type: object
      required: [data, check]
      properties:
        data:
          $ref: "#/components/schemas/AutomationFlow"
        check:
          oneOf:
            - $ref: "#/components/schemas/AutomationFlowCheck"
            - type: "null"
    AutomationFlowCheck:
      type: object
      required: [canPublish, errors, warnings]
      properties:
        canPublish:
          type: boolean
        errors:
          type: array
          items:
            $ref: "#/components/schemas/AutomationFlowIssue"
        warnings:
          type: array
          items:
            $ref: "#/components/schemas/AutomationFlowIssue"
    AutomationFlowIssue:
      type: object
      required: [kind, code, ref, message]
      properties:
        kind:
          type: string
          enum: [structure, reference, conflict]
        code:
          type: string
        ref:
          type: [string, "null"]
          description: The step or trigger id the issue points at.
        message:
          type: string
    AutomationFlowRun:
      type: object
      required: [id, taskId, hqItemId, state, currentStepId, exitReason, enteredAt, finishedAt, steps]
      properties:
        id:
          type: string
          format: uuid
        taskId:
          type: [string, "null"]
          format: uuid
        hqItemId:
          type: [string, "null"]
          format: uuid
        state:
          type: string
          enum: [active, waiting, completed, exited, failed]
        currentStepId:
          type: [string, "null"]
        exitReason:
          type: [string, "null"]
        enteredAt:
          type: string
          format: date-time
        finishedAt:
          type: [string, "null"]
          format: date-time
        steps:
          type: array
          items:
            type: object
            required: [stepId, outcome, skipCode, error, ranAt]
            properties:
              stepId:
                type: string
              outcome:
                type: string
                enum: [success, skipped, failed, dryRun]
              skipCode:
                type: [string, "null"]
              error:
                type: [string, "null"]
              ranAt:
                type: string
                format: date-time
    AutomationRule:
      type: object
      description: |
        One Automations Center rule. Rules run in the returned order, and only
        while the workspace's master automations toggle is on.
      required: [id, brandId, hqBoardId, enabled, trigger, actions, createdAt, updatedAt]
      properties:
        id: { type: string, format: uuid }
        hqBoardId:
          type: string
          format: uuid
          nullable: true
          description: >-
            The HQ board this rule is scoped to, or `null` for a deliverable
            rule. A board rule runs on that board's items only and never
            touches client work. (1.76.0)
        brandId:
          type: string
          format: uuid
          nullable: true
          description: >-
            The brand this rule is scoped to, or `null` for a workspace-global
            rule. A brand-scoped rule runs only on that brand's tasks, and only
            when the brand's automation mode admits it — so `enabled: true` on
            a brand rule does not on its own mean the rule is live.
        enabled:
          type: boolean
          description: A disabled rule is kept but never runs.
        trigger:
          $ref: "#/components/schemas/AutomationTrigger"
        actions:
          type: array
          description: Executed in order. Actions this API version does not recognise are omitted.
          items:
            $ref: "#/components/schemas/AutomationAction"
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }

    AutomationTrigger:
      description: |
        TWO vocabularies live here and they never mix inside one rule. The
        DELIVERABLE triggers act on tasks and belong to a rule whose
        `hqBoardId` is null; the `hq*` triggers act on HQ board items and
        belong to a rule whose `hqBoardId` is set. Pairing one with the other's
        actions is rejected with 400.
      oneOf:
        - type: object
          title: HQ — item added
          description: |
            An item was added to the board. Fires on real creation only:
            duplicating a card, or moving one in from another board, does not
            fire it (a duplicate already carries the original's assignees,
            dates and field values, and re-running the recipe would overwrite
            the copy the user asked for). Board rules only. (1.76.0)
          required: [type]
          properties:
            type: { type: string, enum: [hqItemCreated] }
            stageConditions:
              type: array
              maxItems: 20
              description: >-
                Stage ids the item must be sitting in. Empty = any stage.
              items: { type: string, format: uuid }
            fieldConditions:
              type: array
              maxItems: 20
              description: >-
                Select-field conditions (see HqFieldCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: HQ — item moved to a stage
          description: |
            An item moved to another stage of this board. A move that lands
            back on the same stage never fires. Board rules only. (1.76.0)
          required: [type, stageId]
          properties:
            type: { type: string, enum: [hqStageChanged] }
            stageId:
              type: string
              description: >-
                A specific stage id, or the literal `any` for every arrival in
                a different stage.
              example: any
            fieldConditions:
              type: array
              maxItems: 20
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: HQ — someone assigned
          description: |
            Fires for the people ADDED by an assignment change, never for a
            re-save that changes nothing. Board rules only. (1.76.0)
          required: [type]
          properties:
            type: { type: string, enum: [hqItemAssigned] }
            memberIds:
              type: array
              maxItems: 20
              nullable: true
              description: >-
                Narrow to particular people — at least one of them must be
                among the names the change added. `null` = anyone.
              items: { type: string, format: uuid }
            stageConditions:
              type: array
              maxItems: 20
              description: >-
                Stage ids the item must be sitting in. Empty = any stage.
              items: { type: string, format: uuid }
            fieldConditions:
              type: array
              maxItems: 20
              description: >-
                Select-field conditions (see HqFieldCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: HQ — due date set
          description: |
            The item's due date was set or changed. The new date is the ANCHOR:
            an `hqSetField` date write counts its `offsetDays` from it
            (negative = before). A CLEARED due date never fires. Board rules
            only. (1.76.0)
          required: [type]
          properties:
            type: { type: string, enum: [hqDueDateSet] }
            stageConditions:
              type: array
              maxItems: 20
              description: >-
                Stage ids the item must be sitting in. Empty = any stage.
              items: { type: string, format: uuid }
            fieldConditions:
              type: array
              maxItems: 20
              description: >-
                Select-field conditions (see HqFieldCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: HQ — due date arrives
          description: |
            Fires `offsetDays` days from the item's due date, at 09:00
            workspace-local. Negative = BEFORE it ("nudge the owner the day
            before"), 0 = on the day, positive = after.

            BLAST RADIUS: this is an ARMED TIMER, never a sweep. A reminder
            exists only because a due date was SET or CHANGED while the rule
            was live, and the server refuses to arm an instant that has already
            passed — so creating this rule can never nudge anyone about the
            board's existing overdue backlog. Enabling it additionally arms
            reminders for cards whose due date is still in the FUTURE, so the
            rule works on the board as it stands. Every firing re-validates
            that the item still carries the exact date the timer was armed
            from. Board rules only. (1.76.0)
          required: [type]
          properties:
            type: { type: string, enum: [hqDueDateReached] }
            offsetDays:
              type: integer
              minimum: -365
              maximum: 365
              default: 0
              example: -1
            stageConditions:
              type: array
              maxItems: 20
              description: >-
                Stage ids the item must be sitting in. Empty = any stage.
              items: { type: string, format: uuid }
            fieldConditions:
              type: array
              maxItems: 20
              description: >-
                Select-field conditions (see HqFieldCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: HQ — field changed
          description: |
            A board field cell was written. On a SELECT field `optionId` may
            pin a specific arrival (or `any`); on every other field kind it
            must be null and the trigger means "this cell was written". A
            CLEARED cell never fires, and a time-tracker field cannot be
            watched. A rule may not condition on — or write — the field it
            watches. Board rules only. (1.76.0)
          required: [type, fieldId]
          properties:
            type: { type: string, enum: [hqFieldChanged] }
            fieldId: { type: string, format: uuid }
            optionId:
              type: [string, "null"]
              description: >-
                SELECT fields only: an option id, the literal `any`, or `null`
                for "the cell was written" (the only meaning on other kinds).
            stageConditions:
              type: array
              maxItems: 20
              description: >-
                Stage ids the item must be sitting in. Empty = any stage.
              items: { type: string, format: uuid }
            fieldConditions:
              type: array
              maxItems: 20
              description: >-
                Select-field conditions (see HqFieldCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: HQ — doc updated
          description: |
            The item's doc body changed. DEBOUNCED per rule per item to at most
            once every 15 minutes: the editor autosaves, so an undebounced rule
            would fire on every keystroke burst. Board rules only. (1.76.0)
          required: [type]
          properties:
            type: { type: string, enum: [hqDocUpdated] }
            stageConditions:
              type: array
              maxItems: 20
              description: >-
                Stage ids the item must be sitting in. Empty = any stage.
              items: { type: string, format: uuid }
            fieldConditions:
              type: array
              maxItems: 20
              description: >-
                Select-field conditions (see HqFieldCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: HQ — file attached
          description: |
            A file finished uploading onto the item. Keyed on the ITEM, so a
            multi-file drop is one arrival rather than one per file; files
            dropped on the board's shelf belong to no card and never fire.
            Board rules only. (1.76.0)
          required: [type]
          properties:
            type: { type: string, enum: [hqFileAttached] }
            stageConditions:
              type: array
              maxItems: 20
              description: >-
                Stage ids the item must be sitting in. Empty = any stage.
              items: { type: string, format: uuid }
            fieldConditions:
              type: array
              maxItems: 20
              description: >-
                Select-field conditions (see HqFieldCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/HqFieldCondition"
        - type: object
          title: Status changed
          required: [type, status, statuses, onlyWhenStage, afterDays]
          properties:
            type: { type: string, enum: [statusChanged] }
            status:
              type: string
              deprecated: true
              description: >-
                DEPRECATED — the first entry of `statuses`, kept for integrations
                built against the single-status shape. A rule listening on
                several statuses reports only the first here. Read `statuses`.
              example: approved
            statuses:
              type: array
              minItems: 1
              description: >-
                Every status the rule fires on. The rule triggers when the task
                moves into ANY of them.
              items: { type: string }
              example: [approved, posted]
            onlyWhenStage:
              nullable: true
              deprecated: true
              description: >-
                DEPRECATED — the first entry of `stageConditions`, kept for
                integrations built against the single-condition shape. Read
                `stageConditions`.
              type: object
              required: [columnId, optionId]
              properties:
                columnId: { type: string, format: uuid }
                optionId: { type: string, format: uuid }
            stageConditions:
              type: array
              description: >-
                Every stage condition (see AutomationStageCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            afterDays:
              type: integer
              nullable: true
              minimum: 1
              maximum: 365
              description: >-
                Whole days to wait after the status arrival before the actions
                run, or `null` to run them immediately. A delayed rule re-checks
                at run time that the task is STILL in the triggering status, and
                does nothing if it has moved on. Timers are armed only by status
                changes that happen while the rule is live, so a newly created
                rule never acts on pre-existing tasks.
              example: 60
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either. (1.74.0)
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional. (1.74.0)
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Stuck in status
          required: [type, statuses, afterHours, repeatEveryHours, includeExisting]
          description: >-
            Fires when a task has been SITTING in one of `statuses` for longer
            than `afterHours` — the inverse of `statusChanged`, which fires when
            a task moves. Evaluated by an hourly sweep, so actions run within
            the hour after the threshold is crossed. (1.77.0)
          properties:
            type: { type: string, enum: [statusStalled] }
            statuses:
              type: array
              minItems: 1
              description: >-
                Every status the rule watches. A task sitting in ANY of them
                past the threshold matches.
              items: { type: string }
              example: [inRevision]
            afterHours:
              type: integer
              minimum: 1
              maximum: 8760
              description: >-
                How long a task must sit in the status before the rule fires.
                Hours rather than days because the short end of this is an SLA
                ("4 h in client review"); one year is the ceiling.
              example: 72
            repeatEveryHours:
              type: integer
              nullable: true
              minimum: 1
              maximum: 8760
              description: >-
                Re-fire on this cadence while the task stays put, or `null` to
                fire once per stall. Capped at 20 firings per stall; the count
                resets when the task finally moves to another status.
              example: 48
            includeExisting:
              type: boolean
              default: false
              description: >-
                Whether the rule also acts on tasks that were ALREADY stalled
                when it was created.

                `false` (the default, and what you get by omitting the field)
                confines the rule to stalls that BEGIN after it is created, so
                creating one can never act on a backlog.

                `true` opts in to the workspace's existing backlog. Every task
                already past the threshold becomes eligible immediately, and the
                sweep works through them at a few hundred per hour. On a large
                workspace that can mean a great many notifications or mutations
                shortly after the rule is created — check how many tasks are
                affected before setting it.
              example: false
            stageConditions:
              type: array
              description: >-
                Every stage condition (see AutomationStageCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either.
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Stage changed
          required: [type, columnId, optionId]
          properties:
            type: { type: string, enum: [stageChanged] }
            columnId:
              type: string
              format: uuid
              description: The select ("stage group") custom column.
            optionId:
              type: string
              description: An option id, or `any` for every arrival in that column.
              example: any
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either. (1.74.0)
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional. (1.74.0)
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Custom status entered
          description: |
            Fires when a task ENTERS one of the listed workspace custom
            statuses - extra steps a workspace adds inside the main workflow,
            each sitting after a built-in status. Leaving one never fires.
            Custom statuses have no automation of their own; this is how one
            is attached. (1.108.0)
          required: [type, statusIds]
          properties:
            type: { type: string, enum: [customStatusEntered] }
            statusIds:
              type: array
              minItems: 1
              maxItems: 15
              items: { type: string, format: uuid }
              description: The custom statuses (ids from the workspace's custom status list).
            stageConditions:
              type: array
              description: >-
                Every stage condition (see AutomationStageCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: Fire only for this task type. `null` = either.
            tagConditions:
              type: array
              maxItems: 20
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Posting time scheduled
          description: |
            Fires when the task's posting time is scheduled, placed as a
            draft, or moved (never on unschedule). DATE-ANCHORED: the date
            actions' `offsetDays` count from the publish date — negative =
            before it. Re-scheduling re-fires the rule and the derived dates
            recompute (Notion-formula semantics).
          required: [type]
          properties:
            type: { type: string, enum: [publishDateScheduled] }
            stageConditions:
              type: array
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either. (1.74.0)
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional. (1.74.0)
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Date column set
          description: |
            Fires when a date-kind custom column (e.g. "Record Date") is set
            or changed — never on clear. DATE-ANCHORED on the new cell value.
          required: [type, columnId]
          properties:
            type: { type: string, enum: [dateColumnSet] }
            columnId:
              type: string
              format: uuid
              description: The date-kind custom column that anchors the rule.
            stageConditions:
              type: array
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either. (1.74.0)
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional. (1.74.0)
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Deadline approaching
          description: |
            Fires when the task's deadline is `daysBefore` days away — at the
            instant `deadline − daysBefore × 24h`, evaluated by an hourly sweep
            and fired ONCE per (rule, task, deadline value); a moved deadline
            fires again for its new date. `daysBefore: 0` = the deadline itself
            passes with the task still open. Approved, posted and archived
            tasks never fire. DATE-ANCHORED: date actions' `offsetDays` count
            from the deadline's calendar day. `field: internal` needs
            dual-deadline mode. (1.80.0)
          required: [type, field, daysBefore]
          properties:
            type: { type: string, enum: [deadlineApproaching] }
            field:
              type: string
              enum: [external, internal]
            daysBefore:
              type: integer
              minimum: 0
              maximum: 60
              example: 3
            stageConditions:
              type: array
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either.
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Inbound URL called (catch hook)
          description: |
            The rule gets its own URL — `POST /api/hooks/automations/{token}`
            with `{ "taskId" }` or `{ "taskRef": "TL-1042" }` runs THIS rule's
            actions on that task. Zapier, Make, n8n, a form builder or a custom
            app can fire it with no API key: the token is the credential.
            Omit `token` on create and the server mints one (192 random bits);
            resend the trigger with a new token to revoke the old URL. `url`
            is read-only. (1.80.0)


            **`url` and `token` are returned only to a key holding
            `write:automations` (1.84.0).** They are the live credential —
            anyone holding the URL can run this rule's actions on any task in
            the workspace with no API key at all — so returning them to a
            read-scoped key would make `read:automations` transitively write
            access. A read-scoped caller receives `tokenPrefix` instead, which
            is enough to tell two hooks apart. Create/update responses always
            include the full values (the caller necessarily holds the write
            scope). Same treatment as webhook signing secrets.
          required: [type, tokenPrefix]
          properties:
            type: { type: string, enum: [inboundHook] }
            url:
              type: string
              format: uri
              readOnly: true
              description: >-
                The full URL to POST to. Present only with `write:automations`.
              example: https://timeliner.io/api/hooks/automations/K2rBp8x_3wQ9tVhLm0aY7nZc4dEfGhJi
            token:
              type: string
              pattern: "^[A-Za-z0-9_-]{24,64}$"
              description: >-
                The URL's last path segment. Omit to have one minted. Returned
                only with `write:automations`.
            tokenPrefix:
              type: string
              readOnly: true
              description: >-
                First 8 characters of the token — always present, safe for a
                read-scoped caller, and enough to identify which hook a rule uses.
              example: K2rBp8x_
            stageConditions:
              type: array
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either.
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Comment added
          description: |
            Fires when a review comment lands on the task — from the app, the
            API or a share link; thread replies included. `author` narrows to
            client (`guest`) or team comments; `onlyWithMention` to comments
            that @-mention at least one member. Fires after the comment is
            stored and never blocks it. (1.80.0)
          required: [type]
          properties:
            type: { type: string, enum: [commentAdded] }
            author:
              type: string
              nullable: true
              enum: [guest, team, null]
              description: >-
                Fire only for comments by clients (share-link reviewers and
                guest seats — `guest`) or by workspace members (`team`).
                `null` = anyone.
            onlyWithMention:
              type: boolean
              nullable: true
              description: >-
                Fire only when the comment @-mentions at least one member.
                Reads back as `false` when unset.
            stageConditions:
              type: array
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either.
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional.
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Version uploaded
          description: |
            Fires when a new task version finishes uploading, optionally
            conditioned on the file's media properties ("video under 90
            seconds", "vertical"). Conditions evaluate the metadata available
            at upload time; files whose codec the browser cannot probe have
            none, so media-conditioned rules do not fire for them.
          required: [type]
          properties:
            type: { type: string, enum: [versionUploaded] }
            maxDurationSec:
              type: integer
              nullable: true
              minimum: 1
              maximum: 86400
              description: Fire only when duration ≤ this many seconds.
              example: 90
            minDurationSec:
              type: integer
              nullable: true
              minimum: 1
              maximum: 86400
            orientation:
              type: string
              nullable: true
              enum: [vertical, horizontal, square, null]
              description: Fire only for this orientation (from width × height).
            aspectRatio:
              type: string
              nullable: true
              enum: ["16:9", "9:16", "1:1", "4:5", "4:3", "21:9", null]
              description: >-
                Fire only for this named delivery ratio, matched from
                width × height within 3.5%. Strictly finer than `orientation`,
                which cannot separate a 16:9 master from a 4:3 cutdown; the two
                compose. A file whose real ratio matches none of the listed ones
                (say 5:4) matches no ratio condition, and — like the duration
                and orientation conditions — a file whose dimensions were not
                probeable at upload never matches. (1.74.0)
            stageConditions:
              type: array
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either. (1.74.0)
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional. (1.74.0)
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Client request approved
          description: |
            Fires once per TASK created by approving a client request (intake
            form) — the moment a brief becomes real work. Narrow it with
            `answerConditions` (all must hold; an unanswered question never
            matches). `anchorQuestionId` names a DATE question on the form whose
            answer becomes the anchor, so the date actions' `offsetDays` count
            back from the client's own requested date (`-14` = fourteen days
            before it). Without an anchor the offsets count from the approval
            moment. (1.70.0)
          required: [type]
          properties:
            type: { type: string, enum: [intakeApproved] }
            answerConditions:
              type: array
              maxItems: 10
              items:
                $ref: "#/components/schemas/AutomationAnswerCondition"
            anchorQuestionId:
              type: string
              nullable: true
              description: >-
                A date question on the request form. Its answer anchors every
                date action's offset. Null (or an unanswered question) makes the
                offsets count from the approval moment instead.
            formId:
              type: string
              format: uuid
              nullable: true
              description: >-
                Fire only for requests submitted through THIS intake form.
                `null` = every form in the workspace, which is every rule
                authored before the scope existed. A form-scoped rule never
                fires for a request whose originating form is unknown (legacy
                rows) — it fails closed rather than guessing. (1.75.0)
            stageConditions:
              type: array
              items:
                $ref: "#/components/schemas/AutomationStageCondition"
            taskType:
              type: string
              nullable: true
              enum: [media, doc, null]
              description: >-
                Fire only for this task type. `null` = either. (1.74.0)
            tagConditions:
              type: array
              maxItems: 20
              description: >-
                Every tag condition (see AutomationTagCondition semantics).
                Empty = unconditional. (1.74.0)
              items:
                $ref: "#/components/schemas/AutomationTagCondition"
        - type: object
          title: Client request came in
          description: |
            The ROUTING trigger. Fires while an approval is deciding which brand
            the work belongs to — before any project or task exists — so it
            pairs ONLY with the `routeToBrand` action, and a rule carrying it
            may hold no other actions. Workspace-scope only: the brand is what
            is being decided, so `brandId` must be null. (1.70.0)
          required: [type]
          properties:
            type: { type: string, enum: [intakeSubmitted] }
            answerConditions:
              type: array
              maxItems: 10
              items:
                $ref: "#/components/schemas/AutomationAnswerCondition"
            formId:
              type: string
              format: uuid
              nullable: true
              description: >-
                Fire only for requests submitted through THIS intake form.
                `null` = every form in the workspace, which is every rule
                authored before the scope existed. A form-scoped rule never
                fires for a request whose originating form is unknown (legacy
                rows) — it fails closed rather than guessing. (1.75.0)

    AutomationTagCondition:
      type: object
      description: >-
        One condition on a task's tags. Refs naming the SAME tag column are
        alternatives (the task needs any one of them); refs across DIFFERENT tag
        columns must all hold. A task whose cell for a named column is empty
        never matches. Tags live in their own vocabulary per column, so a ref
        names both.
      required: [columnId, tagId]
      properties:
        columnId:
          type: string
          format: uuid
          description: A tag-kind custom column.
        tagId:
          type: string
          format: uuid
          description: A tag defined on that column.

    AutomationAnswerCondition:
      type: object
      description: >-
        One condition on a submitted intake answer. Set `optionIds` for a select
        question (any listed option counts) or `equals` for a text question
        (trimmed, case-insensitive) — never both. Both null means "answered at
        all". Several conditions all have to hold, and an unanswered question
        never matches.
      required: [questionId]
      properties:
        questionId:
          type: string
          description: A question id from the brand's request form.
        optionIds:
          type: array
          nullable: true
          maxItems: 20
          items: { type: string }
        equals:
          type: string
          nullable: true
          example: Podcast

    AutomationAssigneeTarget:
      oneOf:
        - type: object
          title: Named members
          required: [kind, memberIds]
          properties:
            kind: { type: string, enum: [members] }
            memberIds:
              type: array
              items: { type: string, format: uuid }
        - type: object
          title: By role
          description: |
            Everyone currently carrying this sub-role label (e.g. "Scriptwriter").
            Resolved when the rule RUNS, so it follows staffing changes.
          required: [kind, subRole]
          properties:
            kind: { type: string, enum: [subRole] }
            subRole: { type: string, example: Scriptwriter }

    AutomationAction:
      description: |
        As with `AutomationTrigger`, two vocabularies: the DELIVERABLE actions
        act on tasks, the `hq*` actions act on HQ board items, and a rule may
        only carry the set matching its scope. `createHqItem` is the one
        deliberate bridge — a deliverable action that writes onto a board.
      oneOf:
        - type: object
          title: HQ — move to stage
          description: |
            Moves the item to the next stage by order, or to a named one.
            "next" on the last stage is a no-op. Board rules only. (1.76.0)
          required: [type, target]
          properties:
            type: { type: string, enum: [hqMoveToStage] }
            target:
              oneOf:
                - { type: string, enum: [next] }
                - type: object
                  required: [stageId]
                  properties:
                    stageId: { type: string, format: uuid }
        - type: object
          title: HQ — set field
          description: |
            Writes one of the board's custom fields. Board rules only. (1.76.0)
          required: [type, fieldId, value]
          properties:
            type: { type: string, enum: [hqSetField] }
            fieldId: { type: string, format: uuid }
            value:
              $ref: "#/components/schemas/HqActionFieldValue"
        - type: object
          title: HQ — assign
          description: |
            Adds assignees (union with the current list — never removes
            anyone). People who cannot OPEN the board are dropped and named in
            the run history: assigning work someone cannot see is not work you
            can give them. Newly-added people get the normal HQ assignment
            notification. Board rules only. (1.76.0)
          required: [type, target]
          properties:
            type: { type: string, enum: [hqAssign] }
            target:
              $ref: "#/components/schemas/AutomationAssigneeTarget"
        - type: object
          title: HQ — unassign
          description: |
            Drops assignees; `{"kind":"all"}` clears the list. Within ONE rule
            an assign wins over a later unassign, so "assign M + unassign
            everyone" means "make M the sole owner". Board rules only. (1.76.0)
          required: [type, target]
          properties:
            type: { type: string, enum: [hqUnassign] }
            target:
              oneOf:
                - $ref: "#/components/schemas/AutomationAssigneeTarget"
                - type: object
                  required: [kind]
                  properties:
                    kind: { type: string, enum: [all] }
        - type: object
          title: HQ — set due date
          description: |
            Sets the item's due date relative to the trigger's anchor (under
            the two due-date triggers) or to the fire moment. Also re-arms any
            "due date arrives" reminders on the board. A due-date TRIGGER may
            not carry this action — it would overwrite its own anchor (400).
            Board rules only. (1.76.0)
          required: [type, offsetDays]
          properties:
            type: { type: string, enum: [hqSetDueDate] }
            offsetDays: { type: integer, minimum: -365, maximum: 365 }
        - type: object
          title: HQ — notify
          description: |
            Notifies an audience about the item, deep-linked to the card.
            Anyone without access to the board is dropped. Board rules only.
            (1.76.0)
          required: [type, recipients]
          properties:
            type: { type: string, enum: [hqNotify] }
            recipients:
              oneOf:
                - type: object
                  required: [kind]
                  properties:
                    kind:
                      type: string
                      enum: [assignees, boardMembers, admins]
                      description: >-
                        `boardMembers` = everyone who can open this board (its
                        explicit members, or every active team member when the
                        board is open).
                - type: object
                  required: [kind, memberIds]
                  properties:
                    kind: { type: string, enum: [members] }
                    memberIds:
                      type: array
                      minItems: 1
                      maxItems: 20
                      items: { type: string, format: uuid }
        - type: object
          title: HQ — move the source deliverable
          description: |
            Moves the TASK this card was spawned from by a `createHqItem`
            action ("invoice card reaches Paid → mark the deliverable Posted").
            A card with no source task is a NO-OP, not an error — hand-made
            cards track no deliverable. The status write goes through the same
            path a human move does: history row, notifications and webhooks all
            fire, attributed to "Automation". Board rules only. (1.76.0)
          required: [type, status]
          properties:
            type: { type: string, enum: [hqSetSourceTaskStatus] }
            status:
              type: string
              description: >-
                Must be a status this workspace's own board shows (its template
                minus any disabled statuses).
              example: posted
        - type: object
          title: Add a card to an HQ board
          description: |
            The CROSS-SURFACE action, on a DELIVERABLE rule: drops a card on an
            internal HQ board when a task lands ("when a deliverable is
            approved, add it to the Invoicing board").

            IDEMPOTENT: the card is stamped with the source task and a unique
            index allows one card per (board, task), so a task that re-enters
            the trigger status reports a no-op instead of burying the board in
            duplicates. That same link is what `hqSetSourceTaskStatus` reads to
            move the deliverable back when the card is done. (1.76.0)
          required: [type, boardId]
          properties:
            type: { type: string, enum: [createHqItem] }
            boardId:
              type: string
              format: uuid
              description: A live (not trashed or archived) HQ board in this workspace.
            stageId:
              type: string
              format: uuid
              nullable: true
              description: Stage the card lands in. `null` = the board's first stage.
            titlePrefix:
              type: string
              maxLength: 60
              nullable: true
              description: >-
                Prepended to the task's own title ("Invoice — Launch film").
                `null` = the task title verbatim.
            assign:
              description: Seed the card's assignees, or `null` for none.
              oneOf:
                - $ref: "#/components/schemas/AutomationAssigneeTarget"
                - type: "null"
            dueOffsetDays:
              type: integer
              minimum: -365
              maximum: 365
              nullable: true
              description: >-
                The card's due date, in whole days from the trigger's anchor
                (or the fire moment). `null` = no due date.
        - type: object
          title: Move to stage
          required: [type, columnId, target]
          properties:
            type: { type: string, enum: [moveToStage] }
            columnId: { type: string, format: uuid }
            target:
              description: '`next` = the following option by sort order, or a specific option.'
              oneOf:
                - type: string
                  enum: [next]
                - type: object
                  required: [optionId]
                  properties:
                    optionId: { type: string, format: uuid }
        - type: object
          title: Set status
          required: [type, status]
          properties:
            type: { type: string, enum: [setStatus] }
            status: { type: string, example: toDo }
        - type: object
          title: Set custom status
          description: >-
            Move the task into a workspace custom status (its base status plus
            the custom one). Counts as the rule's one status-setting action -
            it can't be combined with setStatus. Skipped for a brand that
            doesn't use that custom status. (1.108.0)
          required: [type, statusId]
          properties:
            type: { type: string, enum: [setCustomStatus] }
            statusId: { type: string, format: uuid }
        - type: object
          title: Notify
          required: [type, recipients]
          properties:
            type: { type: string, enum: [notify] }
            recipients:
              oneOf:
                - type: object
                  required: [kind]
                  properties:
                    kind:
                      type: string
                      enum: [assignees, admins, supervisorsAndAdmins]
                - type: object
                  required: [kind, memberIds]
                  properties:
                    kind: { type: string, enum: [members] }
                    memberIds:
                      type: array
                      items: { type: string, format: uuid }
        - type: object
          title: Assign
          description: |
            Adds assignees (never removes). People without access to the task's
            project are skipped rather than assigned — assigning them would leave
            them tagged but unable to open the task.
          required: [type, target]
          properties:
            type: { type: string, enum: [assign] }
            target:
              $ref: "#/components/schemas/AutomationAssigneeTarget"
        - type: object
          title: Unassign
          required: [type, target]
          properties:
            type: { type: string, enum: [unassign] }
            target:
              oneOf:
                - $ref: "#/components/schemas/AutomationAssigneeTarget"
                - type: object
                  title: Everyone
                  required: [kind]
                  properties:
                    kind: { type: string, enum: [all] }
        - type: object
          title: Auto-assign
          description: |
            Workload action — picks ONE person from the pool and assigns them.
            The pick is the pool member with the lowest committed workload over
            the next 14 days (scheduled hours, plus an allowance for each open
            task that has no estimate (2h unless an admin changes it in
            Settings → Workload → Auto-assign), as a share of their capacity
            with time off already subtracted). Anyone within 5 percentage
            points of the lowest load counts as tied, and a tie goes to the
            highest on-time completion rate over the last 90 days (deliveries
            that had a deadline; fewer than 3 = no rate, which ranks below any
            real rate).

            A workspace whose admin chose the Monthly target method instead
            picks the pool member furthest below their monthly task target
            (main tasks given to them this calendar month that they still hold,
            divided by their target, default 25). Anyone at or above 100% load
            is skipped; equal progress goes to the lower load, then the on-time
            rate. If everyone is fully booked, the lowest-load pick applies.

            The pool is narrowed to members with access to the task's project
            before anyone is ranked, and a member with no capacity in the window
            is never picked. A task that ALREADY has an assignee is left
            untouched — a manual assignment always wins. When nobody qualifies,
            or the workload cannot be read, nobody is assigned and the run is
            recorded as partial. At most one per rule.

            When the task is a parent, every variant of it that has no
            assignee goes to the same person (variants never run rules of their
            own, so this is the only moment an unowned variant gets its editor).

            `flagWhenFull` raises a capacity flag: when even the freest person
            in the pool is booked to 100% or more of their capacity the task is
            STILL assigned, and the project's supervisors and admins are
            notified. When nobody can be picked at all, those same people are
            always notified that the task has no assignee — whether or not
            `flagWhenFull` is on.
          required: [type, pool]
          properties:
            type: { type: string, enum: [autoAssign] }
            flagWhenFull:
              type: boolean
              default: false
              description: |
                Notify the project's supervisors and admins when the task went
                to someone already fully booked. (A task nobody could be picked
                for is always reported to them, whatever this says.) Always
                present on responses.
            dailyLimit:
              type: [integer, "null"]
              minimum: 1
              maximum: 50
              default: null
              description: |
                The most tasks auto-assign hands any ONE person per day, counted
                in the workspace's time zone. Someone at the ceiling is not a
                candidate until tomorrow; when everyone is, the task stays
                unassigned (and the project's supervisors and admins are told
                it has no assignee). Every auto-assign
                rule in the workspace counts toward the same per-person total;
                variants that follow their parent do not count. Enforced
                atomically, so a bulk move cannot overshoot it. `null` / omitted
                = no ceiling. Anything else that is not a whole number from 1 to
                50 is a 400. Always present on responses.
            pool:
              oneOf:
                - type: object
                  title: All editors
                  description: Every active team member whose role is `editor`.
                  required: [kind]
                  properties:
                    kind: { type: string, enum: [editors] }
                - type: object
                  title: A sub-role
                  description: |
                    Everyone holding this sub-role when the rule fires. Must be a
                    sub-role at least one active team member holds.
                  required: [kind, subRole]
                  properties:
                    kind: { type: string, enum: [subRole] }
                    subRole: { type: string, example: Colorist }
                - type: object
                  title: A hand-picked shortlist
                  description: |
                    Specific team members (ids from `GET /members`), for pools
                    no role describes — a region, a skill tier, the people
                    cleared for one client. Ids that are not active team
                    members are dropped; fewer than 2 left is a 400. A member
                    deactivated later simply stops being a candidate.
                  required: [kind, memberIds]
                  properties:
                    kind: { type: string, enum: [members] }
                    memberIds:
                      type: array
                      minItems: 2
                      maxItems: 100
                      items: { type: string, format: uuid }
        - type: object
          title: Set deadline
          required: [type, field, offsetDays]
          properties:
            type: { type: string, enum: [setDeadline] }
            field:
              type: string
              enum: [internal, external]
            offsetDays:
              type: integer
              minimum: -365
              maximum: 365
              description: |
                Days from the moment the rule fires — or, under a
                date-anchored trigger (`publishDateScheduled` /
                `dateColumnSet`), days from the ANCHOR date. `0` = the same
                day; negative = before. Relative, never absolute — an absolute
                date would give every task the rule touches one identical
                deadline.
              example: 3
        - type: object
          title: Set time estimate
          description: |
            Workload action — sets the task's total time estimate. When a
            per-assignee breakdown exists it is rescaled proportionally.
          required: [type, minutes]
          properties:
            type: { type: string, enum: [setEstimate] }
            minutes:
              type: integer
              minimum: 1
              maximum: 60000
              example: 180
        - type: object
          title: Set start date
          description: |
            Workload action — sets the task's start date relative to the moment
            the rule fires, or to the anchor date under a date-anchored trigger
            (same semantics as Set deadline's offsetDays).
          required: [type, offsetDays]
          properties:
            type: { type: string, enum: [setStartDate] }
            offsetDays:
              type: integer
              minimum: -365
              maximum: 365
              example: 0
        - type: object
          title: Set date column
          description: |
            Writes a date-kind custom column at anchor/fire-moment +
            `offsetDays` — the backward-scheduling workhorse ("Edit Brief =
            publish date − 21 days"). A `dateColumnSet` rule may not write its
            own trigger column (400).
          required: [type, columnId, offsetDays]
          properties:
            type: { type: string, enum: [setDateColumn] }
            columnId:
              type: string
              format: uuid
              description: A date-kind custom column of the workspace.
            offsetDays:
              type: integer
              minimum: -365
              maximum: 365
              example: -21
        - type: object
          title: Set posting time
          description: |
            Places or moves the task's posting time to anchor/fire-moment +
            `offsetDays`. Unscheduled tasks get a 09:00 workspace-local DRAFT
            placement (no platforms or connected accounts required); an
            already-committed post keeps its status and time-of-day and is
            time-moved. Posts that already went out are never re-timed. A
            `publishDateScheduled` rule may not carry this action (400), and
            it requires a plan with social distribution (Enterprise, Agency,
            or Scale) — on other plans it is rejected at authoring time (400).
          required: [type, offsetDays]
          properties:
            type: { type: string, enum: [setPostingTime] }
            offsetDays:
              type: integer
              minimum: -365
              maximum: 365
              example: 7
        - type: object
          title: Set project deadline
          description: |
            Writes the PROJECT's target end date — the only action that reaches
            above the task. Built for the intake flow ("the client asked to go
            live on the 3rd, so the project is due on the 3rd"): under an
            anchored trigger `offsetDays: 0` is the requested date itself.
            Every task of one approval runs the rule and resolves the same day,
            so the repeat is idempotent. (1.70.0)
          required: [type, offsetDays]
          properties:
            type: { type: string, enum: [setProjectDeadline] }
            offsetDays:
              type: integer
              minimum: -365
              maximum: 365
              example: 0
        - type: object
          title: Send to brand
          description: |
            Sends an approved client request to a specific brand ("if the show
            name is B, file it under Brand B"). Pairs ONLY with the
            `intakeSubmitted` trigger (400 otherwise), and such a rule may hold
            no other actions. Applied only when the approval creates a NEW
            project and the reviewer did not pick a destination themselves; the
            target brand is re-validated at run time and a trashed, foreign or
            folder node is ignored in favour of the brand the client submitted
            to. (1.70.0)
          required: [type, nodeId]
          properties:
            type: { type: string, enum: [routeToBrand] }
            nodeId:
              type: string
              format: uuid
              description: An active brand in this workspace. A folder is rejected.
        - type: object
          title: Apply pricing template
          description: |
            Applies a workspace pricing template to the task (client price /
            editor pay / badge; `pricing_source: template`) and, when the
            template carries a default time estimate and the task has none,
            prefills the estimate too. Paid tasks are left untouched.
          required: [type, templateId]
          properties:
            type: { type: string, enum: [applyPricingTemplate] }
            templateId: { type: string, format: uuid }
        - type: object
          title: Call a webhook
          description: |
            Queues one signed `automation.triggered` delivery to one of the
            workspace's webhook endpoints (`GET /api/v1/webhooks`) every time
            the rule fires — through the ordinary delivery queue (retries,
            dead-letter, `GET /api/v1/webhooks/{id}/deliveries`). The endpoint
            need not (and cannot) subscribe to `automation.triggered`; the rule
            names it. A deleted or paused endpoint is a `webhookMissing` skip
            in the run log, never a failed rule. (1.80.0)
          required: [type, webhookId]
          properties:
            type: { type: string, enum: [sendWebhook] }
            webhookId:
              type: string
              format: uuid
              description: A webhook subscription in this workspace.
        - type: object
          title: Post to Slack
          description: |
            Posts a one-line summary — task, what happened, brand / project, a
            login-gated link — to Slack every time the rule fires. `channelId`
            null (or omitted) = the brand's mapped channel (project → brand →
            workspace default, as configured under Settings → Integrations →
            Slack), so a remapped brand never needs the rule edited; a channel
            id pins one channel. Refused at author time unless Slack is
            connected — a `400` with `reason: slack_not_connected` (1.108.0);
            at run time a disconnected install, a plan without
            Slack, Slack switched off for the workspace, no mapped channel, or
            a refused post is a `slackUnavailable` skip in the run log, never a
            failed rule. (1.80.0)
          required: [type]
          properties:
            type: { type: string, enum: [postToSlack] }
            channelId:
              type: string
              nullable: true
              pattern: "^[CG][A-Z0-9]{8,}$"
              description: A Slack conversation id (C… / G…). `null` = the brand's mapped channel.
            channelName:
              type: string
              nullable: true
              maxLength: 80
              description: Display-only name captured when the rule was authored; ignored without `channelId`.
        - type: object
          title: Send review link to Slack
          description: |
            Posts the client's review link to Slack in client-friendly words,
            every time the rule fires: a headline (by default "New cut ready for
            your review: <title>", in the workspace's notification language), an
            optional opening line and the link, with no brand, project path or
            "Sent by" line. The link is the task's own share link: the level
            picked in Share wins, so the live link
            `GET /api/v1/tasks/{id}/share-link` returns goes out at its own
            level; with no pick, a live approver link is reused, else the newest
            live link. A link that cannot approve is never upgraded: it goes out
            with a neutral label and the run log carries `reviewLinkLimited`,
            because a client cannot approve from it. A link a person switched off
            stays off and nothing is posted (`reviewLinkSwitchedOff`); with no
            link, or only one past its expiry, a new approver link with no expiry
            is made, filed under the rule's author — never for a brand in Secure
            guest-notification mode (`reviewLinkSecureBrand`) or one that is not
            active (`reviewLinkInTrash`, as for a task that is not active).
            Anyone holding the link can
            approve without signing in, and Approve only shows at Client Approval
            or End Client Approval. At End Client Approval a link the client
            already approved with is not re-sent, because its Approve would be
            refused (`reviewLinkEndClientUsed`). Those four are designed
            outcomes: a flow step records them as `skipped` with that
            `skipCode`, and a classic rule's run stays a success. A link that
            could not be read or made is `reviewLinkUnavailable`; it and
            `slackUnavailable` are the faults that keep a classic run partial
            (1.222.2).
            `channelId` works as on `postToSlack`. Refused
            at author time unless Slack is connected — a `400` with
            `reason: slack_not_connected`; at run time, Slack gates that fail
            before the send (not connected, plan, switched off, no channel) are a
            `slackUnavailable` skip and make no link; if Slack refuses the post
            itself, for example when the bot is not in the channel, the skip is
            the same but a link just made stays on the task, unsent. Neither fails
            the rule. (1.209.0)
          required: [type]
          properties:
            type: { type: string, enum: [sendReviewLinkToSlack] }
            channelId:
              type: string
              nullable: true
              pattern: "^[CG][A-Z0-9]{8,}$"
              description: A Slack conversation id (C… / G…). `null` = the brand's mapped channel.
            channelName:
              type: string
              nullable: true
              maxLength: 80
              description: Display-only name captured when the rule was authored; ignored without `channelId`.
            message:
              type: object
              nullable: true
              description: >-
                Your own words, `null` = the standard ones. The link and its label
                cannot be changed. Each slot refuses links, email addresses, phone
                numbers, mentions of everyone, formatting code and rude or
                promotional wording, with a `400`. Variables, in double braces:
                `task.title`, `task.status`, `brand.name`, `project.name`,
                `workspace.name`.
              properties:
                slackHeadline:
                  type: string
                  nullable: true
                  maxLength: 120
                  description: Replaces the standard headline. One line.
                intro:
                  type: string
                  nullable: true
                  maxLength: 200
                  description: An opening line under the headline.
        - type: object
          title: Send email
          description: |
            Emails the people the action names, every time the rule fires, with
            the admin's own subject and message (1.223.0). Recipients are kinds,
            never text: the task's assignees, named team members who can open the
            task's project, the task's clients (the project's client-tier guests)
            and up to 10 typed addresses. Typed addresses are accepted only on a
            rule that belongs to one brand (`brandId`) and never while the
            workspace is on a trial (`400`); a client who has not activated
            their account yet is held back like a typed address during a trial.
            Only an active workspace admin may author the step — for an API
            key, the person who made the key, checked on every create and every
            edit that keeps the step, beside the rule's own author — and the
            author is re-checked every time the rule fires
            (`sendEmailAuthorNotAdmin`).

            The subject and message refuse links, email addresses, phone numbers,
            mentions of everyone, formatting code and rude or promotional wording
            with a `400`, and are checked again at send: text that fails then is
            never sent (`sendEmailBlockedCopy`). `includeReviewLink: true` adds
            Timeliner's own button — the task's share link for typed addresses
            (the level picked in Share, never raised; no link for a link
            switched off, a Secure brand, Trash or an end-client link already
            used: `sendEmailNoReviewLink`, the email still goes), and each team
            member's or client's own sign-in link.

            Sent from Timeliner's no-reply address as "<Workspace> via
            Timeliner", with replies to the rule's author. People outside the
            team get a one-click unsubscribe (per workspace and address); the
            do-not-email list is honoured (a bounce, a spam complaint or an
            unsubscribe from Timeliner's email stops these emails too); each address gets at most one email
            per task from a rule in 24 hours (`sendEmailAlreadySent`), at most
            10 people outside the team per rule firing across its steps and a
            daily ceiling per workspace (`sendEmailCapReached`). Outside
            production only test inboxes are mailed
            (`sendEmailOutsideProduction`). Opt-outs, repeats and the
            non-production drop are designed outcomes and keep a classic run a
            success; every other skip keeps it partial.
          required: [type, to, subject, message]
          properties:
            type: { type: string, enum: [sendEmail] }
            to:
              type: object
              description: At least one recipient kind must be set.
              properties:
                assignees: { type: boolean, description: The task's assignees. }
                memberIds:
                  type: array
                  maxItems: 50
                  items: { type: string, format: uuid }
                  description: Team members (`GET /api/v1/members`); people who cannot open the task's project are skipped and named in the run log.
                clients: { type: boolean, description: The task's clients (the project's client-tier guests). }
                emails:
                  type: array
                  maxItems: 10
                  items: { type: string, format: email }
                  description: Typed addresses. Brand rules only; refused during a trial.
            subject:
              type: string
              maxLength: 120
              description: One line. Variables in double braces — `task.title`, `task.status`, `brand.name`, `project.name`, `workspace.name`.
            message:
              type: string
              maxLength: 1000
              description: Short paragraphs (up to 12 line breaks). Same variables as `subject`.
            includeReviewLink:
              type: boolean
              description: Adds Timeliner's review button. Read back as `false` when absent.
        - type: object
          title: Trash media
          description: |
            Moves the task's media to the workspace Trash — every live
            version's file, the task's current file, and the same for its
            active variants — while the task itself stays, so its prices and
            analytics are kept (free storage on finished work). Prices are not
            recalculated. Reversible from Trash for 30 days; restoring a
            version makes it the task's current media again. Each removal is
            recorded in the task's history as done by Automation. Skipped
            (`mediaScheduledPost` in the run log, nothing trashed) while a
            social post that is still scheduled uses the media. (1.164.0)
          required: [type]
          properties:
            type: { type: string, enum: [trashMedia] }
        - type: object
          title: Trash task
          description: |
            Moves the whole task to the workspace Trash (its variants follow,
            running timers stop), exactly like a manual trash. Must be the
            rule's LAST action — a rule with any action after it is refused
            with `400`. Skipped (`mediaScheduledPost`) when the task is a
            variant a scheduled parent post publishes. Reversible from Trash
            for 30 days. (1.164.0)
          required: [type]
          properties:
            type: { type: string, enum: [trashTask] }
        - type: object
          title: Write caption (AI)
          description: |
            Writes the post's caption with AI in the brand's voice (the
            brand's voice profile), only when the post has no caption yet — a
            caption someone wrote is never replaced (`captionAlreadyWritten`
            in the run log). A fresh video is transcribed first, so the caption
            lands shortly after the run, not inside it. Billed to the
            workspace's credits like the composer's AI caption. Document
            posts follow their document and are skipped
            (`captionNotForDocuments`). Needs social posting on the plan:
            refused with `400` otherwise. (1.211.0; credits wording 1.227.1)
          required: [type]
          properties:
            type: { type: string, enum: [writePostCaption] }
        - type: object
          title: Schedule into posting plan
          description: |
            Schedules the post into the next free time of its brand's
            posting plan (Brand settings → Posting plan): the earliest planned
            time at least the plan's lead time ahead, for the post's networks,
            that no other post of the brand already holds. Posts to the
            networks the post names, or the brand's connected networks when it
            names none, through the same checks as any schedule. A post already
            queued keeps its time (`alreadyScheduled`); a calendar draft is
            never turned into a live post — it stays a draft at its time, and
            the brand's posting-alert person is notified to schedule it
            (`postIsDraft`, 1.213.2); a published post is never moved
            (`postingTimeLocked`). With no posting times
            (`noPostingPlan`), no free time in the next 10 weeks
            (`noFreePostingTime`) or no network (`noPostNetworks`) nothing is
            scheduled and the brand's posting-alert person is notified. Cannot
            be combined with `setPostingTime` in one rule, nor used on a
            `publishDateScheduled` rule (`400`). The post's history records it
            as scheduled by this automation. Needs social posting on the
            plan. The auto-publish recipe is `statusChanged` to `approved` →
            `writePostCaption`, `scheduleNextPostingTime`. (1.211.0)
            Since 1.232.0 uploading to a connected YouTube channel needs the
            brand's one-time consent for automatic uploads (given in the app,
            Edit Brand → Posting plan — YouTube API Services Terms §9.1):
            without it the YouTube leg is not created (`youtubeConsentMissing`),
            the post's other networks are still scheduled, and the brand's
            posting-alert person is notified. With it, a post with no
            made-for-kids answer of its own uploads with the answer the consent
            chose. A YouTube leg YouTube would refuse as it stands (no
            made-for-kids answer, a title, description or tags over YouTube's
            limits, a video over 15 minutes the channel can't post) is skipped
            the same way (`youtubeRefused`) — never shortened, never the whole
            post — and a YouTube leg the team posts itself (no connected
            channel) is created as before.
          required: [type]
          properties:
            type: { type: string, enum: [scheduleNextPostingTime] }
        - type: object
          title: Add tag
          description: |
            Puts one tag of a tag-kind custom column on the task. The task's
            other tags in that column stay; a task that already carries the tag
            is left as it is. Column and tag ids come from
            `GET /api/v1/custom-columns`; an unknown column or tag is refused
            with `400`. Re-checked when the rule runs: a column or tag deleted
            since is skipped (`tagMissing` in the run log), a brand-specific tag
            on a task of another brand is skipped (`tagNotForBrand`), and a cell
            already holding 30 tags is skipped (`tagCellFull`) — the rule's
            other actions still run. (1.206.0)
          required: [type, columnId, tagId]
          properties:
            type: { type: string, enum: [addTag] }
            columnId:
              type: string
              format: uuid
              description: A tag-kind custom column of the workspace.
            tagId:
              type: string
              format: uuid
              description: A tag of that column.
        - type: object
          title: Remove tag
          description: |
            Takes one tag off the task's cell in a tag-kind custom column,
            leaving its other tags. A task that does not carry the tag is left
            as it is. Same ids and the same `400` as Add tag; a column deleted
            since is skipped (`tagMissing`). A rule may not add and remove the
            same tag, or name it twice (`400`). (1.206.0)
          required: [type, columnId, tagId]
          properties:
            type: { type: string, enum: [removeTag] }
            columnId:
              type: string
              format: uuid
              description: A tag-kind custom column of the workspace.
            tagId:
              type: string
              format: uuid
              description: A tag of that column.

    UpdateAutomationsInput:
      type: object
      description: Any subset of the review/workflow automations. Send only what changes.
      minProperties: 1
      properties:
        autoAdvanceVariantReview: { type: boolean }
        reviewRevertTimeout: { type: integer, minimum: 0, maximum: 1440 }
        autoSubmitForReviewTimeout: { type: integer, minimum: 0, maximum: 1440 }
        guestRevertWindow: { type: integer, minimum: -1, maximum: 1440 }
        guestApprovalRevertWindow: { type: integer, minimum: -1, maximum: 1440 }

    Comment:
      type: object
      required:
        [id, text, author, isGuest, type, timecode, endTimecode, fileId, resolved, parentId, createdAt, attachments, drawings, frames, smpte, version, page, textAnchor, transcriptExcerpt, mentions, visibility, editedAt, postPlatform, authorKind, agentName, ai]
      properties:
        id: { type: string, format: uuid }
        text: { type: string }
        author:
          type: string
          description: Display name of who wrote it.
        isGuest:
          type: boolean
          description: >-
            True for a client/guest comment — a signed-in guest's comment or an
            anonymous share-link commenter's. Decided by whether the author was a
            guest when they wrote it, so a teammate later converted to a guest
            stays `false` on comments they wrote as a teammate.
        type:
          type: string
          description: comment_type — general / video-point / video-range / text-selection / post-*.
        timecode:
          type:
            - number
            - "null"
          description: Video position in seconds (start of the comment), or null for a general comment.
        endTimecode:
          type:
            - number
            - "null"
          description: >-
            End of a range comment in seconds, or null for a point (since
            1.111.0). Since 1.132.0 never at or before `timecode` — a
            backwards or zero-length range is a single point.
        fileId:
          type:
            - string
            - "null"
          format: uuid
          description: The version (file) the comment was left on, or null — a comment with no version shows on every version of the task (since 1.111.0; a new top-level comment posted here carries the task's current version since 1.126.2).
        resolved: { type: boolean }
        parentId:
          type:
            - string
            - "null"
          description: The thread's first comment when this is a reply, else null.
        createdAt: { type: string, format: date-time }
        attachments:
          type: array
          description: >-
            Files attached to the comment (since 1.111.0). Uploads still in
            progress or failed are left out.
          items:
            $ref: "#/components/schemas/CommentAttachment"
        drawings:
          type: array
          description: >-
            Annotations drawn on the frame or page (since 1.111.0). A comment
            can be only a drawing, with empty `text`.
          items:
            $ref: "#/components/schemas/CommentDrawing"
        frames:
          description: >-
            The timecode in whole frames — 0-based, the nearest frame at the
            version's real frame rate (since 1.132.0). Null when the comment
            has no timecode, has no video version, or the frame rate is
            unknown.
          oneOf:
            - $ref: "#/components/schemas/CommentFrames"
            - type: "null"
        smpte:
          description: The same frames as SMPTE non-drop-frame labels, or null (since 1.132.0).
          oneOf:
            - $ref: "#/components/schemas/CommentSmpte"
            - type: "null"
        version:
          description: >-
            The version the comment was left on (since 1.132.0). Null for a
            comment saved with no version — such a comment shows on every
            version of the task; it is not missing data.
          oneOf:
            - $ref: "#/components/schemas/CommentVersion"
            - type: "null"
        page:
          type:
            - integer
            - "null"
          description: A PDF comment's 1-based page (from its pins / drawings), else null (since 1.132.0).
        textAnchor:
          description: >-
            The passage a document or caption comment was left on, or null
            (since 1.132.0).
          oneOf:
            - $ref: "#/components/schemas/CommentTextAnchor"
            - type: "null"
        transcriptExcerpt:
          description: >-
            What is said IN THE VIDEO during a range comment — the words the
            Transcript tab underlines for it, from the version's transcript
            (since 1.132.0). Only on a thread's first comment with a range on
            a video or audio version that has a ready transcript; null
            otherwise. Not the reviewer's voice memo — that is
            `attachments[].transcript`.
          oneOf:
            - $ref: "#/components/schemas/CommentTranscriptExcerpt"
            - type: "null"
        mentions:
          type: array
          description: Who was @-mentioned (since 1.132.0). Always empty on a client's share-link comment.
          items:
            $ref: "#/components/schemas/CommentMention"
        visibility:
          type: string
          enum: [public, team]
          description: >-
            `public` — clients can see it; `team` — internal (since 1.132.0).
            A client's share-link comment is always `public`.
        editedAt:
          type:
            - string
            - "null"
          format: date-time
          description: When the text or timecode was last edited, or null when never edited (since 1.132.0).
        postPlatform:
          type:
            - string
            - "null"
          description: >-
            Post caption comments: which network's caption the note is about
            (`shared`, or a platform), else null (since 1.132.0).
        authorKind:
          type: string
          enum: [team, guest, ai]
          description: >-
            Who wrote it: `team` (a teammate), `guest` (a client) or `ai` (an
            AI note) (since 1.137.0).
        agentName:
          type:
            - string
            - "null"
          description: >-
            The name an AI note is signed with — `Ronald` (Timeliner's AI
            editor; `Timeliner Editor` before 1.152.0), `Smith` (Timeliner's
            AI check; `Timeliner Supervisor` before 1.168.0 — not returned
            while the AI check is a staff beta, since 1.172.0), or an outside
            AI's own `aiLabel` — else null (since
            1.137.0). Match Timeliner's own AI on `ai.source`, not on this
            name. `author` stays whose row it is (an outside AI's note belongs
            to the API key's person).
        ai:
          description: An AI note's facts, or null for a person's comment (since 1.137.0).
          oneOf:
            - $ref: "#/components/schemas/CommentAiNote"
            - type: "null"

    VoiceMemoTranscript:
      type: object
      required: [commentId, attachmentId, transcript, cached, noSpeech]
      properties:
        commentId: { type: string, format: uuid }
        attachmentId: { type: string }
        transcript:
          type: string
          description: What the reviewer said in the memo ("" when `noSpeech`).
        cached:
          type: boolean
          description: True when an existing transcript was returned (no charge).
        noSpeech:
          type: boolean
          description: True when the memo holds no recognizable speech (silence, music, noise) — not a failure, do not retry.
    CommentAiNote:
      type: object
      required: [source, kind, severity, extraRanges]
      properties:
        source:
          type: string
          enum: [editor, supervisor, external]
          description: >-
            `editor` / `supervisor` — Timeliner's own AI (`Ronald`, the
            editing service's editor, signed `Timeliner Editor` before
            1.152.0; and `Smith`, the AI check, signed `Timeliner Supervisor`
            before 1.168.0); `external` — an outside AI
            that posted through this API with an `aiLabel`.
        kind:
          type:
            - string
            - "null"
          enum: [issue, assetRequest, riskConfirm, deliveryNote, question, null]
          description: What the note is about, or null.
        severity:
          type:
            - string
            - "null"
          enum: [mustFix, suggestion, note, null]
          description: How much it matters, or null.
        extraRanges:
          type: array
          description: More places in the video the same note is about.
          items:
            $ref: "#/components/schemas/CommentRange"

    CommentRange:
      type: object
      required: [start, end]
      properties:
        start:
          type: number
          minimum: 0
          maximum: 86400
          description: Seconds.
        end:
          type:
            - number
            - "null"
          minimum: 0
          maximum: 86400
          description: Seconds, after `start`; null = a single point.

    CommentFrames:
      type: object
      required: [start, end]
      properties:
        start: { type: integer, minimum: 0 }
        end:
          type:
            - integer
            - "null"
          minimum: 0
          description: Null for a point, or a range shorter than one frame.

    CommentSmpte:
      type: object
      required: [start, end]
      properties:
        start:
          type: string
          description: HH:MM:SS:FF, e.g. `00:00:05:00`.
        end:
          type:
            - string
            - "null"

    CommentVersion:
      type: object
      required: [fileId, number, current, kind, width, height, duration, fps]
      properties:
        fileId: { type: string, format: uuid }
        number:
          type:
            - integer
            - "null"
          description: The version number the app shows (1 = V1), or null when the task has no record of it.
        current:
          type: boolean
          description: True when this is the task's current version.
        kind:
          type: string
          enum: [video, image, pdf, audio, other]
        width:
          type:
            - integer
            - "null"
          description: Pixels.
        height:
          type:
            - integer
            - "null"
          description: Pixels.
        duration:
          type:
            - number
            - "null"
          description: Seconds.
        fps:
          type:
            - number
            - "null"
          description: The real frame rate, e.g. `29.97`; null when unknown.

    CommentTextAnchor:
      type: object
      required: [quotedText, charOffset]
      properties:
        quotedText: { type: string }
        charOffset:
          type:
            - number
            - "null"
          description: Character offset of the passage when the comment was made, or null.

    CommentTranscriptExcerpt:
      type: object
      required: [text, turns, truncated]
      properties:
        text:
          type: string
          description: Every word in the range, in order.
        turns:
          type: array
          description: The same words, split where the speaker changes.
          items:
            type: object
            required: [speaker, text]
            properties:
              speaker:
                type:
                  - string
                  - "null"
                description: The transcript's speaker label (e.g. `speaker_0`), or null without speaker detection — every video transcribed since 1.139.1.
              text: { type: string }
        truncated:
          type: boolean
          description: True when the range held more than 1,000 words and the rest was left out.

    CommentMention:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          description: The mentioned person's user id.
        name:
          type:
            - string
            - "null"
          description: The name shown in the mention when it was written, or null.

    CommentWithReplies:
      allOf:
        - $ref: "#/components/schemas/Comment"
        - type: object
          required: [replies]
          properties:
            replies:
              type: array
              description: Every reply in this comment's thread, oldest first (empty for a reply).
              items:
                $ref: "#/components/schemas/Comment"

    CommentWithRepliesResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/CommentWithReplies"

    CommentAttachment:
      type: object
      required: [id, name, mimeType, size, removed, downloadUrl, transcript]
      properties:
        id: { type: string }
        name: { type: string }
        mimeType: { type: string }
        size:
          type: number
          description: Bytes.
        removed:
          type: boolean
          description: >-
            True when a cancelled workspace's media purge removed the file —
            `downloadUrl` and `transcript` are then null.
        downloadUrl:
          type:
            - string
            - "null"
          description: >-
            Presigned link to the original file, valid 7 days. Null when
            removed, or for a stored file the API cannot link.
        transcript:
          type:
            - string
            - "null"
          description: Speech-to-text of a voice memo, when one was generated in the app.

    CommentDrawingPoint:
      type: object
      required: [x, y]
      properties:
        x: { type: number, minimum: 0, maximum: 1 }
        y: { type: number, minimum: 0, maximum: 1 }

    CommentDrawing:
      type: object
      description: >-
        One annotation. Coordinates are normalized 0-1 against the picture
        the reviewer drew on (0,0 = top-left) — the video frame with the
        player's letterbox bars excluded, the image, or the PDF page — so
        `x × width` of the version is the source pixel. `bounds` says where
        it sits for every type; since 1.132.0 circles add `center` /
        `radius`, pins `point` and freehand strokes their `points`. Only the
        five stored types exist.
      required: [type, color, lineThickness, opacity, page, bounds]
      properties:
        type:
          type: string
          enum: [freehand, rectangle, circle, arrow, pin]
        color:
          type:
            - string
            - "null"
          description: The stroke color, e.g. `#ff3b30`.
        lineThickness:
          type:
            - number
            - "null"
          description: >-
            Stroke width in screen pixels at the size the reviewer drew it —
            not normalized to the picture (since 1.132.0).
        opacity:
          type: number
          minimum: 0
          maximum: 1
          description: 1 = fully opaque, the default (since 1.132.0).
        page:
          type:
            - integer
            - "null"
          description: The 1-based PDF page, or null on video and images.
        bounds:
          type: object
          required: [x, y, width, height]
          properties:
            x: { type: number, minimum: 0, maximum: 1 }
            y: { type: number, minimum: 0, maximum: 1 }
            width: { type: number, minimum: 0, maximum: 1 }
            height: { type: number, minimum: 0, maximum: 1 }
        from:
          $ref: "#/components/schemas/CommentDrawingPoint"
        to:
          $ref: "#/components/schemas/CommentDrawingPoint"
        center:
          $ref: "#/components/schemas/CommentDrawingPoint"
        radius:
          type: object
          description: >-
            Circles: the half-width and half-height, as fractions of the
            picture's width and height.
          required: [x, y]
          properties:
            x: { type: number, minimum: 0 }
            y: { type: number, minimum: 0 }
        point:
          $ref: "#/components/schemas/CommentDrawingPoint"
        points:
          type: array
          maxItems: 128
          description: Freehand strokes — the path, thinned to at most 128 points, first and last kept.
          items:
            $ref: "#/components/schemas/CommentDrawingPoint"

    CommentList:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Comment"

    CommentResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/Comment"

    ChatScopeType:
      type: string
      enum: [global, brand, project, dm, custom]
      description: >-
        Which kind of chat channel. `global` is the workspace-wide channel,
        `custom` a standalone channel such as `#marketing`.

    ChatMessage:
      type: object
      required: [id, text, author, isSystem, teamOnly, createdAt]
      properties:
        id:
          type: string
          format: uuid
        text:
          type: string
        author:
          type: string
          description: Display name of the sender, or `Timeliner` for a system post.
        isSystem:
          type: boolean
          description: True for app-generated activity posts (status changes, uploads).
        teamOnly:
          type: boolean
          description: True when the message is internal and hidden from clients.
        createdAt:
          type: string
          format: date-time

    ChatMessageList:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ChatMessage"

    ChatMessageResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/ChatMessage"

    ChatChannel:
      type: object
      required: [scopeType, scopeId, name, visibility, archived]
      properties:
        scopeType:
          $ref: "#/components/schemas/ChatScopeType"
        scopeId:
          type: string
          format: uuid
          nullable: true
          description: Null for the global channel.
        name:
          type: string
        visibility:
          type: string
          nullable: true
          enum: [private, team, client, null]
          description: >-
            Standalone channels only: `private` (invited members), `team` (all
            team members) or `client` (members plus selected clients). Null for
            the global channel.
        archived:
          type: boolean

    ChatChannelList:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ChatChannel"

    CreateChatMessageInput:
      type: object
      required: [scopeType, text]
      properties:
        scopeType:
          $ref: "#/components/schemas/ChatScopeType"
        scopeId:
          type: string
          format: uuid
          nullable: true
          description: Required for every scope except `global`.
        text:
          type: string
          minLength: 1
          maxLength: 10000

    PostingTime:
      type: object
      required: [id, days, time, platforms]
      properties:
        id:
          type: string
          maxLength: 64
          description: Row id (keep the one you read; optional on a write).
        days:
          type: array
          minItems: 1
          items: { type: integer, minimum: 0, maximum: 6 }
          description: Weekdays — 0 = Sunday … 6 = Saturday.
        time:
          type: string
          pattern: "^([01]\\d|2[0-3]):[0-5]\\d$"
          description: Wall-clock time, "HH:MM" 24h, in the plan's zone.
        platforms:
          type: array
          items:
            $ref: "#/components/schemas/SocialPlatform"
          description: Networks this time is for; empty = every network the post targets.

    PostingPlan:
      type: object
      required: [brandId, times, timeZone, useBestTime, minLeadMinutes, alertMemberId, updatedAt]
      additionalProperties: false
      properties:
        brandId: { type: string, format: uuid }
        times:
          type: array
          maxItems: 28
          items:
            $ref: "#/components/schemas/PostingTime"
        timeZone:
          type: ["string", "null"]
          description: IANA zone; `null` = the workspace's zone.
        useBestTime:
          type: boolean
          description: Use the brand's best posting hour from its analytics.
        minLeadMinutes:
          type: integer
          minimum: 15
          maximum: 1440
          description: The least time between scheduling a post and its slot (default 60).
        alertMemberId:
          type: ["string", "null"]
          format: uuid
          description: The team member alerted when a post can't be placed.
        updatedAt:
          type: ["string", "null"]
          format: date-time

    PostingPlanResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/PostingPlan"

    UpdatePostingPlanInput:
      type: object
      minProperties: 1
      additionalProperties: false
      properties:
        times:
          type: array
          maxItems: 28
          description: The FULL weekly list (replace). `id` and `platforms` are optional on each entry.
          items:
            type: object
            required: [days, time]
            properties:
              id: { type: string, maxLength: 64 }
              days:
                type: array
                minItems: 1
                items: { type: integer, minimum: 0, maximum: 6 }
              time:
                type: string
                pattern: "^([01]\\d|2[0-3]):[0-5]\\d$"
              platforms:
                type: array
                items:
                  $ref: "#/components/schemas/SocialPlatform"
        timeZone: { type: ["string", "null"], description: "IANA zone, or null for the workspace's." }
        useBestTime: { type: boolean }
        minLeadMinutes: { type: integer, minimum: 15, maximum: 1440 }
        alertMemberId: { type: ["string", "null"], format: uuid }

    UpdateChatMessageInput:
      type: object
      required: [text]
      additionalProperties: false
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 10000
          description: The message's full new text.

    HeaderCardShareLink:
      type: object
      required: [cardId, active, url, blockReason]
      additionalProperties: false
      properties:
        cardId: { type: string, format: uuid }
        active:
          type: boolean
          description: True while the card has a working link.
        url:
          type: ["string", "null"]
          format: uri
          description: The public read-only page (`/card-share/<token>`); `null` with no active link.
        blockReason:
          type: ["string", "null"]
          enum: [hiddenFromClients, unsupportedType, null]
          description: Why no working link can exist for this card right now.

    HeaderCardShareLinkResponse:
      type: object
      required: [data]
      properties:
        data:
          $ref: "#/components/schemas/HeaderCardShareLink"

    HeaderCardShareRevokeResponse:
      type: object
      required: [data]
      properties:
        data:
          type: object
          required: [cardId, revoked]
          additionalProperties: false
          properties:
            cardId: { type: string, format: uuid }
            revoked:
              type: boolean
              description: False when the card had no active link to turn off.

    CreateTaskChatInput:
      type: object
      required: [text]
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 10000

    CreateCommentInput:
      type: object
      required: [text]
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 10000
        parentId:
          type:
            - string
            - "null"
          format: uuid
          description: >-
            Reply inside this comment's thread — a review comment on the same
            task (team or client). Omit (or null) for a new top-level comment
            (since 1.111.0). A reply refuses the placement keys below.
        timecode:
          type:
            - number
            - "null"
          minimum: 0
          maximum: 86400
          description: Seconds into a video or audio version — a timeline note (since 1.137.0).
        endTimecode:
          type:
            - number
            - "null"
          minimum: 0
          maximum: 86400
          description: A range's end in seconds, after `timecode` (since 1.137.0).
        fileId:
          type:
            - string
            - "null"
          format: uuid
          description: >-
            The version to comment on (a `version.fileId` of this task). Omit
            for the task's current version (since 1.137.0).
        visibility:
          type: string
          enum: [public, team]
          description: >-
            `public` — clients see it; `team` — internal. Honoured within the
            key person's role; omit for the role's default — or, on a reply,
            for its thread's. Beside `parentId` (since 1.146.0) `team` keeps
            the reply internal inside a client-visible thread, and `public`
            inside an internal thread is a `400`. An AI note (`aiLabel`) is
            always `team` — `public` beside it is a `400` (since 1.137.0).
        drawings:
          type: array
          maxItems: 20
          description: >-
            Marks on the picture, in the read shape, normalised 0-1 (since
            1.137.0).
          items:
            $ref: "#/components/schemas/CommentDrawingInput"
        page:
          type: integer
          minimum: 1
          maximum: 10000
          description: The PDF page the drawings sit on (a drawing's own `page` wins). Needs `drawings` (since 1.137.0).
        notify:
          type: boolean
          description: >-
            Tell the task's assigned editors a comment was added (their
            notification settings decide how). Not with `aiLabel` (since
            1.137.0).
        aiLabel:
          type: string
          minLength: 1
          maxLength: 40
          description: >-
            Post an AI note signed with this name — the caller is an AI. One
            line of plain text (no control or invisible formatting
            characters), never a name starting with "Timeliner" and never
            "Ronald" (since 1.152.0) or "Smith" (since 1.168.0) — Timeliner's
            own AI names, compared
            ignoring case, width and spaces. Shown to the team only with an AI
            badge, always silent, never runs comment automations; a guest's
            key → `403` (since 1.137.0).
        aiSeverity:
          type: string
          enum: [mustFix, suggestion, note]
          description: An AI note's severity. Needs `aiLabel` (since 1.137.0).
        extraRanges:
          type: array
          maxItems: 20
          description: More places the same AI note applies to. Needs `aiLabel` and `timecode` (since 1.137.0).
          items:
            type: object
            required: [start]
            properties:
              start: { type: number, minimum: 0, maximum: 86400 }
              end:
                type:
                  - number
                  - "null"
                minimum: 0
                maximum: 86400

    CommentDrawingInput:
      type: object
      required: [type]
      description: >-
        One mark, in the shape `drawings[]` comes back in. Coordinates are
        normalised 0-1 on the picture (letterbox excluded) or the PDF page.
      properties:
        type:
          type: string
          enum: [pin, rectangle, circle, arrow, freehand]
        point:
          description: Pins.
          $ref: "#/components/schemas/CommentDrawingPoint"
        bounds:
          type: object
          description: Rectangles.
          required: [x, y, width, height]
          properties:
            x: { type: number, minimum: 0, maximum: 1 }
            y: { type: number, minimum: 0, maximum: 1 }
            width: { type: number, minimum: 0, maximum: 1 }
            height: { type: number, minimum: 0, maximum: 1 }
        center:
          description: Circles (ellipses).
          $ref: "#/components/schemas/CommentDrawingPoint"
        radius:
          description: Circles — half-width and half-height as fractions of the picture.
          $ref: "#/components/schemas/CommentDrawingPoint"
        from:
          description: Arrows — where the arrow starts.
          $ref: "#/components/schemas/CommentDrawingPoint"
        to:
          description: Arrows — where it points.
          $ref: "#/components/schemas/CommentDrawingPoint"
        points:
          type: array
          description: Freehand strokes, 1-500 points.
          maxItems: 500
          items:
            $ref: "#/components/schemas/CommentDrawingPoint"
        color:
          type: string
          pattern: "^#[0-9A-Fa-f]{6}$"
          description: Defaults to the app's red, #EF4444.
        lineThickness:
          type: number
          minimum: 1
          maximum: 20
          description: Stroke width; defaults to 4.
        opacity:
          type: number
          minimum: 0
          maximum: 1
        page:
          type:
            - integer
            - "null"
          minimum: 1
          description: The PDF page this mark sits on.

    ResolveCommentInput:
      type: object
      required: [resolved]
      properties:
        resolved:
          type: boolean
          description: true resolves the thread, false reopens it.

    UpdateWorkspaceSettingsInput:
      type: object
      description: Any subset of the writable settings. Send only what changes.
      minProperties: 1
      properties:
        editorCanCreateTasks: { type: boolean }
        editorCanCreateProjects: { type: boolean, description: "Let editors create projects in brands they can access, and delete only their own." }
        editorSeeAllProjectTasks: { type: boolean }
        editorCanReachClientApproval: { type: boolean }
        supervisorCanApprove: { type: boolean }
        supervisorChartAccess: { type: boolean }
        autoAddSupervisorsToNodes: { type: boolean }
        supervisorCanArchiveBrands: { type: boolean, description: "Let supervisors archive/unarchive the brands they manage. Projects stay admin-only." }
        dualDeadlineMode: { type: boolean, description: "Plan-gated to enable." }
        automationsCenterEnabled: { type: boolean, description: "Plan-gated to enable; the Automations Center master toggle." }
        defaultRevisionLimit:
          type:
            - integer
            - "null"
          minimum: 0
          maximum: 50
          description: Plan-gated to set. null = unlimited.
        showFrameNumber: { type: boolean }
        startMuted: { type: boolean }
        autoplayOnOpen: { type: boolean }
        enableTranscripts: { type: boolean, description: "Plan-gated to enable." }
        transcriptSidePanel: { type: boolean, description: "Docks the transcript left of the review player, beside the comments, for team members on desktop. All plans; defaults to false." }
        autoTranscribeUploads:
          type: boolean
          description: >-
            Plan-gated to enable, like enableTranscripts (every plan with
            transcripts since 1.143.0; Scale and Enterprise only from 1.106.0).
            Starts the transcript of every NEW uploaded video (task versions
            and raw files) automatically, while enableTranscripts is on; a task
            version's transcript is free (since 1.228.4), each raw file's uses
            the workspace's credits. Defaults to false.
        footageEnrichMode: { type: string, enum: [off, manual, auto], description: "AI footage tagging (1.160.0): off (default) runs nothing, manual lets team members tag footage on request after a credit estimate, auto also tags every NEW video upload within footageEnrichDailyCreditCap per day. Plan-gated to enable, like enableTranscripts; off is always accepted. Each run uses the workspace's credits (about 7 credits per minute on the standard tier)." }
        footageEnrichTier: { type: string, enum: [standard, light], description: "The model tier footage tagging runs on: standard (default, the most detail) or light (several times cheaper per minute). 1.160.0." }
        footageEnrichDailyCreditCap: { type: integer, minimum: 0, maximum: 100000, description: "The most credits automatic footage tagging may reserve per UTC day (default 2000); manual requests are never capped here. 1.160.0." }
        footageEnrichWriteTaskTags: { type: boolean, description: "Also write a task deliverable's AI footage tags into the task's Tags column (default true). 1.160.0." }
        rawFilesCommentsEnabled: { type: boolean, description: "Turns on task-review-style comments (timecodes, ranges, drawings, unread badges) for raw files. All plans; defaults to false." }
        openTaskOnTitleClick: { type: boolean, description: "When true, a single click on a task's name (List view) or card title (Board) opens the task for team members, and rename moves to double-click. All plans; defaults to false (click renames)." }
        guestCanViewBrief:
          type: boolean
          description: >-
            Plan-gated to enable. Defaults to false (briefs hidden from
            guests); a per-brand override set in-app wins over this value.
        guestAllStagesVisible:
          type: boolean
          description: >-
            "Show clients every workflow stage" — the workspace default
            (false). When true, client-tier guests (signed in and on share
            links) see tasks in EVERY non-archive workflow stage — to-do, in
            progress, internal approvals and internal revision rounds. An
            early-stage media task (and every other non-document type) is a
            view-only placeholder card: title, stage name, deadlines, planned
            posting time and a thumbnail if one exists — no playable preview,
            versions, download, transcript, post caption, comments, approval or
            other client action until it reaches client review (a cut already
            presented to the client stays watchable). A signed-in guest the
            task already reaches through an assignment — listed in its editors,
            in the parent's editors for a variant, or in a child variant's
            editors for a parent — is not narrowed by this setting: it keeps
            the rights it had before it (playback, download, transcript and
            post caption on early-stage media; comments, suggestions and, with
            guest document editing on, edits on an internal revision round).
            Early-stage documents
            follow `guestEarlyStageDocAccess`; at its default `placeholder` a
            signed-in client gets no document card at all (only its name, in
            the progress tracker). End-client-tier guests are never widened.
            Plan-gated (Studio and up) to enable; setting it false is always
            accepted. A brand's own `guestAllStagesVisible`
            (`PATCH /brands/{id}`) overrides it per brand, and the brand's share
            links inherit the brand.
        guestEarlyStageDocAccess:
          type: string
          enum: [placeholder, view, comment, edit]
          description: >-
            How far a client may go with a DOCUMENT task in a stage before
            client review while `guestAllStagesVisible` is on. `placeholder`
            (default) — no content: a signed-in client does not get the
            document on Grid, List or Board (only its name, not clickable, in
            the progress tracker), and a share-link visitor sees a placeholder
            card (title, stage, deadlines) with no body. `view` — the body can
            be read; no comments, no editing. `comment` — read + comment, for
            clients who can comment (commenter / approver roles and share
            links; a viewer reads only). `edit` — read + comment + edit,
            including live co-editing, for commenter / approver clients and
            commenter / approver / editor share links while the document is in
            To Do, In Progress, Supervisor Approval, Admin Approval or an
            internal revision round; in any other pre-review stage it is read +
            comment only. Suggestion mode is not offered on an early-stage
            document. Media and every other task type are a placeholder in
            those stages. These limits bind a client the setting alone lets see
            the task: a signed-in guest the task already reaches through an
            assignment (see `guestAllStagesVisible`) keeps the rights it had
            before the setting — on an internal revision round that includes
            comments, suggestions and, with guest document editing on, edits.
            Plan-gated (Studio and up) past `placeholder`.
            Per-brand override on `PATCH /brands/{id}`.
        guestCanCreateEndClients:
          type: boolean
          description: >-
            Whether a client's approvers may add their own end clients under
            their brand from the client portal (agency-of-agencies workspaces;
            default true). Workspace-wide (1.199.0).
        guestPortalLanding:
          type: ["string", "null"]
          enum: [media, firstView, null]
          description: "Where clients land (1.227.0): media, firstView, or null for each client's own last choice. All plans."
        guestCanMarkPosted:
          type: boolean
          description: "Whether client approvers may move their approved work to Posted (1.227.0). All plans; default true."
        guestCanSchedulePosts:
          type: boolean
          description: >-
            Requires a posting plan (Studio, Agency, Scale, or Enterprise) to
            enable. Defaults to false. Lets a client approver schedule and publish
            content they already approved, from their portal calendar or an
            approver share link, instead of the team publishing for them.

    Project:
      type: object
      required: [id, name, nodeId, createdAt]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        nodeId:
          type: string
          format: uuid
          description: UUID of the parent Node (brand or sub-folder) this project lives under.
        createdAt:
          type: string
          format: date-time
        externalMetadata:
          description: Arbitrary JSON metadata you set on the project (e.g. linking to a row in your own system).
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        status:
          type: string
          enum: [active, trashed]
          description: |
            Lifecycle status. `DELETE /api/v1/projects/{id}` is a **soft**
            delete: the project and its tasks move to Trash (restorable in the
            Timeliner app) and the project keeps existing with
            `status: "trashed"`. Trashed projects are excluded from
            `GET /api/v1/projects` unless you pass `includeTrashed=true`.
        archived:
          type: boolean
          description: |
            `true` when the project is in the Timeliner sidebar's Archive —
            archived itself, or under a brand or sidebar folder that is
            archived (the same rule the sidebar's Archived filter shows).
            Archiving hides nothing from the API: an archived project, its
            folders, raw files and tasks read exactly like an active one's.
            (1.206.0)

    ProjectFolder:
      type: object
      description: |
        A raw-FILE folder inside the project (the project file system).
        Not to be confused with `SubFolder`, the task grouping level.
      required: [id, name, projectId, visibility, createdAt]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        projectId:
          type: string
          format: uuid
        parentFolderId:
          type:
            - string
            - "null"
          format: uuid
        visibility:
          type: string
          enum: [public, internal]
        createdAt:
          type: string
          format: date-time

    SubFolder:
      type: object
      description: |
        A sub-folder (sub-project): a TASK grouping level between project and
        task — one level deep, permissions inherited from the project. Tasks
        reference it via `subFolderId` (`null` = project root). Distinct from
        `ProjectFolder`, the raw-file folder system.
      required: [id, name, sortOrder, createdAt]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        sortOrder:
          type: number
          description: Ordering weight — sub-folders are listed by (sortOrder, name) ascending.
        createdAt:
          type: string
          format: date-time

    ProjectWithFolders:
      allOf:
        - $ref: "#/components/schemas/Project"
        - type: object
          required: [folders, subFolders]
          properties:
            folders:
              type: array
              description: The project's raw-FILE folders (the file system) — NOT task grouping.
              items:
                $ref: "#/components/schemas/ProjectFolder"
            subFolders:
              type: array
              description: |
                The project's sub-folders (TASK grouping), ordered by
                (sortOrder, name). Place tasks in one via the task
                `subFolderId` field.
              items:
                $ref: "#/components/schemas/SubFolder"

    ProjectPage:
      type: object
      required: [data, nextBefore]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Project"
        nextBefore:
          type:
            - string
            - "null"
          format: date-time
          description: ISO timestamp to pass as `before` on the next request. `null` when the list is exhausted.

    CreateProjectInput:
      type: object
      required: [name, nodeId]
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 120
        nodeId:
          type: string
          format: uuid
          description: >-
            UUID of the brand, client or folder the project goes under — a
            brand's or client's id from `GET /api/v1/brands`, or the `nodeId`
            of an existing project. Never a project, task, sub-folder, file or
            HQ item id; a wrong id is named in the `404`.
        description:
          type:
            - string
            - "null"
          maxLength: 5000
        picture:
          type:
            - string
            - "null"
          description: URL of a project image, if you maintain one externally.
        folders:
          type: array
          maxItems: 20
          items:
            type: string
            minLength: 1
            maxLength: 120
          description: Optional list of starter folder names to create inside the project.
        externalMetadata:
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"

    UpdateProjectInput:
      type: object
      description: Provide at least one of the allow-listed fields.
      minProperties: 1
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 120
        description:
          type:
            - string
            - "null"
          maxLength: 5000
        externalMetadata:
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"

    Task:
      type: object
      required:
        - id
        - title
        - statusGroup
        - status
        - projectId
        - type
        - kind
        - createdAt
        - updatedAt
        - assigneeIds
        - internalRevisions
        - clientRevisions
        - endClientRevisions
        - extraRevisionsAllowed
      properties:
        id:
          type: string
          format: uuid
        taskId:
          type: string
          nullable: true
          description: |
            Permanent, human-readable handle for the task (`TL-1042`) — a
            workspace-chosen prefix plus a per-workspace sequence. Assigned by
            the server and **read-only**: it can never be set or changed through
            the API, and a number is never reused, even after the task is
            deleted. `null` when the workspace has not enabled task IDs. Not
            unique across workspaces (two workspaces may pick the same prefix).
            Look one up with `GET /api/v1/tasks?taskId=TL-1042`.
          example: TL-1042
        title:
          type: string
        statusGroup:
          type: string
          enum:
            - toDo
            - inProgress
            - supervisorApproval
            - clientApproval
            - endClientApproval
            - approved
            - posted
            - inRevision
        customStatus:
          description: |
            The workspace custom status the task sits in, inside its
            `statusGroup` (e.g. "Legal sign-off" inside `inProgress`), or `null`
            when it sits in the plain built-in status. List them with
            `GET /api/v1/custom-statuses`; set one with `PATCH` `customStatusId`.
          oneOf:
            - type: "null"
            - type: object
              required: [id, name]
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
        status:
          type: string
          description: Lifecycle status — `active`, `archived`, or `trashed`.
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            UUID of the brand (Node) the task's project belongs to, resolved
            via the project's parent node. `null` when the project has no
            parent brand. Read-only.
        internalRevisions:
          type: integer
          description: Internal (supervisor) revision rounds so far.
        clientRevisions:
          type: integer
          description: Client revision rounds so far.
        endClientRevisions:
          type: integer
          description: End-client revision rounds so far (agency-of-agency setups).
        extraRevisionsAllowed:
          type: integer
          description: Extra revision rounds granted beyond the plan default.
        type:
          type: string
          enum: [media, doc]
          description: |
            Task content type. `media` (video/image/audio — gets transcoded) or
            `doc` (document). Defaults to `media` on create.
        kind:
          type: string
          enum: [regular, variant]
        parentTaskId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            For variants, the UUID of the parent task they belong to. Creating
            the first variant promotes that task's own `kind` to `parent`.
        approvalState:
          type:
            - string
            - "null"
          enum: [pending, approved, rejected, null]
          description: |
            A VARIANT's own status — the Pending / Approved / Changes requested
            pill the app shows on it (`rejected` = "Changes requested"). A
            variant's `statusGroup` always follows its parent's, so this is the
            one status a variant has of its own; set it with
            `PUT /api/v1/tasks/{id}/approval`. `null` on a regular or parent
            task, which has no approval. *(1.176.0)*
        position:
          type:
            - integer
            - "null"
          minimum: 0
          description: |
            A variant's 0-based slot among its parent's active variants (1.163.1)
            — the order the app lists them in and a carousel post publishes
            them in (`0` = the first slide). Sort a parent's variants by it to
            read the carousel in order. `null` on a regular or parent task and
            on a variant in the trash. Set it with `position` on create or
            update.
        subFolderId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            UUID of the sub-folder (task group) inside the project the task
            sits in, or `null` when it lives at the project root. Sub-folders
            are the TASK grouping level between project and task — distinct
            from the project's `folders` (the raw-file folder system). List
            them via `GET /api/v1/projects/{id}` (`subFolders`).
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
          description: |
            When the task last changed — content and file edits, and any change
            to a field this API returns (a status or custom-status move
            included), so polling on it catches moves. Tasks last changed
            before 2026-10-14 report their last content edit until their next
            change.
        approvedAt:
          type:
            - string
            - "null"
          format: date-time
        internalDeadline:
          type:
            - string
            - "null"
          format: date
          description: Team-only deadline. Format `YYYY-MM-DD`.
        externalDeadline:
          type:
            - string
            - "null"
          format: date
          description: Client-facing deadline. Format `YYYY-MM-DD`.
        externalMetadata:
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        assigneeIds:
          type: array
          items:
            type: string
            format: uuid
          description: |
            Team members assigned to the task (the `Task.editors` set). Always
            present; `[]` when no one is assigned. Set via `PATCH` with a
            full-replace `assigneeIds` body.
        startDate:
          type:
            - string
            - "null"
          format: date
          description: |
            Workload work-window start (`YYYY-MM-DD`). The window ends at
            `internalDeadline` (when set) else `externalDeadline`. With an
            estimate and assignees the task appears on the Workload view,
            spread across working days. `null` = unscheduled.
        estimatedMinutes:
          type:
            - integer
            - "null"
          description: |
            Total time estimate in minutes (`1440` = 24h). `null` = no
            estimate. While `assigneeEstimates` rows exist this equals their
            sum (kept in sync server-side).
        assigneeEstimates:
          type: array
          items:
            type: object
            required: [memberId, estimatedMinutes]
            properties:
              memberId:
                type: string
                format: uuid
              estimatedMinutes:
                type: integer
          description: |
            Per-assignee estimate breakdown (minutes each — e.g. editor 1440,
            thumbnail designer 120, reviewer 60). When non-empty the breakdown
            is authoritative (an assignee without a row has 0); when empty the
            task total splits evenly across `assigneeIds`. Always present.
        media:
          description: |
            Download links for the task's current deliverable file (raw original
            + each transcoded variant that has finished). `null` when the task
            has no file. URLs are presigned and valid for 7 days.
          oneOf:
            - $ref: "#/components/schemas/MediaFile"
            - type: "null"
        pricing:
          description: |
            Since 1.125.0. The task's current pricing — template, pricing tag,
            client price and each editor's role and pay (the same values the
            app's pricing column and Payables show). `null` when the API key
            lacks the `read:finance` scope.
          oneOf:
            - $ref: "#/components/schemas/TaskPricingSummary"
            - type: "null"

    TaskPricingSummary:
      type: object
      required: [source, templateId, templateName, badge, clientPrice, teamPay, editorPays]
      properties:
        source:
          type: [string, "null"]
          enum: [template, manual, null]
          description: "`template` (priced from a pricing template), `manual` (a custom price set in the app), or null (never priced)."
        templateId: { type: [string, "null"], format: uuid }
        templateName: { type: [string, "null"] }
        badge:
          description: The pricing tag shown on the task in the app, or null.
          oneOf:
            - type: object
              required: [name, color]
              properties:
                name: { type: string }
                color: { type: [string, "null"] }
            - type: "null"
        clientPrice: { type: [number, "null"] }
        teamPay:
          type: [number, "null"]
          description: Total team pay on the task (sum of editorPays).
        editorPays:
          type: array
          items:
            type: object
            required: [id, memberId, role, roleSource, amount, paidAt]
            properties:
              id:
                type: string
                format: uuid
                description: TaskEditorPay id — pass to POST /api/v1/pricing/payables/mark-paid.
              memberId: { type: string, format: uuid }
              role: { type: [string, "null"] }
              roleSource:
                type: [string, "null"]
                enum: [manual, auto, optOut, null]
              amount: { type: number }
              paidAt: { type: [string, "null"], format: date-time }

    TaskPage:
      type: object
      required: [data, nextBefore]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Task"
        nextBefore:
          type:
            - string
            - "null"
          format: date-time

    WorkloadBlock:
      type: object
      required: [id, memberId, title, kind, startDate, endDate, minutesPerDay, createdAt]
      properties:
        id:
          type: string
          format: uuid
        memberId:
          type: string
          format: uuid
        title:
          type: string
        kind:
          type: string
          enum: [production, timeOff, other]
          description: |
            `timeOff` subtracts `minutesPerDay` from the member's daily
            capacity (floored at 0); `production`/`other` add scheduled load.
            Every calendar day in range counts, weekends included.
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
          description: Inclusive.
        minutesPerDay:
          type: integer
        taskId:
          type:
            - string
            - "null"
          format: uuid
          description: Optional task this block serves (e.g. the deliverable a shoot day is for).
        projectId:
          type:
            - string
            - "null"
          format: uuid
        createdBy:
          type:
            - string
            - "null"
          format: uuid
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type:
            - string
            - "null"
          format: date-time

    WorkloadGrid:
      type: object
      required: [from, to, workingDays, defaultWeeklyCapacityMinutes, members]
      properties:
        from:
          type: string
          format: date
        to:
          type: string
          format: date
        workingDays:
          type: array
          items:
            type: integer
            minimum: 1
            maximum: 7
          description: ISO weekdays (1=Mon … 7=Sun) that count as working days.
        defaultWeeklyCapacityMinutes:
          type: integer
          description: The workspace default weekly capacity (2400 = 40h).
        members:
          type: array
          items:
            type: object
            required:
              - id
              - name
              - role
              - days
              - weeks
              - tasks
              - blocks
              - unscheduledTaskIds
              - overdueTaskIds
            properties:
              id:
                type: string
                format: uuid
              name:
                type: string
              role:
                type: string
                enum: [admin, supervisor, editor]
              subRole:
                type:
                  - string
                  - "null"
              weeklyCapacityMinutes:
                type:
                  - integer
                  - "null"
                description: Per-member override; `null` = workspace default.
              days:
                type: array
                items:
                  type: object
                  required: [date, scheduledMinutes, capacityMinutes]
                  properties:
                    date:
                      type: string
                      format: date
                    scheduledMinutes:
                      type: integer
                    capacityMinutes:
                      type: integer
              weeks:
                type: array
                items:
                  type: object
                  required: [weekStart, scheduledMinutes, capacityMinutes]
                  properties:
                    weekStart:
                      type: string
                      format: date
                    scheduledMinutes:
                      type: integer
                    capacityMinutes:
                      type: integer
              tasks:
                type: array
                description: This member's task spans in range (their share of each estimate).
                items:
                  type: object
                  required: [taskId, startDate, dueDate, totalMinutes]
                  properties:
                    taskId:
                      type: string
                      format: uuid
                    startDate:
                      type: string
                      format: date
                    dueDate:
                      type: string
                      format: date
                    totalMinutes:
                      type: integer
                      description: 0 = scheduled but not estimated yet.
              blocks:
                type: array
                items:
                  type: object
                  required: [blockId, kind, title, startDate, endDate, minutesPerDay]
                  properties:
                    blockId:
                      type: string
                      format: uuid
                    kind:
                      type: string
                      enum: [production, timeOff, other]
                    title:
                      type: string
                    startDate:
                      type: string
                      format: date
                    endDate:
                      type: string
                      format: date
                    minutesPerDay:
                      type: integer
              unscheduledTaskIds:
                type: array
                items:
                  type: string
                  format: uuid
                description: Assigned tasks missing a start date or deadline.
              overdueTaskIds:
                type: array
                items:
                  type: string
                  format: uuid
                description: Open tasks whose work window ended before today.

    PostNetwork:
      type: object
      description: One social network's caption + publish state for a post.
      required: [platform, account, caption, status]
      properties:
        platform:
          type: string
          enum:
            - facebook
            - instagram
            - linkedin
            - linkedinCompany
            - tiktok
            - youtube
            - threads
            - x
        account:
          description: |
            The account this network publishes TO — handle, displayName, avatar,
            platform, status. Once the network has been processed it is the exact
            account the post went out on (or was attempted on). Before that it is
            the account the post WILL publish to: the one the post names for this
            network, else the brand's oldest CONNECTED account on the network —
            the same choice the app's composer shows and the publisher makes.
            `null` when no account on the network is connected (the network will
            need a manual post). A disconnected account is never reported as the
            default; the only way one appears before publishing is when the post
            names it explicitly, and its `status` then says it must be
            reconnected. Since 1.160.1 — before, an older disconnected account on
            the brand could be reported here instead of the connected one the post
            actually publishes to.
          oneOf:
            - $ref: "#/components/schemas/SocialAccount"
            - type: "null"
        caption:
          type: string
          description: |
            The caption for this network. Before publishing, resolved live from
            the composer (per-network override, else the shared caption). After
            publishing, the frozen snapshot that was posted. May be empty. For
            `youtube` this is the video DESCRIPTION; the separate video title is
            `platformOptions.title`.
        status:
          type:
            - string
            - "null"
          description: |
            Per-network publish status. After the post is processed this is the
            execution status (`pending`, `publishing`, `published`, `failed`,
            `canceled`, `manual`). Before processing it mirrors the post's
            overall status (`draft`, `pending`, `manual`, `missed`).
          enum:
            - draft
            - pending
            - publishing
            - published
            - failed
            - canceled
            - manual
            - missed
            - null
        scheduledAt:
          type:
            - string
            - "null"
          format: date-time
          description: When this network is/was scheduled to publish.
        publishedAt:
          type:
            - string
            - "null"
          format: date-time
          description: When this network was actually published. `null` until published.
        permalink:
          type:
            - string
            - "null"
          description: |
            Provider URL to the live post once published. On TikTok it is
            first the creator's profile (`https://www.tiktok.com/@<username>`)
            and becomes the video's own link
            (`https://www.tiktok.com/@<username>/video/<id>`) once TikTok has
            finished reviewing the post — usually within an hour; a post only
            its creator can see, or one sent to the creator's TikTok inbox,
            keeps the profile link. On Threads it is the post's own link, or
            the account's profile (`https://www.threads.com/@<username>`) when
            Threads did not return one at publish.
        providerPostId:
          type:
            - string
            - "null"
          description: |
            Provider's stable id for the published post (e.g. Meta Graph media
            id). On TikTok it is TikTok's publish id (`v_pub_file~v2-…`), not
            the video id — the video id is in `permalink`.
        error:
          type:
            - string
            - "null"
          description: |
            Why this network did not publish — the platform's refusal in plain
            words (e.g. TikTok declining the post because the account made too
            many posts through apps in the last 24 hours, or a connection that
            expired before the post went out). It is the same text the in-app
            post composer shows for that network and the `post.failed` webhook
            sends as `platforms[].error`. `null` unless `status` is `failed`
            (and `null` on a failed network that recorded no reason). Since
            1.113.0. A YouTube network that did not upload because YouTube's
            daily upload limit for Timeliner was reached reads one plain
            sentence ("Not uploaded: YouTube's daily upload limit was reached
            — nothing is wrong with the channel. …"), and no YouTube reason
            carries Google's internal project identifiers — older failures
            included (1.228.1).
        media:
          description: |
            Per-network media OVERRIDE links (when this network posts a different
            file than the task deliverable, e.g. a vertical cut). `null` means
            this network inherits the post-level `media`.
          oneOf:
            - $ref: "#/components/schemas/MediaFile"
            - type: "null"
        coverUrl:
          type:
            - string
            - "null"
          format: uri
          description: |
            The cover this network publishes from its OWN slot — the image the
            team picked in the app for this network (its composer card, or the
            Post tab's **Change**), TikTok's picked frame (with
            `platformOptions.coverTimestampMs`), or YouTube's selected thumbnail.
            Such a cover is stored with the post itself, not as a file, so it
            never appears as `customThumbnail`. Fetch it with your API key:
            `GET /api/v1/posts/{taskId}/covers/{platform}` (this URL) answers
            the image bytes. `null` when the network has no cover of its own —
            it then publishes the post's `customThumbnail` if set, else the
            video's own frame — and on an Instagram Story, a TikTok draft sent
            to the creator's inbox, or a post whose video was removed. Since
            1.157.0.
        metrics:
          description: |
            Only present with `includeMetrics=true` (v1.102.0): this network's
            latest metrics snapshot, or `null` when none was fetched — never
            zeros.
          oneOf:
            - $ref: "#/components/schemas/PostNetworkMetrics"
            - type: "null"
        platformOptions:
          description: |
            This network's per-platform composer settings (the populated shape
            matches the sibling `platform`). Read live from the draft, so —
            unlike `caption` — it reflects the post's CURRENT configuration, not
            a value frozen at publish time. Heavy base64 image fields (custom
            thumbnails / cover frames) and internal ids are omitted. `null` when
            the post has no composer draft, or the draft predates per-platform
            options. `linkedinCompany` uses the LinkedIn shape.
          oneOf:
            - $ref: "#/components/schemas/YouTubePlatformOptions"
            - $ref: "#/components/schemas/InstagramPlatformOptions"
            - $ref: "#/components/schemas/FacebookPlatformOptions"
            - $ref: "#/components/schemas/LinkedInPlatformOptions"
            - $ref: "#/components/schemas/TikTokPlatformOptions"
            - $ref: "#/components/schemas/ThreadsPlatformOptions"
            - type: "null"

    YouTubePlatformOptions:
      type: object
      description: YouTube composer settings (the `youtube` network).
      additionalProperties: false
      required: [title, tags, visibility, isShorts, collaborators, audioNote, madeForKids]
      properties:
        collaborators:
          $ref: "#/components/schemas/ManualCollaboratorsField"
        audioNote:
          $ref: "#/components/schemas/AudioNoteField"
        title:
          type: string
          description: |
            The resolved upload title — the explicit composer title if set
            (exactly as typed), else the first non-empty caption line, else the
            task name; `""` when all three are empty (since 1.229.0 there is no
            made-up default title, and such a leg fails before upload). For
            YouTube the network `caption` is the video DESCRIPTION; this is the
            separate title. YouTube takes up to 100 characters; Timeliner never
            cuts it to fit.
        tags:
          type: array
          items:
            type: string
          description: |
            Parsed tag list (split on commas, trimmed, blanks removed) with every
            tag kept as typed, including case-variant repeats, and none dropped
            to fit YouTube's 500-character limit.
        visibility:
          type: string
          enum: [public, unlisted, private]
        isShorts:
          type: boolean
        madeForKids:
          type:
            - boolean
            - "null"
          description: |
            YouTube's "made for kids" audience (COPPA). `true` = made for
            kids, `false` = not made for kids, `null` = not answered. Since
            1.232.0 a post with `null` cannot be scheduled to YouTube (`422`
            `youtube_made_for_kids_required`), and a YouTube leg that still
            reaches its posting time unanswered fails without being sent to
            YouTube — Timeliner never assumes the answer.

    InstagramPlatformOptions:
      type: object
      description: Instagram composer settings (the `instagram` network).
      additionalProperties: false
      required: [format, collaborator, firstComment, audioNote, trialReel]
      properties:
        audioNote:
          $ref: "#/components/schemas/AudioNoteField"
        trialReel:
          description: |
            Trial reel setting (Reels only) — shown to non-followers first.
            `null` = an ordinary Reel. Honoured at publish unless the
            deployment switched Instagram trial reels off (on by default
            since 1.131.1).
          oneOf:
            - $ref: "#/components/schemas/InstagramTrialReel"
            - type: "null"
        format:
          type: string
          enum: [feed, reel, story]
        collaborator:
          type: string
          description: |
            Instagram collaborator invites, as up to 3 handles separated by
            commas or spaces (a leading `@` is optional). They are sent on the
            media container at publish, so every invited account really does
            receive Instagram's collaboration request. Never sent on a Story —
            Instagram rejects collaborators on a STORIES container.
        firstComment:
          type: string
          description: Follow-up comment posted after publish, or empty.

    FacebookPlatformOptions:
      type: object
      description: Facebook composer settings (the `facebook` network).
      additionalProperties: false
      required: [format, firstComment, collaborators, audioNote]
      properties:
        collaborators:
          $ref: "#/components/schemas/ManualCollaboratorsField"
        audioNote:
          $ref: "#/components/schemas/AudioNoteField"
        format:
          type: string
          description: Facebook post type. Only `post` publishes today; `reel`/`story` are reserved for future support.
          enum: [post, reel, story]
        firstComment:
          type: string
          description: |
            Stored for the post but NOT published yet — Meta has not granted
            the Page-comment permission, so the saved text is held until it
            lands (Instagram and LinkedIn first comments do post).

    LinkedInPlatformOptions:
      type: object
      description: |
        LinkedIn composer settings (for `platform: linkedin` and
        `platform: linkedinCompany`).
      additionalProperties: false
      required: [postAs, targetAudience, firstComment, collaborators, format]
      properties:
        collaborators:
          $ref: "#/components/schemas/ManualCollaboratorsField"
        format:
          type: string
          enum: [post, newsletter]
          description: "`newsletter` = a newsletter edition, always published on LinkedIn by a person."
        postAs:
          type: string
          enum: [personal, company]
        targetAudience:
          type: string
          description: |
            Free-form target-audience note. Stored for the post but NOT applied
            at publish — LinkedIn audience targeting is not wired, and the
            composer shows the field disabled ("Coming soon").
        firstComment:
          type: string
          description: Follow-up comment posted after publish, or empty.

    ManualCollaboratorsField:
      type: string
      maxLength: 700
      description: |
        "Collab with" — up to 5 names or handles, separated by commas or line
        breaks (on LinkedIn also profile / Page URLs). The network's API
        cannot invite collaborators, so a non-empty value makes the leg a
        MANUAL hand-off: at its posting time the team is reminded to publish it
        and invite these people inside the network (YouTube: YouTube Studio →
        Collaborations, on a long-form video or a Short). `""` = none.

    AudioNoteField:
      type: string
      maxLength: 200
      description: |
        "Audio to add in the app" — a trending sound only the network's own
        app can attach (Instagram any format, TikTok, Facebook Reels, YouTube
        Shorts; ignored elsewhere). A non-empty value makes the leg a MANUAL
        hand-off whose reminder names the track. `""` = none.

    InstagramTrialReel:
      type: object
      additionalProperties: false
      required: [enabled, graduation]
      properties:
        enabled:
          type: boolean
        graduation:
          type: string
          enum: [manual, performance]
          description: |
            How the trial reaches followers: `manual` (the team shares it from
            Instagram) or `performance` (Instagram shares it automatically if
            it performs well).

    TikTokPlatformOptions:
      type: object
      description: TikTok composer settings (the `tiktok` network).
      additionalProperties: false
      required: [postMode, privacyLevel, allowComments, allowDuet, allowStitch, commercialContent, yourBrand, brandedContent, collaborators, audioNote, coverTimestampMs]
      properties:
        collaborators:
          $ref: "#/components/schemas/ManualCollaboratorsField"
        audioNote:
          $ref: "#/components/schemas/AudioNoteField"
        postMode:
          type: string
          enum: [directPost, draft]
          description: >-
            `directPost` publishes straight to the creator's profile; `draft`
            sends the video to the creator's TikTok inbox to finish and post
            inside TikTok (privacy and interaction settings are then chosen
            there, so the fields below reflect composer state but are not
            applied at publish).
        privacyLevel:
          type:
            - string
            - "null"
          enum: [PUBLIC_TO_EVERYONE, MUTUAL_FOLLOW_FRIENDS, FOLLOWER_OF_CREATOR, SELF_ONLY, null]
          description: "`null` = not selected yet (publish clamps to a safe level)."
        allowComments:
          type: boolean
        allowDuet:
          type: boolean
        allowStitch:
          type: boolean
        commercialContent:
          type: boolean
        yourBrand:
          type: boolean
        brandedContent:
          type: boolean
        coverTimestampMs:
          type:
            - integer
            - "null"
          minimum: 0
          description: |
            The cover TikTok publishes, as milliseconds into the video — the
            frame picked with the composer's "Pick from video", or set with
            `PATCH /posts/{taskId}` (`platformOptions.tiktok.coverTimestampMs`).
            `null` = no cover picked (TikTok uses the video's first frame).
            TikTok takes its cover as a timestamp, never an image, so a picked
            frame never appears as the post's `customThumbnail`. Added in 1.150.0.

    ThreadsPlatformOptions:
      type: object
      description: |
        Threads composer settings (the `threads` network, since 1.163.0) —
        what the post publishes with. A post saved before Threads shipped
        reads back as no tag. `replyControl` is always `everyone` (since
        1.183.0): every Threads post takes replies from everyone.
      additionalProperties: false
      required: [topicTag, replyControl]
      properties:
        topicTag:
          type: string
          description: |
            The post's one topic tag (at most 50 characters of letters,
            numbers, spaces and underscores), without the `#` (`""` = no tag).
            Threads shows it on the post and files the post under that topic.
        replyControl:
          $ref: "#/components/schemas/ThreadsReplyControl"

    ThreadsReplyControl:
      type: string
      enum: [everyone]
      description: |
        Who may reply to a Threads post — always `everyone`. Timeliner cannot
        limit who replies on Threads, so since 1.183.0 `accountsYouFollow`,
        `mentionedOnly` and `followersOnly` are no longer accepted: a `PATCH`
        sending one is a `400`, and a post that stored one before reads back
        (and publishes) as `everyone`. Sending `everyone` is accepted and
        changes nothing.

    Post:
      type: object
      description: A scheduled task, flattened into its per-network posts.
      required: [taskId, title, brandId, projectId, assigneeIds, overallStatus, statusGroup, review, networks]
      properties:
        taskId:
          type: string
          format: uuid
        title:
          type: string
        brandId:
          type:
            - string
            - "null"
          format: uuid
          description: The brand (Node) this post belongs to. `null` if unresolved.
        projectId:
          type:
            - string
            - "null"
          format: uuid
          description: The project this post's task lives in.
        assigneeIds:
          type: array
          items:
            type: string
            format: uuid
          description: |
            Team members assigned to the post's task (the `Task.editors` set) —
            answers "which editor made this post" without a per-task fetch.
            Always present; `[]` when no one is assigned. Manage via
            `PATCH /api/v1/tasks/{id}` with a full-replace `assigneeIds` body.
        overallStatus:
          type:
            - string
            - "null"
          description: |
            The post's overall (task-level) PUBLISHING status. `missed` = the
            scheduled time passed while the task was unapproved (held, not posted).
            `partial` = at least one channel published but at least one other did
            not (a manual or failed leg); the task is advanced to Posted with a
            warning. Per-channel truth is in each `networks[].status`.
          enum: [draft, pending, manual, published, failed, missed, partial, null]
        statusGroup:
          type: string
          description: |
            The deliverable's APPROVAL lifecycle stage — distinct from
            `overallStatus`. Together they answer drafted / approved / rejected /
            posted. `inRevision` = a reviewer sent the post back (rejected);
            `clientApproval` = awaiting the client; `approved` / `posted` = signed
            off. One of the Task `statusGroup` values.
        scheduledAt:
          type:
            - string
            - "null"
          format: date-time
          description: The post's scheduled publish time (a UTC instant; see workspace `timezone`).
        review:
          $ref: "#/components/schemas/PostReview"
        media:
          description: |
            Download links for the post's deliverable file (the task media). Each
            network inherits this unless its own `media` override is set. `null`
            when the task has no file. URLs are presigned and valid for 7 days.
          oneOf:
            - $ref: "#/components/schemas/MediaFile"
            - type: "null"
        customThumbnail:
          description: |
            The custom cover image the team chose for the post (a separate file
            from the deliverable), with presigned links. `null` when no custom
            cover is set — the media's own `thumbnailUrl` is then the cover. A
            cover picked in the app for one network (a TikTok frame included) is
            not a file: it is that network's `networks[].coverUrl` (since
            1.157.0), and a TikTok frame's time is also
            `networks[].platformOptions.coverTimestampMs`.
          oneOf:
            - $ref: "#/components/schemas/MediaFile"
            - type: "null"
        networks:
          type: array
          items:
            $ref: "#/components/schemas/PostNetwork"

    UpdatePostInput:
      type: object
      description: |
        Content patch for a post — caption copy, per-network composer options,
        and/or the custom cover. Provide at least one field. Captions are
        capped at 5000 characters here; a caption longer than one of the
        post's scheduled networks allows is refused with `400`
        `code: "captionOverLimit"` (see `PATCH /posts/{taskId}`).
      properties:
        caption:
          type: string
          maxLength: 5000
          description: |
            The shared caption applied to every network (`""` clears it). On a
            post scheduled to YouTube it is also the description of each
            YouTube channel without a caption of its own, so since 1.229.0 one
            YouTube would refuse there (over 5,000 bytes of UTF-8, or holding
            `<` / `>`) is a `422` `youtubeDescriptionTooLong` /
            `youtubeDescriptionInvalidChars`.
        thumbnailFileId:
          type: ["string", "null"]
          format: uuid
          description: |
            Custom cover for the post: the id of an **image file — JPEG, PNG or
            WebP — already uploaded to this post's project** (`400` otherwise).
            `null` clears it. Since 1.150.1 a file that is not one of those image
            types — the task's own video, a document, a HEIC or SVG image — is
            refused with `400` and `code: "coverNotImage"`, and the post keeps its
            previous cover (it used to be accepted and showed as a broken cover
            image). Picking a video *frame* isn't possible here — frames are
            captured in the browser composer and never reach storage — so upload
            the cover image to the project and pass its file id. TikTok's cover
            is the exception:
            its API takes a timestamp, so use
            `platformOptions.tiktok.coverTimestampMs`. Changing the cover resets
            the client's thumbnail approval (`thumbnailApprovedAt` → `null`),
            identical to an in-app change.
        platformCaptions:
          type: object
          description: |
            Per-network caption overrides, merged key-by-key into the existing
            overrides: a string sets that network's override, `null` (or `""`)
            removes it (the network falls back to the shared caption), and
            omitted networks keep their current override.
          additionalProperties: false
          properties:
            facebook: { type: ["string", "null"], maxLength: 5000 }
            instagram: { type: ["string", "null"], maxLength: 5000 }
            linkedin: { type: ["string", "null"], maxLength: 5000 }
            linkedinCompany: { type: ["string", "null"], maxLength: 5000 }
            tiktok: { type: ["string", "null"], maxLength: 5000 }
            youtube:
              type: ["string", "null"]
              maxLength: 5000
              description: |
                The video's DESCRIPTION, sent exactly as written. Since
                1.229.0 one YouTube would refuse is a `422`: over 5,000 bytes of
                UTF-8 (`youtubeDescriptionTooLong` — a Hebrew letter counts 2,
                an emoji 4) or holding `<` / `>`
                (`youtubeDescriptionInvalidChars`).
            threads: { type: ["string", "null"], maxLength: 5000 }
            x: { type: ["string", "null"], maxLength: 5000 }
        platformOptions:
          type: object
          additionalProperties: false
          description: |
            Per-network composer options patch, deep-merged per platform —
            unpatched fields (thumbnails, covers, A/B state — not writable via
            the API) and sibling platforms survive. Writable: `youtube`,
            `instagram`, `facebook`, `linkedin` (shared by `linkedinCompany`
            legs — one LinkedIn card), `tiktok`, `threads` (since 1.163.0).
          properties:
            youtube:
              type: object
              additionalProperties: false
              properties:
                title:
                  type: string
                  maxLength: 100
                  description: |
                    YouTube video title — up to 100 characters as YouTube
                    counts them (an emoji is one), sent exactly as written.
                    Since 1.229.0 a title holding `<` or `>` is a `422`
                    `youtubeTitleInvalidChars`. `""` clears it — publish falls
                    back to the caption's first line, then the task name.
                tags:
                  description: |
                    YouTube tags — an array of tag strings or one
                    comma-separated string. Every tag is sent; since 1.229.0 a
                    list over YouTube's 500 characters as YouTube counts them
                    (each tag, one per comma between tags, 2 more for a tag
                    holding a space) is a `422` `youtubeTagsTooLong` — never
                    trimmed to fit.
                  oneOf:
                    - type: array
                      items: { type: string }
                    - type: string
                visibility:
                  type: string
                  enum: [public, unlisted, private]
                isShorts:
                  type: boolean
                  description: |
                    Publish as a YouTube Short. Only square/vertical video up
                    to 3 minutes actually qualifies — YouTube itself
                    classifies from the video. It sets the post's `/shorts/`
                    link and Short thumbnail shape; since 1.229.0 nothing is
                    added to the description (no `#Shorts` hint).
                madeForKids:
                  type:
                    - boolean
                    - "null"
                  description: |
                    YouTube's "made for kids" audience (COPPA), declared on the
                    upload as given: `true` = made for kids, `false` = not made
                    for kids. `null` means "not answered" — Timeliner never
                    assumes the answer. Any other value is rejected with 400.
                    Ask the person; the in-app composer requires an answer
                    before it schedules a YouTube post. Since 1.232.0 a post
                    with no answer can't be scheduled to YouTube
                    (`POST /posts/{taskId}/schedule` answers `422`
                    `youtube_made_for_kids_required`), `null` on a post already
                    queued to YouTube is the same `422`, and a YouTube post that
                    reaches its posting time with no answer (one queued before
                    1.232.0) fails without being sent to YouTube.
                collaborators:
                  $ref: "#/components/schemas/ManualCollaboratorsField"
                audioNote:
                  $ref: "#/components/schemas/AudioNoteField"
            instagram:
              type: object
              additionalProperties: false
              properties:
                format:
                  type: string
                  enum: [feed, reel, story]
                collaborator:
                  type: string
                  maxLength: 100
                  description: |
                    Up to 3 Instagram handles, separated by commas or spaces,
                    with an optional leading `@` (`""` clears). Validated on
                    write: a malformed handle or a 4th one is rejected with
                    400. Sent on the media container at publish, so each
                    account really receives Instagram's invite — except on a
                    Story, which takes no collaborators.
                firstComment:
                  type: string
                  maxLength: 2200
                  description: Comment auto-posted right after publish (`""` clears).
                audioNote:
                  $ref: "#/components/schemas/AudioNoteField"
                trialReel:
                  type: object
                  additionalProperties: false
                  required: [enabled]
                  description: |
                    Trial reel — Reels only (sent beside a non-reel `format` it
                    is a `400`), never a carousel (turned on for a post that
                    publishes to Instagram as a carousel it is a `400`,
                    `code: "trialReelCarousel"`). Accepted by default since 1.131.1; refused
                    with `422` "Trial reels aren't available yet" only where
                    the deployment switched Instagram trial reels off.
                    `graduation` defaults to `manual`.
                  properties:
                    enabled: { type: boolean }
                    graduation:
                      type: string
                      enum: [manual, performance]
            facebook:
              type: object
              additionalProperties: false
              properties:
                format:
                  type: string
                  enum: [post]
                  description: |
                    Only `post` (feed) publishes today — `reel`/`story` are
                    rejected until their publishing legs are wired.
                firstComment:
                  type: string
                  maxLength: 2200
                  description: |
                    Accepted and stored, but NOT posted at publish yet — Meta
                    has not granted the Page-comment permission (`""` clears).
                collaborators:
                  $ref: "#/components/schemas/ManualCollaboratorsField"
                audioNote:
                  $ref: "#/components/schemas/AudioNoteField"
            linkedin:
              type: object
              additionalProperties: false
              description: |
                Shared by personal (`linkedin`) and Company Page
                (`linkedinCompany`) legs — `postAs` picks the author.
              properties:
                postAs:
                  type: string
                  enum: [personal, company]
                targetAudience:
                  type: string
                  maxLength: 100
                  description: |
                    Accepted and stored, but NOT applied at publish yet —
                    LinkedIn audience targeting is not wired (`""` clears). The
                    composer field is disabled ("Coming soon") for the same
                    reason.
                firstComment:
                  type: string
                  maxLength: 2200
                collaborators:
                  $ref: "#/components/schemas/ManualCollaboratorsField"
                format:
                  type: string
                  enum: [post, newsletter]
                  description: "`newsletter` = a newsletter edition — always published on LinkedIn by a person."
            tiktok:
              type: object
              additionalProperties: false
              description: |
                Commercial-content legality combos (commercialContent requires
                yourBrand and/or brandedContent) are clamped at publish against
                the creator's live options — same as a composer save. A
                fallback audience is always the narrowest one the account
                allows. brandedContent can't pair with SELF_ONLY privacy: the
                write is accepted, but the app's composer will not schedule
                that pair, and a Direct Post that carries it is refused at
                publish (the post fails with a reason and nothing is sent to
                TikTok) — it is never swapped for a wider audience (1.124.0).
              properties:
                postMode:
                  type: string
                  enum: [directPost, draft]
                  description: >-
                    `directPost` publishes straight to the creator's profile;
                    `draft` sends the video to the creator's TikTok inbox to
                    finish and post inside TikTok.
                privacyLevel:
                  type:
                    - string
                    - "null"
                  enum: [PUBLIC_TO_EVERYONE, MUTUAL_FOLLOW_FRIENDS, FOLLOWER_OF_CREATOR, SELF_ONLY, null]
                  description: "`null` = unselected (publish clamps to a safe level)."
                allowComments: { type: boolean }
                allowDuet: { type: boolean }
                allowStitch: { type: boolean }
                commercialContent: { type: boolean }
                yourBrand: { type: boolean }
                brandedContent: { type: boolean }
                collaborators:
                  $ref: "#/components/schemas/ManualCollaboratorsField"
                audioNote:
                  $ref: "#/components/schemas/AudioNoteField"
                coverTimestampMs:
                  type: ["integer", "null"]
                  minimum: 0
                  description: |
                    TikTok cover position, in **milliseconds** into the video
                    (e.g. `2500` = the 2.5s frame). TikTok's API takes a
                    timestamp rather than an image, so this is the one cover
                    settable without a browser. `null` clears it (TikTok picks
                    its own frame). Changing the value also discards the cover
                    image previously picked in the composer (it showed a
                    different frame); the composer re-captures the frame at the
                    new timestamp the next time the post is opened.
            threads:
              type: object
              additionalProperties: false
              description: |
                Threads settings (since 1.163.0). Set at least one field; the
                other keeps its stored value.
              properties:
                topicTag:
                  type: string
                  description: |
                    One topic tag. Surrounding spaces and one leading `#` are
                    dropped before it is stored, so `"#Video Production"` is
                    saved and published as `Video Production`; `""` clears it
                    (the post goes out untagged). After that the tag may be at
                    most 50 characters and may hold only letters, numbers,
                    spaces and underscores (since 1.177.0 — before, only a
                    period `.` and an ampersand `&` were refused; Threads also
                    refused other symbols at publish) — or the request is a
                    `400` naming the first character it cannot take, and
                    nothing is written.
                replyControl:
                  $ref: "#/components/schemas/ThreadsReplyControl"

    PostCaption:
      type: object
      description: The post's content state after a write.
      required: [taskId, title, caption, platformCaptions, platformOptions, thumbnailFileId, captionApprovedAt, thumbnailApprovedAt, overallStatus, scheduledAt]
      properties:
        taskId:
          type: string
          format: uuid
        title:
          type: string
        caption:
          type: string
          description: The shared caption as stored.
        platformCaptions:
          type: object
          description: The full per-network override map after the merge.
          additionalProperties:
            type: string
        platformOptions:
          type:
            - object
            - "null"
          description: |
            The stored per-network composer options blob after the merge
            (partial — only networks that carry options). `null` when the
            draft has none.
          additionalProperties: true
        thumbnailFileId:
          type: ["string", "null"]
          format: uuid
          description: The post's custom cover (File id) after the write; `null` when it has none.
        captionApprovedAt:
          type:
            - string
            - "null"
          format: date-time
          description: |
            The client's caption approval after the write — `null` when not
            approved. A caption text change resets a prior approval to `null`
            (the client re-reviews), identical to an in-app edit.
        thumbnailApprovedAt:
          type:
            - string
            - "null"
          format: date-time
          description: |
            The client's thumbnail approval after the write — `null` when not
            approved. A cover change resets a prior approval to `null`
            (the client re-reviews), identical to an in-app change.
        overallStatus:
          type:
            - string
            - "null"
          enum: [draft, pending, manual, published, failed, missed, partial, null]
          description: |
            The post's overall scheduling status. `null` = the task has no
            calendar slot yet — the caption pre-fills the composer. `partial` =
            at least one channel published but at least one other did not.
        scheduledAt:
          type:
            - string
            - "null"
          format: date-time
          description: The post's scheduled publish time, if planned.

    PostNetworkMetrics:
      type: object
      description: One published network's latest metrics snapshot (v1.102.0).
      required:
        - views
        - reach
        - impressions
        - likes
        - comments
        - shares
        - saves
        - engagementRate
        - totalWatchTimeSeconds
        - avgWatchTimeSeconds
        - avgViewPercentage
        - capturedAt
      properties:
        views:
          type: [integer, "null"]
          description: Cross-platform view count (`videoViews ?? impressions`).
        reach: { type: [integer, "null"] }
        impressions: { type: [integer, "null"] }
        likes: { type: [integer, "null"] }
        comments: { type: [integer, "null"] }
        shares: { type: [integer, "null"] }
        saves: { type: [integer, "null"] }
        engagementRate:
          type: [number, "null"]
          description: (likes + comments) / views; `null` without a positive view count.
        totalWatchTimeSeconds: { type: [number, "null"] }
        avgWatchTimeSeconds: { type: [number, "null"] }
        avgViewPercentage: { type: [number, "null"] }
        capturedAt: { type: string, format: date-time }

    ContentInsightMetrics:
      type: object
      required:
        - views
        - likes
        - comments
        - shares
        - saves
        - reach
        - impressions
        - totalWatchTimeSeconds
        - avgWatchTimeSeconds
        - avgViewPercentage
        - capturedAt
      properties:
        views: { type: [integer, "null"] }
        likes: { type: [integer, "null"] }
        comments: { type: [integer, "null"] }
        shares: { type: [integer, "null"] }
        saves: { type: [integer, "null"] }
        reach: { type: [integer, "null"] }
        impressions: { type: [integer, "null"] }
        totalWatchTimeSeconds: { type: [number, "null"] }
        avgWatchTimeSeconds: { type: [number, "null"] }
        avgViewPercentage: { type: [number, "null"] }
        capturedAt: { type: string, format: date-time }

    ContentInsightPost:
      type: object
      description: One ranked published post (a winner or a loser).
      required:
        - source
        - taskId
        - platform
        - accountHandle
        - permalink
        - publishedAt
        - format
        - durationSeconds
        - hook
        - captionExcerpt
        - transcriptExcerpt
        - metrics
        - engagementRate
        - relativeToMedian
      properties:
        source:
          type: string
          enum: [timeliner, external]
          description: |
            `external` (v1.103.0) = a post published outside Timeliner and
            imported from the connected account — no task and no transcript
            (its hook is the caption).
        taskId:
          type: [string, "null"]
          format: uuid
          description: The task behind the post; `null` for `external` posts.
        platform:
          $ref: "#/components/schemas/SocialPlatform"
        accountHandle: { type: [string, "null"] }
        permalink: { type: [string, "null"] }
        publishedAt: { type: [string, "null"], format: date-time }
        format:
          type: [string, "null"]
          enum: [video, short, image, carousel, story, text, null]
        durationSeconds: { type: [number, "null"] }
        hook:
          type: string
          description: |
            What the viewer met first — the transcript's first 8 seconds when a
            transcript exists, else the caption's first line (≤ 140 chars).
        captionExcerpt: { type: string, description: The caption, trimmed to 140 characters. }
        transcriptExcerpt:
          type: [string, "null"]
          description: The transcript, trimmed to 600 characters; `null` without one.
        metrics:
          oneOf:
            - $ref: "#/components/schemas/ContentInsightMetrics"
            - type: "null"
        engagementRate: { type: number, description: (likes + comments) / views. }
        relativeToMedian:
          type: number
          description: engagementRate ÷ the platform's median rate (1.8 = 80% above typical).

    ContentPattern:
      type: object
      description: |
        One deterministic finding. Comparison kinds (hookLength,
        questionHook, duration, format, captionLength) carry `winnerShare` /
        `loserShare` — the fraction of winners / losers in `bucket` (the
        winners' most common value). Timing kinds (weekday 0=Mon…6=Sun, hour
        0–23) carry `lift` — that slot's median relative rate ÷ the overall
        median. Buckets: hookLength short|medium|long (≤8 / 9–15 / 16+ words),
        questionHook question|statement, duration
        under15|15to30|30to60|60to180|over180 seconds, captionLength
        short|medium|long (<100 / 100–300 / >300 chars).
      required: [kind, bucket, winnerShare, loserShare, lift, sampleSize, lowConfidence]
      properties:
        kind:
          type: string
          enum: [hookLength, questionHook, duration, format, captionLength, weekday, hour]
        bucket: { type: string }
        winnerShare: { type: [number, "null"] }
        loserShare: { type: [number, "null"] }
        lift: { type: [number, "null"] }
        sampleSize: { type: integer }
        lowConfidence: { type: boolean, description: True when sampleSize < 8. }

    ContentInsights:
      type: object
      description: The "What worked" bundle (v1.102.0).
      required: [window, postCount, hasEverPublished, excludedPlatforms, winners, losers, patterns]
      properties:
        window:
          type: object
          required: [from, to]
          properties:
            from: { type: string, format: date-time }
            to: { type: string, format: date-time }
        postCount:
          type: integer
          description: Scoreable posts in the window (0 = not enough data yet).
        hasEverPublished:
          type: boolean
          description: |
            Same rule as the social analytics bundle: `false` only when nothing
            was ever published through Timeliner and no connected account has
            imported history.
        excludedPlatforms:
          type: array
          description: |
            Networks never scored, ranked or used in a pattern here (v1.231.0,
            YouTube API Services) — always `["youtube"]`.
          items: { type: string }
        winners:
          type: array
          items: { $ref: "#/components/schemas/ContentInsightPost" }
        losers:
          type: array
          description: Worst first.
          items: { $ref: "#/components/schemas/ContentInsightPost" }
        patterns:
          type: array
          description: Findings with a positive strength, strongest first.
          items: { $ref: "#/components/schemas/ContentPattern" }

    DemographicSlice:
      type: object
      description: One slice of an audience breakdown.
      required: [key, share, count]
      properties:
        key:
          type: string
          description: |
            `female` | `male` | `unknown`, an age band (`25-34`), an ISO-3166
            alpha-2 country code, or a city name.
        share: { type: number, description: Fraction 0–1 of the reported base. }
        count: { type: [integer, "null"], description: Raw count when the network gives one. }

    SocialAccountDailyPoint:
      type: object
      description: One connected account, one UTC day. Unreported metrics are `null`, never 0.
      required:
        - day
        - socialAccountId
        - platform
        - followers
        - followersGained
        - followersLost
        - views
        - reach
        - impressions
        - engagement
        - likes
        - comments
        - shares
        - saves
        - profileVisits
        - websiteClicks
        - watchMinutes
        - postsPublished
      properties:
        day: { type: string, format: date }
        socialAccountId: { type: string, format: uuid }
        platform:
          $ref: "#/components/schemas/SocialPlatform"
        followers:
          type: [integer, "null"]
          description: Audience at end of day (YouTube subscribers, reconstructed backwards).
        followersGained: { type: [integer, "null"] }
        followersLost: { type: [integer, "null"] }
        views: { type: [number, "null"] }
        reach: { type: [number, "null"] }
        impressions: { type: [number, "null"] }
        engagement: { type: [number, "null"] }
        likes: { type: [number, "null"] }
        comments: { type: [number, "null"] }
        shares: { type: [number, "null"] }
        saves: { type: [number, "null"] }
        profileVisits: { type: [number, "null"] }
        websiteClicks: { type: [number, "null"] }
        watchMinutes: { type: [number, "null"] }
        postsPublished:
          type: integer
          description: Posts that went live that day — Timeliner + imported.

    SocialAccountDemographics:
      type: object
      description: Latest audience breakdown for one account (not window-scoped).
      required: [socialAccountId, platform, basis, capturedAt, gender, age, country, city]
      properties:
        socialAccountId: { type: string, format: uuid }
        platform:
          $ref: "#/components/schemas/SocialPlatform"
        basis:
          type: string
          enum: [followers, viewers]
        capturedAt: { type: string, format: date-time }
        gender:
          type: array
          items: { $ref: "#/components/schemas/DemographicSlice" }
        age:
          type: array
          items: { $ref: "#/components/schemas/DemographicSlice" }
        country:
          type: array
          items: { $ref: "#/components/schemas/DemographicSlice" }
        city:
          type: array
          items: { $ref: "#/components/schemas/DemographicSlice" }

    SocialImportStatus:
      type: object
      description: Where a connected account stands on importing its past posts and history.
      required:
        - socialAccountId
        - platform
        - state
        - importedPosts
        - oldestImportedAt
        - historyFrom
        - lastRunAt
        - lastError
        - unsupportedReason
      properties:
        socialAccountId: { type: string, format: uuid }
        platform:
          $ref: "#/components/schemas/SocialPlatform"
        state:
          type: string
          enum: [idle, queued, running, done, error, unsupported]
        importedPosts: { type: integer, description: Posts imported from outside Timeliner so far. }
        oldestImportedAt: { type: [string, "null"], format: date-time }
        historyFrom: { type: [string, "null"], format: date }
        lastRunAt: { type: [string, "null"], format: date-time }
        lastError: { type: [string, "null"] }
        unsupportedReason:
          type: [string, "null"]
          enum: [tiktokApproval, linkedinApproval, reconnectRequired, notSupported, null]
          description: |
            Set only when `state` is `unsupported` (`null` otherwise).
            `tiktokApproval` — TikTok analytics is not available on Timeliner
            yet, so no TikTok account can import; `linkedinApproval` —
            LinkedIn has not approved the access this account's history
            needs; `reconnectRequired` — the account must be reconnected
            first (its connection expired or its grant lacks the scope the
            import reads; since v1.162.0 also a TikTok account whose grant
            lacks `video.list`, once TikTok analytics is available);
            `notSupported` — Timeliner has no importer for that network's past
            posts yet (Threads, since 1.163.0).

    SocialHistory:
      type: object
      description: The social history bundle (v1.103.0).
      required: [period, accounts, daily, demographics, importStatus]
      properties:
        period:
          type: object
          description: The analyzed window and its comparison window (ISO instants).
          additionalProperties: true
        accounts:
          type: array
          description: Connected accounts in scope (same rows as `SocialAnalytics.connectedAccounts`).
          items: { type: object, additionalProperties: true }
        daily:
          type: array
          description: Sorted by day, then account.
          items: { $ref: "#/components/schemas/SocialAccountDailyPoint" }
        demographics:
          type: array
          items: { $ref: "#/components/schemas/SocialAccountDemographics" }
        importStatus:
          type: array
          items: { $ref: "#/components/schemas/SocialImportStatus" }

    PlatformGuidanceItem:
      type: object
      required:
        - id
        - platform
        - topic
        - title
        - summary
        - sourceUrl
        - sourceTitle
        - publishedAt
        - fetchedAt
      properties:
        id: { type: string }
        platform:
          type: string
          enum: [instagram, facebook, tiktok, youtube, linkedin, x, threads, general]
        topic: { type: string }
        title: { type: string }
        summary: { type: string }
        sourceUrl:
          type: string
          description: The official platform page this item restates.
        sourceTitle: { type: [string, "null"] }
        publishedAt:
          type: [string, "null"]
          description: The source's own date (YYYY-MM-DD) when it states one.
        fetchedAt:
          type: string
          format: date-time
          description: When Timeliner read the source (the "as of" date).

    PlatformGuidanceList:
      type: object
      required: [items, source]
      properties:
        items:
          type: array
          items: { $ref: "#/components/schemas/PlatformGuidanceItem" }
        source:
          type: string
          enum: [live, seed]
          description: "`seed` = the built-in verified set (no weekly collection yet)."

    WorkspaceGuidanceAccount:
      type: object
      required: [id, platform, handle, displayName, brandId, brandName, status, busiest24h]
      properties:
        id: { type: string, format: uuid }
        platform:
          type: string
          description: The account's own network (`linkedinCompany` stays distinct from `linkedin`).
        handle: { type: [string, "null"] }
        displayName: { type: [string, "null"] }
        brandId: { type: string, format: uuid }
        brandName: { type: [string, "null"] }
        status:
          type: string
          enum: [connected, expired, revoked]
          description: "`expired` / `revoked` = the account must be reconnected."
        busiest24h:
          type: [integer, "null"]
          description: |
            On a `postingLimits` item: the most upcoming posts this account
            has in any 24 hours, to compare with the stated cap. `null` on
            every other item.

    WorkspaceGuidancePost:
      type: object
      required: [taskId, title, platform, accountHandle, status, scheduledAt, publishedAt]
      properties:
        taskId: { type: string, format: uuid }
        title: { type: string }
        platform: { type: string }
        accountHandle: { type: [string, "null"] }
        status:
          type: string
          enum: [pending, publishing, manual, published]
          description: "`pending` / `publishing` / `manual` = upcoming; `published` = in the last 30 days."
        scheduledAt: { type: [string, "null"], format: date-time }
        publishedAt: { type: [string, "null"], format: date-time }

    WorkspaceGuidanceItem:
      allOf:
        - $ref: "#/components/schemas/PlatformGuidanceItem"
        - type: object
          required: [affects]
          properties:
            affects:
              type: object
              required: [accounts, posts, postCount]
              description: What this item means for the workspace.
              properties:
                accounts:
                  type: array
                  description: The workspace's accounts on this item's network (every connected network for a `general` item).
                  items: { $ref: "#/components/schemas/WorkspaceGuidanceAccount" }
                posts:
                  type: array
                  description: |
                    Upcoming (soonest first) then last-30-days published posts
                    it touches, at most 5 — a `trialReels` item only Instagram
                    trial reels, a `collaborators` / `audio` item only posts
                    that name a collaborator / an in-app audio track.
                  items: { $ref: "#/components/schemas/WorkspaceGuidancePost" }
                postCount:
                  type: integer
                  minimum: 0
                  description: Every post it touches (`posts` lists the first 5).

    WorkspacePlatformGuidanceList:
      type: object
      required:
        - scope
        - connectedPlatforms
        - items
        - accountsNeedingAttention
        - developerNoticesOmitted
        - otherNetworkItemsOmitted
        - source
        - note
      properties:
        scope:
          type: string
          enum: [workspace]
        connectedPlatforms:
          type: array
          description: Guidance platforms the workspace has a connected (not disconnected) account on.
          items:
            type: string
            enum: [instagram, facebook, tiktok, youtube, linkedin, x, threads, general]
        items:
          type: array
          items: { $ref: "#/components/schemas/WorkspaceGuidanceItem" }
        accountsNeedingAttention:
          type: array
          description: Accounts whose connection expired or was revoked — the one thing the user must act on.
          items: { $ref: "#/components/schemas/WorkspaceGuidanceAccount" }
        developerNoticesOmitted:
          type: integer
          minimum: 0
          description: Developer / API notices left out (Timeliner handles them).
        otherNetworkItemsOmitted:
          type: integer
          minimum: 0
          description: Items for networks the workspace has not connected, left out (`scope=all` returns them).
        source:
          type: string
          enum: [live, seed]
        note:
          type: [string, "null"]
          description: Plain-language note when nothing applies (no account connected, or nothing new for the connected networks).

    SocialPlatform:
      type: string
      enum:
        - facebook
        - instagram
        - linkedin
        - linkedinCompany
        - tiktok
        - youtube
        - threads
        - x
      description: |
        A social network channel slot. `linkedin` = personal profile,
        `linkedinCompany` = Company Page. `threads` (Meta's Threads, since
        1.163.0) publishes automatically through a connected account —
        text-only posts, images, videos and carousels of up to 20 items.
        Threads is in early access: it is offered per deployment, and where it
        is offered only Timeliner team accounts can connect a Threads account
        (in-app) or add a NEW `threads` leg to a post (for the API, the account
        that created the key); where it is not offered, nobody can. A post that
        already goes to Threads keeps its leg. A `threads` leg on a brand
        without a connected Threads account is a `manual` leg (`notConnected`);
        a brand's connected Threads account publishes automatically.

        `x` (X, formerly Twitter, since 1.210.0) publishes automatically
        through a connected X account — a text post of up to 280 characters
        as X counts them (a link counts as 23, an emoji or CJK character as
        2), with up to 4 photos or 1 video, never both. X has no
        `platformOptions`. X bills every read, so Timeliner never reads X on
        its own: an X account's numbers (follower count, and each X post's
        impressions, likes, replies, reposts and quotes) come in only when an
        admin or supervisor presses that account's Sync in Analytics →
        Social, which is charged in AI credits. Since 1.225.0 the social
        analytics reads list X accounts and accept `x` in `platforms`; an X
        account nobody has synced reports no numbers. An `x` leg on a brand
        without a connected X account is a `manual` leg (`notConnected`).

    SchedulePostInput:
      type: object
      required: [scheduledAt, platforms]
      properties:
        scheduledAt:
          type: string
          format: date-time
          description: |
            The instant the post should go out (UTC or offset). Must be in
            the future for non-drafts — the publish engine picks up past-due
            queued posts on its next tick.
        platforms:
          type: array
          minItems: 1
          description: Target networks — a FULL REPLACE of the post's platform set.
          items:
            $ref: "#/components/schemas/SocialPlatform"
        draft:
          type: boolean
          default: false
          description: |
            `true` places the post on the calendar as a draft — visible to
            the team, never auto-published.

    ApprovalGate:
      type: object
      description: |
        Whether the scheduled post will actually auto-publish at its slot, as
        things stand. Assistants must relay `warning` to the user when
        present.
      required: [requireApprovalBeforePosting, taskStatus, scheduledStatus, requiredStatus, willAutoPublish, warning]
      properties:
        requireApprovalBeforePosting:
          type: boolean
          description: The workspace's "only post approved videos" pref (default on).
        taskStatus:
          type: string
          description: The task's approval-pipeline status (`statusGroup`) after the write.
        scheduledStatus:
          type: string
          enum: [pending, manual, draft]
          description: |
            The committed scheduling rollup this write produced. `manual` when no
            selected channel has a connected account, OR (1.102.0) when the team
            turned on "I'll post this myself" for this post in the app — a
            manual-by-choice post is never auto-published, even with a connected
            account, and this endpoint cannot turn that switch off.
        requiredStatus:
          type: string
          enum: [approved]
          description: The status the task must reach for the post to auto-publish.
        willAutoPublish:
          type: boolean
          description: |
            `true` = the publish engine WILL post this at the slot. `false` =
            it won't (draft, manual — including the team's "I'll post this
            myself" choice — or held by the approval gate; see `warning`).
        warning:
          type:
            - string
            - "null"
          description: |
            Human-readable heads-up when the post will NOT auto-publish
            (approval gate, manual-only channels, or draft). `null` when it
            will.

    SchedulePostResult:
      type: object
      required: [post, approvalGate, channels]
      properties:
        post:
          type: object
          required: [taskId, title, scheduledAt, platforms, overallStatus, statusGroup]
          properties:
            taskId: { type: string, format: uuid }
            title: { type: string }
            scheduledAt: { type: string, format: date-time }
            platforms:
              type: array
              items:
                $ref: "#/components/schemas/SocialPlatform"
            overallStatus:
              type: string
              enum: [draft, pending, manual]
              description: The post's scheduling rollup after the write.
            statusGroup:
              type: string
              description: The task's approval-pipeline status.
        approvalGate:
          $ref: "#/components/schemas/ApprovalGate"
        channels:
          type: array
          description: Per-platform connected-vs-manual breakdown of the scheduled set.
          items:
            type: object
            required: [platform, mode, account]
            properties:
              platform:
                $ref: "#/components/schemas/SocialPlatform"
              mode:
                type: string
                enum: [auto, manual]
              reason:
                type: string
                enum: [notConnected, notSupported]
                description: Present only for manual legs.
              account:
                description: The connected account an auto leg publishes through.
                oneOf:
                  - $ref: "#/components/schemas/SocialAccount"
                  - type: "null"

    SocialAnalytics:
      type: object
      description: |
        The social-performance bundle (the in-app Analytics → Social data).
        Sub-objects are documented by their property names; every metrics
        carrier obeys the honesty contract — `metricsAvailable: false` pairs
        with `metrics: null` (numbers never fabricated).
      required: [period, connectedAccounts, hasEverPublished, kpis, trend, channels, accountInsights, byEditor, posts, topPosts, heatmap, contentMix, funnel, planned, followerTrend, pooledExcludes, youtube]
      properties:
        period:
          type: object
          description: The analyzed window and its comparison window (ISO instants).
          additionalProperties: true
        connectedAccounts:
          type: array
          description: |
            Accounts in scope (platform, handle, status, brand). Every row
            carries `needsInsightsReconnect` (v1.67.0) — `true` when a
            connected account's token predates or lacks its platform's
            insights scope (YouTube `yt-analytics.readonly`; Facebook
            `read_insights`; Instagram `instagram_manage_insights` /
            `instagram_business_manage_insights` by connect kind, including
            legacy rows whose granted scopes were never recorded; TikTok
            `user.info.stats` and `video.list`, both required (v1.162.0) —
            only once TikTok analytics is available on Timeliner: until then
            every TikTok row reads `false`, because a reconnect would collect
            nothing yet) — so analytics need a one-click reconnect. A row
            whose connection expired or was revoked reads `false`: its
            `status` already says it must reconnect. `needsYouTubeReconnect`
            remains (YouTube-only, deprecated in favor of the generic flag;
            on YouTube rows the two are equal).
          items: { type: object, additionalProperties: true }
        hasEverPublished:
          type: boolean
          description: |
            `false` = nothing was ever published through Timeliner and no
            connected account has imported history — treat the whole bundle as
            an empty state. A workspace whose accounts hold only imported posts
            reads `true`.
        kpis:
          type: object
          description: |
            views / engagement / likes / comments / postsPublished with
            previous-window counterparts, `engagementRate` =
            `(likes + comments) / views` (null without positive views — never
            0), and follower deltas (nullable — never zero-filled). Legacy
            `reach` / `impressions` sums remain for Meta-only analysis.
            Also carries `shares` / `sharesPrev` and `saves` / `savesPrev`
            (summed over measured posts; `null` — never 0 — when no post in
            the window reported the metric), `followsGained` / `followsLost`
            (post-attributed follows: YouTube `subscribersGained` /
            `subscribersLost`, Instagram feed-media `follows`; `null` when
            unreported), and `followersDeltaSince` — an ISO instant, set when
            at least one account's audience was first tracked INSIDE the
            window so `followersDelta` is measured from that earliest baseline
            instead of the window start (`null` = the delta spans the whole
            window).
          additionalProperties: true
        trend:
          type: array
          description: Per-day, per-platform published metrics (views, engagement, postsPublished).
          items: { type: object, additionalProperties: true }
        channels:
          type: array
          description: |
            Per-account breakdown (followers, delta, posts, views, likes,
            comments, engagementRate, metricsAvailable). `followers` is the
            account's audience — SUBSCRIBERS on YouTube, followers elsewhere.
            `followersDelta` is measured from the newest snapshot at/before the
            window start; an account first tracked inside the window measures
            from its earliest in-window snapshot instead and reports that
            instant as `followersDeltaSince` (ISO; `null` = whole window).
            `followersDelta` stays `null` (never 0) until two snapshots exist.
            One real account connected to several brands is one row (v1.180.0):
            `socialAccountId` is the connection it is reported under and
            `connectionIds` lists every connection of it in the read's scope,
            disconnected ones included.
          items: { type: object, additionalProperties: true }
        accountInsights:
          type: array
          description: |
            Per-account Instagram AND (v1.67.0) Facebook account-level
            insights, window-summed: `socialAccountId`, `platform`, the IG
            metrics `profileVisits` / `follows` / `unfollows` /
            `websiteClicks`, the FB metrics `pageViews` / `mediaViews` /
            `uniqueViewers` / `postEngagements`, and `daysWithData` (days in
            the window with a captured payload). These networks report this
            data ONLY at the account level (never per post). Capability note:
            an account carries one platform's metric set — IG rows always have
            the FB fields `null` and vice versa, so `null` there means "not a
            thing on this network", not "no data yet". Each metric is nullable
            (absent on every day = `null`, never 0); the array is empty when
            no account in scope has data.
          items: { type: object, additionalProperties: true }
        byEditor:
          type: array
          description: |
            Per-editor breakdown of published legs. Each row carries the
            editor's `editorId` (member id; `null` = the unattributed bucket for
            posts whose task has no editors), `name`, `avatarUrl`,
            `postsPublished` (credited integer count), split `views` / `reach` /
            `impressions` / `engagement` / `videoViews` (each leg's metrics
            divided evenly across that leg's editors, so per-editor sums
            reconcile to the KPI totals — this includes split `likes` /
            `comments`), unsplit `viewsCredited` / `reachCredited` /
            `videoViewsCredited`, and `metricsAvailable`. Reserved system ids
            are never listed (1.136.0): a post whose task carries one is
            credited to its team members alone — the split divides by them
            only — or to the unattributed bucket when the task has no other
            assignee.
          items: { type: object, additionalProperties: true }
        posts:
          type: array
          description: |
            Post performance rows (permalink, format, metrics or null,
            engagementRate = `(likes + comments) / views`, and `editorIds` —
            the member(s) who produced the post's task, never a reserved system
            id; empty array when the task has no editors). Each row's `metrics` (when present) carries
            `views` (the cross-platform view count: `videoViews ??
            impressions`), likes / comments / shares / saves, and the YouTube
            Analytics watch fields `totalWatchTimeSeconds`,
            `avgWatchTimeSeconds`, `avgViewPercentage`, and `trafficSources`
            (`[{source, views, watchTimeSeconds}]`) — all `null` on platforms
            without a watch-time signal. YouTube `reach` / `impressions` are
            always `null` (YouTube reports no unique-reach signal; its views
            land in `views` / `videoViews`). Instagram
            Reels also populate the watch fields, and each `metrics` carries the
            Instagram rich signals `skipRate` (Reels skip rate),
            `storyNavigation`, `storyReplies`, and `storyLinkClicks` (Stories) —
            all `null` where not applicable to that media type. `metrics` also
            carries `followsGained` (YouTube `subscribersGained`, Instagram
            feed-media `follows`) and `followsLost` (YouTube
            `subscribersLost`) — `null` where the platform or media type does
            not report them; YouTube `shares` now populates from the YouTube
            Analytics API and Instagram feed posts populate `profileVisits`.
            Each row carries `socialAccountId` — the connected account the leg
            published through (`null` for a manual leg). Since v1.103.0 each
            row also carries `source` (`timeliner` | `external`),
            `externalPostId` (imported rows), `externalThumbnailUrl` (the
            network's cover URL for imported rows — may expire) and
            `durationSeconds`; `scheduledPostId` / `taskId` are `null` on
            `external` rows.
          items: { type: object, additionalProperties: true }
        postsTruncated:
          type: boolean
          description: More rows existed than the 500-row cap returned.
        topPosts:
          type: array
          description: The top posts by engagement (subset of `posts`).
          items: { type: object, additionalProperties: true }
        heatmap:
          type: object
          description: |
            Weekday × hour engagement buckets (viewer timezone). `cells` is
            sparse — only buckets with at least one measured post — each
            `{ weekday (0 = Monday … 6 = Sunday), hour (0–23), posts,
            engagementTotal, engagementAvg }`; `sampleSize` = measured posts
            feeding the map; `lowConfidence` = `true` below 20 of them. (An
            object since the bundle shipped; documented as an array before
            v1.162.0.)

            **Only posts whose engagement is known (since v1.180.2).** A
            Facebook post whose `likes` and `comments` are both `null` (Meta
            did not report them, as happens on many Page photo posts) still
            carries a `metrics.engagement` of `0` or shares only, which is not
            a measurement. Such a post is left out of the map entirely: it adds
            nothing to `sampleSize`, to any cell's `posts`, or to the totals
            and averages. A post whose engagement was measured as `0` still
            counts as a real `0`. A left-out post still appears in `posts[]`,
            unchanged. When no post in the window has a known engagement,
            `cells` is `[]` and `sampleSize` is `0`.
          required: [cells, sampleSize, lowConfidence]
          properties:
            cells:
              type: array
              items: { type: object, additionalProperties: true }
            sampleSize:
              type: integer
              description: |
                Posts feeding the map — published posts with metrics and a
                known engagement (a Facebook post with `likes` and `comments`
                both `null` is not counted).
            lowConfidence: { type: boolean }
          additionalProperties: true
        contentMix:
          type: array
          description: |
            Published-format mix (reel/carousel/image/video/short...) with
            per-format views + engagementRate.
          items: { type: object, additionalProperties: true }
        funnel:
          type: object
          description: |
            Publishing funnel counts (scheduled → approved → published →
            engaged). A combined figure (v1.231.0): every stage counts the same
            tasks — those scheduled for at least one network other than
            YouTube — and `engaged` reads only their non-YouTube posts, so a
            task bound only for YouTube is in no stage.
          additionalProperties: true
        planned:
          type: object
          description: |
            Planned-content pipeline: upcoming counts, draft / pendingApproval
            / scheduled / failed / missed, per-day upcoming buckets, the next
            post, posts-per-week, and the publishing streak. These count
            Timeliner's own scheduling and publishing records on every network
            (YouTube included — they are not a network's metrics); since
            v1.231.0 `postsPerWeek` counts the posts Timeliner published in the
            window, the same records as the streak.
          additionalProperties: true
        followerTrend:
          type: array
          description: Daily follower snapshots per account in the window (YouTube left out).
          items: { type: object, additionalProperties: true }
        pooledExcludes:
          type: array
          description: |
            Networks every combined field leaves out (v1.231.0) — always
            `["youtube"]`. Say so wherever a combined number is shown.
          items: { type: string }
        youtube:
          $ref: "#/components/schemas/SocialYouTubeSection"

    SocialYouTubeSection:
      type: object
      description: |
        YouTube, reported on its own (v1.231.0 — YouTube API Services). Every
        number belongs to ONE channel: never sum channels, never add a channel
        to another network. Derived figures are simple math on that channel's
        own data (totals, engagement rate, subscribers gained / lost).
      required: [channels, posts, postsTruncated]
      properties:
        channels:
          type: array
          description: One report per YouTube channel in scope, alphabetical by name (never ranked).
          items: { $ref: "#/components/schemas/SocialYouTubeChannel" }
        posts:
          type: array
          description: |
            YouTube post rows, newest first (same row shape as the bundle's
            `posts`; `socialAccountId` names the channel's connection). Capped
            at 500 PER CHANNEL, so one channel never crowds another out.
          items: { type: object, additionalProperties: true }
        postsTruncated:
          type: boolean
          description: Some channel had more posts than its 500-row cap returned (each channel's own `postsTruncated` says which).

    SocialYouTubeChannelTotals:
      type: object
      description: One channel's own totals over one window.
      required: [views, engagement, likes, comments, engagementRate, postsPublished]
      properties:
        views: { type: integer }
        engagement: { type: integer }
        likes: { type: integer }
        comments: { type: integer }
        engagementRate:
          type: [number, "null"]
          description: (likes + comments) / views for this channel alone; `null` without positive views.
        postsPublished: { type: integer }

    SocialYouTubeChannel:
      type: object
      description: One YouTube channel's report.
      required: [socialAccountId, connectionIds, channelId, channelUrl, handle, displayName, avatarUrl, status, nodeId, brandName, brandPictureUrl, subscribers, subscribersDelta, subscribersDeltaSince, subscribersGained, subscribersLost, current, previous, trend, metricsAvailable, postsTruncated]
      properties:
        socialAccountId: { type: string, format: uuid }
        connectionIds:
          type: array
          items: { type: string, format: uuid }
        channelId:
          type: [string, "null"]
          description: YouTube's own channel id (`UC…`).
        channelUrl:
          type: [string, "null"]
          description: The channel's page on YouTube.
        handle: { type: [string, "null"] }
        displayName: { type: [string, "null"] }
        avatarUrl: { type: [string, "null"] }
        status: { type: string }
        nodeId: { type: [string, "null"], format: uuid }
        brandName: { type: [string, "null"] }
        brandPictureUrl: { type: [string, "null"] }
        subscribers:
          type: [integer, "null"]
          description: Latest subscriber count YouTube reported.
        subscribersDelta:
          type: [integer, "null"]
          description: Subscriber change over the window from real readings only (`null` until two exist).
        subscribersDeltaSince:
          type: [string, "null"]
          format: date-time
          description: Set when tracking began inside the window.
        subscribersGained:
          type: [integer, "null"]
          description: Subscribers YouTube attributes to this channel's videos in the window.
        subscribersLost: { type: [integer, "null"] }
        current: { $ref: "#/components/schemas/SocialYouTubeChannelTotals" }
        previous: { $ref: "#/components/schemas/SocialYouTubeChannelTotals" }
        trend:
          type: array
          description: This channel's own published views / engagement per day.
          items:
            type: object
            required: [day, views, engagement, postsPublished]
            properties:
              day: { type: string }
              views: { type: integer }
              engagement: { type: integer }
              postsPublished: { type: integer }
        metricsAvailable: { type: boolean }
        postsTruncated:
          type: boolean
          description: More of THIS channel's posts existed than its 500-row cap returned.

    BrandVoice:
      type: object
      required: [brandId, instructions, platformNotes, about, audience, tone, keyMessages, neverSay, updatedAt]
      properties:
        brandId:
          type: string
          format: uuid
        instructions:
          type: string
          description: Freeform voice/style instructions (`""` = none saved).
        about:
          type: string
          description: "Brand Brain: what the brand does and sells (`\"\"` = not answered)."
        audience:
          type: string
          description: "Brand Brain: who the content is for (`\"\"` = not answered)."
        tone:
          type: string
          description: "Brand Brain: how the brand sounds (`\"\"` = not answered)."
        keyMessages:
          type: string
          description: "Brand Brain: offers, claims, taglines and exact product names to repeat (`\"\"` = not answered)."
        neverSay:
          type: array
          description: Words and phrases that must never appear in anything written for the brand.
          items:
            type: string
        platformNotes:
          type: object
          description: Per-platform style notes, keyed by platform.
          additionalProperties:
            type: string
        updatedAt:
          type:
            - string
            - "null"
          format: date-time
          description: "`null` = no profile saved yet (fields are defaults)."

    BrandVoiceInput:
      type: object
      description: |
        Provide at least one of `instructions`, `platformNotes`, `about`,
        `audience`, `tone`, `keyMessages`, `neverSay`.
      properties:
        instructions:
          type: string
          maxLength: 4000
          description: FULL REPLACEMENT of the freeform instructions (`""` clears).
        about:
          type: string
          maxLength: 1000
          description: FULL REPLACEMENT of the Brand Brain answer "what the brand does" (`""` clears).
        audience:
          type: string
          maxLength: 1000
          description: FULL REPLACEMENT of the Brand Brain answer "who the content is for" (`""` clears).
        tone:
          type: string
          maxLength: 1000
          description: FULL REPLACEMENT of the Brand Brain answer "how the brand sounds" (`""` clears).
        keyMessages:
          type: string
          maxLength: 1000
          description: FULL REPLACEMENT of the Brand Brain key messages (`""` clears).
        neverSay:
          type: array
          maxItems: 50
          description: |
            FULL REPLACEMENT of the never-say list (`[]` clears). Entries are
            trimmed and de-duplicated ignoring case.
          items:
            type: string
            maxLength: 80
        platformNotes:
          type: object
          additionalProperties: false
          description: |
            Per-platform note patch, merged key-by-key: string sets, `null`
            (or `""`) deletes, omitted platforms untouched.
          properties:
            facebook: { type: ["string", "null"], maxLength: 1000 }
            instagram: { type: ["string", "null"], maxLength: 1000 }
            linkedin: { type: ["string", "null"], maxLength: 1000 }
            linkedinCompany: { type: ["string", "null"], maxLength: 1000 }
            tiktok: { type: ["string", "null"], maxLength: 1000 }
            youtube: { type: ["string", "null"], maxLength: 1000 }
            threads: { type: ["string", "null"], maxLength: 1000 }
            x: { type: ["string", "null"], maxLength: 1000 }

    GenerateCaptionInput:
      type: object
      description: |
        Options for AI post-copy generation. Every field is optional — an empty
        (or absent) body writes the shared caption with no extra steering.
      properties:
        platform:
          type: string
          enum:
            - facebook
            - instagram
            - linkedin
            - linkedinCompany
            - tiktok
            - youtube
            - threads
            - x
          description: |
            Write a caption tuned for this one network (saved as its
            per-network override when `apply` is true). Omit for the shared
            caption used by every network. Required (as `youtube`) when `field`
            is `title` or `tags`.
        field:
          type: string
          enum: [caption, title, tags]
          default: caption
          description: |
            Which piece of the post's copy to write.

            - `caption` (default) — the post body, for any network.
            - `title` — the YouTube video title (≤ 100 characters, written for
              search and click-through rather than as a short caption).
            - `tags` — the YouTube tag list, returned comma-separated and
              de-duplicated within YouTube's ~450-character budget.

            `title` and `tags` are YouTube's own metadata fields, so both
            require `platform: "youtube"` — any other network is a `400`. With
            `apply: true` they are saved into the draft's YouTube options
            (the same place `PATCH /posts/{taskId}` writes `platformOptions`),
            not into a caption field.
        instructions:
          type: string
          maxLength: 1000
          description: |
            Optional steering for the writer: tone, angle, something to mention.

            On the in-app composer this same field carries the user's
            correction when they refine a draft, and those corrections become
            dated brand memory that later generations reuse. API-supplied
            instructions steer the single call only — they are **not** recorded
            as brand memory, so an automated integration cannot silently
            reshape a brand's voice.
        apply:
          type: boolean
          default: false
          description: |
            `true` saves the generated copy into the post draft (same write
            path and approval-reset side effect as `PATCH /posts/{taskId}`).
            `false` (default) only returns it.
        retryTranscription:
          type: boolean
          default: false
          description: |
            `true` re-runs a transcription that previously FAILED, instead of
            answering `422 {reason: "transcript_failed"}` — the same retry the
            app offers in the task's Transcript tab, made available to API
            callers who have no tab to open.

            Opt-in because a retry is a new transcription job (free since
            1.228.4 — a task's video costs no credits to transcribe): a master
            that cannot be decoded at all (most often a video with no audio
            track) would otherwise be re-transcribed on every call. Use it once
            after a `transcript_failed` answer; if the retry fails the same way,
            stop rather than looping.

            Ignored unless the video's transcript really is in the failed
            state. When the retry cannot be started the call answers `422` with
            `reason: transcripts_unavailable`.

    GeneratedCaption:
      type: object
      description: A successfully generated piece of post copy.
      required: [status, taskId, platform, field, text, caption, language, applied, captionApprovedAt]
      properties:
        status:
          type: string
          enum: [ok]
        taskId:
          type: string
          format: uuid
        platform:
          type:
            - string
            - "null"
          enum:
            - facebook
            - instagram
            - linkedin
            - linkedinCompany
            - tiktok
            - youtube
            - threads
            - x
            - null
          description: The network the copy was tuned for; `null` = the shared caption.
        field:
          type: string
          enum: [caption, title, tags]
          description: Which piece of copy was written (echoes the request's `field`).
        text:
          type: string
          description: |
            The generated copy, mechanically hardened for its field: captions are
            rulebook-sanitized and platform length-capped, titles are clamped to
            100 characters with YouTube's rejected characters stripped, and tags
            come back comma-separated, de-duplicated and inside the tag budget.
        caption:
          type: string
          deprecated: true
          description: |
            Deprecated alias for `text`, always identical to it. Present so
            clients written before this endpoint could generate titles and tags
            keep working; new integrations should read `text`.
        language:
          type:
            - string
            - "null"
          description: BCP-47 language code of the caption (follows the source material).
        applied:
          type: boolean
          description: Whether the caption was saved into the post draft.
        captionApprovedAt:
          type:
            - string
            - "null"
          format: date-time
          description: |
            The client's caption approval after an applied write (`null` when
            not approved, or when `applied` is false).

    CaptionGenerationPending:
      type: object
      description: The video's transcription is still running — retry the same call.
      required: [status, retryAfterSeconds]
      properties:
        status:
          type: string
          enum: [transcribing]
        retryAfterSeconds:
          type: integer
          description: Suggested wait before retrying the same call.

    CaptionGenerationFailed:
      type: object
      description: |
        No copy was generated — `reason` says why and whether a retry can help
        (422 = the task's material, 502 = a failed AI call, 503 = the AI
        provider is temporarily out of capacity).
      required: [status, reason, message]
      properties:
        status:
          type: string
          enum: [failed]
        reason:
          type: string
          enum: [no_speech, transcript_failed, transcripts_unavailable, no_visuals, insufficient_content, generation_failed, ai_unavailable]
          description: |
            `no_speech` = the video has no readable speech and no usable
            visuals; `transcript_failed` = an earlier transcription of this video
            failed — send `retryTranscription: true` to re-run it (the `message`
            carries the prior failure text); `transcripts_unavailable` =
            transcription can't run (workspace preference off, file too large,
            or still uploading); `no_visuals` = image post but thumbnails
            aren't ready; `insufficient_content` = the material is too thin for
            an honest caption (see `message`); `generation_failed` = the AI
            call itself failed (retry); `ai_unavailable` = the AI provider is
            temporarily out of capacity (HTTP 503 — retry later, not now).
        message:
          type: string
          description: Human-readable explanation, safe to show to the user.

    PostReview:
      type: object
      description: |
        The client's per-element sign-off on the post. Each timestamp is when
        that element was approved; `null` means it is NOT approved (pending
        review, or sent back after a team edit). All three `null` while
        `statusGroup` is `clientApproval` = the client has not reviewed yet.
      required: [captionApprovedAt, thumbnailApprovedAt, scheduleApprovedAt]
      properties:
        captionApprovedAt:
          type:
            - string
            - "null"
          format: date-time
        thumbnailApprovedAt:
          type:
            - string
            - "null"
          format: date-time
        scheduleApprovedAt:
          type:
            - string
            - "null"
          format: date-time

    MediaFile:
      type: object
      description: |
        Presigned download links for a media file. `downloadUrl` is the raw
        original. `availableHeights` are the heights the video was transcoded
        to; `variants` are the MP4 copies of those heights that already exist.
        Transcoding does not write MP4 copies — each is made on demand, so a
        fresh upload usually has `availableHeights` and an empty `variants`.
        Fetch any available height with `GET /api/v1/files/{id}/download?type=variant&height=N`
        (202 while the copy is made, then 200). All URLs expire at `expiresAt` (7 days).

        When the file's content was removed after the workspace's
        subscription ended, the object is still returned (so you can tell
        "removed" from "no deliverable", which is `media: null`) with
        `downloadUrl`, `thumbnailUrl`, `previewUrl` and `expiresAt` all `null`,
        `variants` and `availableHeights` empty and `purgedAt` set.
        Reactivating the subscription restores the content and the links only
        if the file has not yet been permanently deleted; once it has, it stays
        in this shape.
      required: [fileId, name, mimeType, size, downloadUrl, thumbnailUrl, previewUrl, expiresAt, variants, availableHeights, purgedAt]
      properties:
        fileId:
          type: string
          format: uuid
          description: Use with `GET /api/v1/files/{id}/download` to mint a fresh link if these expire.
        name:
          type: string
        mimeType:
          type: string
        size:
          type: integer
          description: Size of the raw original in bytes.
        downloadUrl:
          type:
            - string
            - "null"
          format: uri
          description: Presigned URL for the raw original upload. `null` only when `purgedAt` is set.
        thumbnailUrl:
          type:
            - string
            - "null"
          format: uri
          description: |
            Presigned URL for the file's thumbnail — a small poster frame for a
            video or a downscaled still for an image. An agent can open it to
            "see" the media. `null` when no thumbnail has been generated.
        previewUrl:
          type:
            - string
            - "null"
          format: uri
          description: |
            Presigned URL for the file's lightweight preview / proxy (used by the
            in-app player). `null` when no preview exists.
        expiresAt:
          type:
            - string
            - "null"
          format: date-time
          description: When every URL above expires. `null` only when `purgedAt` is set.
        variants:
          type: array
          description: |
            MP4 copies that already exist, ascending by height. A copy appears
            here once it has been made on demand (in the app's download menu,
            or by a `type=variant` download request); empty on a fresh upload
            and when `purgedAt` is set.
          items:
            $ref: "#/components/schemas/MediaVariant"
        availableHeights:
          type: array
          description: |
            Heights the video was transcoded to, ascending (from 480, 1080,
            2160; 480 for project and brand raw files, plus 1080 in a workspace
            on the Timeliner editing service, never above the source, and 480
            only for some raw files of 1 GB or more; a raw file transcoded on
            2026-11-13 may also list 1080).
            Each can be downloaded as an MP4
            via `GET /api/v1/files/{id}/download?type=variant&height=N`, which
            makes the copy on first request. Empty for images, for a video
            still transcoding, and when `purgedAt` is set.
          items:
            type: integer
          example: [480, 1080]
        purgedAt:
          type:
            - string
            - "null"
          format: date-time
          description: |
            When the file's content was removed after the workspace's
            subscription ended. `null` for a live file. While set, every URL in
            this object is `null` and `GET /api/v1/files/{id}/download` answers
            404 `file_content_missing`; reactivating the subscription restores
            the content only if the file has not yet been permanently deleted,
            and a deleted file stays in this shape.

    MediaVariant:
      type: object
      required: [height, size, url]
      properties:
        height:
          type: integer
          description: Variant height in pixels (e.g. 480, 1080, 2160).
        size:
          type: integer
          description: Variant size in bytes.
        url:
          type: string
          format: uri
          description: Presigned URL for this variant.

    PostPage:
      type: object
      required: [data, nextBefore, timezone]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Post"
        nextBefore:
          type:
            - string
            - "null"
          format: date-time
        timezone:
          type:
            - string
            - "null"
          description: |
            The workspace's IANA timezone (e.g. `America/New_York`). Every
            `scheduledAt` / `publishedAt` in `data` is a UTC instant — render it
            in this zone. `null` = the workspace uses browser-detected time.
          example: America/New_York

    CustomStatus:
      type: object
      required: [id, name, color, baseStatus, brandId, hiddenForBrandIds, sortOrder, editorAccess, editorIds]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          example: Legal sign-off
        color:
          type: string
          description: Palette colour token, as set in Settings → Statuses.
        baseStatus:
          type: string
          enum: [toDo, inProgress, inRevision, supervisorApproval, approved, posted]
          description: The built-in `statusGroup` this status sits after and behaves like.
        brandId:
          type:
            - string
            - "null"
          format: uuid
          description: "`null` = every brand; set = that brand (and what sits under it) only."
        hiddenForBrandIds:
          type: array
          items:
            type: string
            format: uuid
          description: Brands that switched this workspace-wide status off.
        sortOrder:
          type: number
          description: |
            **New in 1.202.0.** Its place among the custom statuses on the same
            `baseStatus` — lower first (set with `PATCH`).
        editorAccess:
          type: string
          enum: [default, all, none, selected]
          description: |
            **New in 1.202.0.** Which editors may move tasks into it in the app
            (supervisors and admins always may): `default` follows the base
            status's editor rule, `all` / `none` every / no editor, `selected`
            only those in `editorIds`.
        editorIds:
          type: array
          items:
            type: string
            format: uuid
          description: |
            **New in 1.202.0.** The saved editor list. It decides only while
            `editorAccess` is `selected`, and is kept as it was under any other
            setting.
    CustomColumn:
      type: object
      required: [id, kind, name, sortOrder, createdAt]
      properties:
        id:
          type: string
          format: uuid
        kind:
          type: string
          enum: [text, date, priority, link, dateRange, select, tag]
        name:
          type: string
        sortOrder:
          type: integer
        createdAt:
          type: string
          format: date-time
        options:
          type: array
          description: Present only for `select` columns.
          items:
            type: object
            required: [id, label, color, sortOrder]
            properties:
              id:
                type: string
                format: uuid
              label:
                type: string
              color:
                type: string
              sortOrder:
                type: integer
        tags:
          type: array
          description: |
            Present only for `tag` columns — the column's tag vocabulary.
            Tags are label-only: unlike select options they carry no colour
            and no icon. Each tag column keeps its own independent set (a
            "People" column and a "Locations" column do not share tags), and
            every tag is scoped: `brandId` null = shared across every brand;
            a brand id = usable only on tasks under that brand.
          items:
            $ref: "#/components/schemas/CustomColumnTag"
        tagScopeDefault:
          type: string
          enum: [brand, workspace]
          description: |
            Present only for `tag` columns — what a tag typed into a cell in
            the app is created as: `brand` (the default, scoped to the task's
            brand) or `workspace` (shared).

    CustomColumnTag:
      type: object
      required: [id, label, brandId, sortOrder]
      properties:
        id:
          type: string
          format: uuid
        label:
          type: string
        brandId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            The brand (client) node this tag belongs to, or `null` for a tag
            shared across every brand. A brand-scoped tag applies to every
            task whose project sits under that brand (folders, projects and
            end brands beneath it) and is visible only to people who can see
            that brand.
        sortOrder:
          type: integer

    TaskTranscript:
      type: object
      required: [taskId, fileId, status, language, text, wordCount, durationSeconds]
      properties:
        taskId:
          type: string
          format: uuid
        fileId:
          type: string
          format: uuid
          description: The media file the transcript belongs to (the task's current version).
        status:
          type: string
          enum: [none, pending, extracting, processing, ready, failed, no_speech]
          description: |
            `ready` = `text` is present. `none` = never transcribed. `pending`,
            `extracting`, `processing` = in progress. `no_speech` = the audio
            carried no readable speech. `failed` = transcription failed (retry
            from the task's Transcript tab).
        language:
          type:
            - string
            - "null"
          description: Detected (or overridden) language code, e.g. `en`; null until ready.
        text:
          type:
            - string
            - "null"
          description: The spoken words, segments joined by newlines. Only present when `status` is `ready`.
        wordCount:
          type:
            - integer
            - "null"
        durationSeconds:
          type:
            - number
            - "null"
        segments:
          type:
            - array
            - "null"
          items:
            $ref: "#/components/schemas/TranscriptSegmentTiming"
          description: |
            Only with `includeSegments=true` (since 1.206.0): the timed lines,
            in order — with no window, line *i* of `text` is `segments[i].text`.
            Narrowed by `fromSeconds` / `toSeconds`. `null` unless `status` is
            `ready`.
        words:
          type:
            - array
            - "null"
          items:
            $ref: "#/components/schemas/TranscriptWordTiming"
          description: |
            Only with `includeWords=true` (since 1.206.0): every spoken word,
            in order, with its own timing. Narrowed by `fromSeconds` /
            `toSeconds`. `null` unless `status` is `ready`.

    TranscriptSegmentTiming:
      type: object
      required: [start, end, text]
      properties:
        start:
          type: number
          description: Seconds from the start of the video when the line begins.
        end:
          type: number
          description: Seconds from the start of the video when the line ends.
        text:
          type: string
          description: The line's words, as the Transcript tab shows them.

    TranscriptWordTiming:
      type: object
      required: [text, start, end]
      properties:
        text:
          type: string
          description: The word, with any punctuation attached to it.
        start:
          type: number
          description: Seconds from the start of the video when the word begins.
        end:
          type: number
          description: Seconds from the start of the video when the word ends.

    SuggestTagsRequest:
      type: object
      required: [columnId]
      additionalProperties: false
      properties:
        columnId:
          type: string
          format: uuid
          description: "The tag column to suggest for (a column whose `kind` is `tag`)."
        instructions:
          type:
            - string
            - "null"
          maxLength: 1000
          description: What kind of tags to look for, in plain words.
        maxTags:
          type: integer
          minimum: 1
          maximum: 10
          default: 5
        allowNew:
          type: boolean
          default: true
          description: "`false` = only existing vocabulary tags may be proposed."
        apply:
          type: boolean
          default: false
          description: "`true` = create the new labels for the task's brand and write the cell."
        startTranscription:
          type: boolean
          default: false
          description: >-
            `true` = start transcribing an untranscribed video first (uses the
            workspace's credits) and answer 202.

    TagSuggestion:
      type: object
      required: [label, tagId, isNew, reason, alreadyApplied, applied]
      properties:
        label:
          type: string
        tagId:
          type:
            - string
            - "null"
          format: uuid
          description: The existing (or, after `apply`, newly created) tag id; `null` for a proposed new tag that was not applied.
        isNew:
          type: boolean
          description: The label did not exist in the brand's vocabulary (with `apply`, it was created).
        reason:
          type: string
          description: Where in the content the tag came from.
        alreadyApplied:
          type: boolean
          description: The tag was already on the cell before this call.
        applied:
          type: boolean
          description: The tag is on the cell after this call (always `false` without `apply`).

    TagSuggestions:
      type: object
      required: [status, taskId, columnId, brandId, sources, suggestions, applied]
      properties:
        status:
          type: string
          enum: [ok]
        taskId:
          type: string
          format: uuid
        columnId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
          description: The brand new tags are scoped to (`null` = the task has no brand up its chain; new tags are shared).
        sources:
          type: object
          required: [title, brief, caption, transcript]
          properties:
            title:
              type: boolean
            brief:
              type: boolean
            caption:
              type: boolean
            transcript:
              type: string
              enum: [ready, none, pending, no_speech, failed]
        suggestions:
          type: array
          items:
            $ref: "#/components/schemas/TagSuggestion"
        applied:
          type:
            - object
            - "null"
          description: "`null` without `apply`; otherwise the ids created and the cell's full tag list after the write."
          required: [createdTagIds, cellTagIds]
          properties:
            createdTagIds:
              type: array
              items:
                type: string
                format: uuid
            cellTagIds:
              type: array
              items:
                type: string
                format: uuid

    CreateCustomColumnTagsRequest:
      type: object
      required: [labels]
      additionalProperties: false
      properties:
        labels:
          type: array
          minItems: 1
          maxItems: 50
          items:
            type: string
            minLength: 1
            maxLength: 40
          description: Tag labels to add. Trimmed and de-duplicated case-insensitively.
        brandId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            The brand (client) node the tags belong to. Omit or `null` for
            SHARED tags. A folder node or a node of another workspace is a 400.

    CustomColumnTagsCreated:
      type: object
      required: [columnId, brandId, tags]
      properties:
        columnId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        tags:
          type: array
          description: One entry per label sent, in input order.
          items:
            type: object
            required: [id, label, brandId, created]
            properties:
              id:
                type: string
                format: uuid
              label:
                type: string
              brandId:
                type:
                  - string
                  - "null"
                format: uuid
              created:
                type: boolean
                description: "`true` when this call created the tag; `false` when the label already existed in that scope."

    CustomColumnValue:
      type: object
      required: [columnId, kind, name, value]
      properties:
        items:
          type: array
          description: |
            Link columns only (1.124.0) — always present on a link entry, `[]`
            when nothing is linked: the cell's linked raw files/folders, in
            order, each `{ kind, id, name }` (`name` null when the item was
            deleted). `value` stays the cell's URL.
          items:
            $ref: "#/components/schemas/LinkItem"
        columnId:
          type: string
          format: uuid
        kind:
          type: string
          enum: [text, date, priority, link, dateRange, select, tag]
        name:
          type: string
        value:
          description: |
            The cell's value, by kind: text/date/priority/link → string | null;
            dateRange → `{ start, end }` | null; select → `{ optionId, label }` | null;
            tag → an ARRAY of `{ tagId, label }` | null (tag cells are
            multi-value; an empty cell reads as `null`, never `[]`).
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
            - type: array
              items:
                type: object
                required: [tagId, label]
                properties:
                  tagId:
                    type: string
                    format: uuid
                  label:
                    type: ["string", "null"]
            - type: "null"

    LinkItem:
      type: object
      required: [kind, id, name]
      properties:
        kind:
          type: string
          enum: [projectFile, projectFolder, brandFile, brandFolder]
        id:
          type: string
          format: uuid
        name:
          type: ["string", "null"]

    RawFile:
      type: object
      required: [id, name, size, mimeType, folderId, durationSeconds, createdAt, hasTranscript, transcriptStatus]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        size:
          type: integer
          description: Bytes.
        mimeType:
          type: string
        folderId:
          type: ["string", "null"]
          format: uuid
        durationSeconds:
          type: ["number", "null"]
          description: Null for non-media files, or media whose duration is not known yet.
        createdAt:
          type: ["string", "null"]
          format: date-time
        hasTranscript:
          type: boolean
          description: A ready transcript exists (`transcriptStatus` is `ready`).
        transcriptStatus:
          type: string
          enum: [none, pending, extracting, processing, ready, no_speech, failed]

    RawFileFolder:
      type: object
      required: [id, name, parentId]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        parentId:
          type: ["string", "null"]
          format: uuid

    RawFileListResponse:
      type: object
      required: [data, nextBefore]
      properties:
        data:
          type: object
          required: [folderId, folders, files]
          properties:
            folderId:
              type: ["string", "null"]
              format: uuid
              description: The folder listed; null = the top level.
            folders:
              type: array
              description: This level's subfolders, by name — on the first page only (`[]` on later pages).
              items:
                $ref: "#/components/schemas/RawFileFolder"
            files:
              type: array
              description: Newest first.
              items:
                $ref: "#/components/schemas/RawFile"
        nextBefore:
          type: ["string", "null"]
          description: Pass as `before` for the next page; null on the last page.

    FileTranscript:
      type: object
      required: [fileId, kind, status, language, text, wordCount, durationSeconds]
      properties:
        fileId:
          type: string
          format: uuid
        kind:
          type: string
          enum: [projectFile, brandFile]
        status:
          type: string
          enum: [none, pending, extracting, processing, ready, failed, no_speech]
          description: Same meaning as `TaskTranscript.status`.
        language:
          type: ["string", "null"]
        text:
          type: ["string", "null"]
          description: The spoken words, segments joined by newlines. Only when `status` is `ready`.
        wordCount:
          type: ["integer", "null"]
        durationSeconds:
          type: ["number", "null"]
        segments:
          type: ["array", "null"]
          items:
            $ref: "#/components/schemas/TranscriptSegmentTiming"
          description: Only with `includeSegments=true` (since 1.206.0) — same as `TaskTranscript.segments`.
        words:
          type: ["array", "null"]
          items:
            $ref: "#/components/schemas/TranscriptWordTiming"
          description: Only with `includeWords=true` (since 1.206.0) — same as `TaskTranscript.words`.

    FootageSelect:
      type: object
      description: |
        **New in 1.218.0.** A footage select — a time range on one raw
        project video or audio file, the row the app's Selects panel shows.
      required: [id, fileId, startSeconds, endSeconds, title, notes, script, taskId, taskTitle, angle, createdAt, updatedAt, url]
      properties:
        id:
          type: string
          format: uuid
        fileId:
          type: string
          format: uuid
        startSeconds:
          type: number
          description: Seconds into the file.
        endSeconds:
          type: ["number", "null"]
          description: Seconds into the file; `null` for a point select ("from 0:12").
        title:
          type: string
        notes:
          type: string
        script:
          type: string
          description: The words spoken in the range.
        taskId:
          type: ["string", "null"]
          format: uuid
          description: The task the select was sent to (its Plan → Media lists it), or `null`.
        taskTitle:
          type: ["string", "null"]
        angle:
          type: string
          enum: [a, b, c, d, audio]
          description: The camera angle of the select's own file (camera angles are linked in the app).
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        url:
          type: string
          format: uri
          description: |
            The app link that opens the clip playing at this moment — the
            same link as the Selects panel's "Copy link to this moment"
            (the preferred camera when one is linked). Opens for a signed-in
            team member of the workspace.

    FootageSelectList:
      type: object
      required: [fileId, selects]
      properties:
        fileId:
          type: string
          format: uuid
        selects:
          type: array
          description: In timecode order (start, then creation). At most 1000.
          items:
            $ref: "#/components/schemas/FootageSelect"

    FootageSelectCreate:
      type: object
      additionalProperties: false
      required: [startSeconds, title]
      properties:
        startSeconds:
          type: number
          minimum: 0
        endSeconds:
          type: ["number", "null"]
          description: Later than `startSeconds`; omit or `null` for a point select.
        title:
          type: string
          minLength: 1
          maxLength: 200
        notes:
          type: string
          maxLength: 4000
        script:
          type: string
          maxLength: 20000
          description: Omit to fill it with the words the transcript has in that range (as the app does).
        taskId:
          type: ["string", "null"]
          format: uuid
          description: A live task of the file's own project — never a parent task.

    FootageSelectUpdate:
      type: object
      additionalProperties: false
      minProperties: 1
      description: Only the fields sent change. `taskId` `null` takes the select off its task.
      properties:
        startSeconds:
          type: number
          minimum: 0
        endSeconds:
          type: ["number", "null"]
        title:
          type: string
          minLength: 1
          maxLength: 200
        notes:
          type: string
          maxLength: 4000
        script:
          type: string
          maxLength: 20000
        taskId:
          type: ["string", "null"]
          format: uuid

    FileTranscriptionStart:
      type: object
      required: [fileId, kind, status, started]
      properties:
        fileId:
          type: string
          format: uuid
        kind:
          type: string
          enum: [projectFile, brandFile]
        status:
          type: string
          enum: [pending, extracting, processing, ready, failed, no_speech]
        started:
          type: boolean
          description: True when this call started a new transcription.
        retryAfterSeconds:
          type: integer
          description: On `202` — how long to wait before polling `GET`.

    TaskCustomValues:
      type: object
      required: [taskId, customValues]
      properties:
        taskId:
          type: string
          format: uuid
        customValues:
          type: array
          items:
            $ref: "#/components/schemas/CustomColumnValue"

    TaskWithCustomValues:
      allOf:
        - $ref: "#/components/schemas/Task"
        - type: object
          required: [customValues]
          properties:
            customValues:
              type: array
              items:
                $ref: "#/components/schemas/CustomColumnValue"

    PricingTemplate:
      type: object
      required: [id]
      properties:
        id: { type: string, format: uuid }
        name: { type: ["string", "null"] }
        description: { type: ["string", "null"] }
        pricingMode:
          type: ["string", "null"]
          description: flat | rules | profitShare | hourly
        defaultClientPrice: { type: ["number", "null"] }
        defaultEditorPay: { type: ["number", "null"] }
        clientPricingEnabled: { type: boolean }
        editorPayEnabled: { type: boolean }
        badgeName: { type: ["string", "null"] }
        badgeColor: { type: ["string", "null"] }

    PricingReceivables:
      type: object
      required: [from, to, totals, margins, brands, brandCharges, projects]
      properties:
        from: { type: ["string", "null"] }
        to: { type: ["string", "null"] }
        totals:
          type: object
          description: >-
            Workspace totals. Include project-level prices (see `projects`) in
            addition to per-task client prices — project prices are additive
            ("extras on top"), never derived from task prices.
          required: [approved, pending, paid, outstanding]
          properties:
            approved: { type: number }
            pending: { type: number }
            paid: { type: number }
            outstanding:
              type: number
              description: >-
                Approved client money not yet received. Work still in
                `pending` is not owed yet and contributes 0 (1.97.0).
        margins:
          type: object
          required: [netMargin, projectedMargin]
          properties:
            netMargin: { type: number }
            projectedMargin: { type: number }
        brands:
          type: array
          description: Per-brand totals (project-level prices folded in).
          items:
            type: object
            required: [brandId, billingBasis, retainerMonthly, retainerAmount, extrasAmount, approved, pending, paid, outstanding]
            properties:
              brandId: { type: string, format: uuid }
              brandName: { type: ["string", "null"] }
              billingBasis:
                type: string
                enum: [perTask, perProject, retainer]
                description: >-
                  `retainer` when the brand has a monthly retainer in effect,
                  whatever its projects do. Otherwise `perProject` only when
                  EVERY project under the brand carrying client money — a
                  project price row (whatever its amount) or billing task
                  prices — is on one fixed client price; `perTask` the moment
                  per-task prices are in play, including a project priced ONLY
                  at task level. Task rows are windowed by `from`/`to`, so a
                  brand whose per-task money all falls outside the window
                  reports on what the window shows. Before 1.95.0 the
                  all-fixed-price case read `retainer`.
              retainerMonthly:
                type: ["number", "null"]
                description: The monthly retainer in effect today; null when the brand has none.
              retainerAmount:
                type: number
                description: Retainer months owed in the window — already inside `approved`.
              extrasAmount:
                type: number
                description: One-off extra charges owed in the window — already inside `approved`.
              approved: { type: number }
              pending: { type: number }
              paid: { type: number }
              outstanding:
                type: number
                description: >-
                  Approved client money not yet received from this brand.
                  `pending` work contributes 0 (1.97.0).
        brandCharges:
          type: array
          description: >-
            Brand-level money in for the window (1.91.0): one line per
            retainer month and per one-off extra charge, already folded into
            `totals` and `brands[]`. Always owed (a month on its 1st, an
            extra on its date). Set in the app (read-only here).
          items:
            type: object
            required: [brandId, kind, chargeId, periodMonth, date, label, projectId, amount, paid, paidAmount, outstanding]
            properties:
              brandId: { type: string, format: uuid }
              kind: { type: string, enum: [retainer, extra] }
              chargeId:
                type: ["string", "null"]
                format: uuid
                description: >-
                  The stored charge — what a Payment row's `brand_charge`
                  points at. Null for a retainer month nobody has recorded
                  money against yet (derived from the retainer schedule).
              periodMonth:
                type: ["string", "null"]
                description: "`retainer` only: the month, `YYYY-MM-01`."
              date:
                type: string
                description: "`YYYY-MM-DD` the line is owed from — the month's 1st, or the extra's date."
              label:
                type: ["string", "null"]
                description: "`extra` only: what the charge was for."
              projectId:
                type: ["string", "null"]
                format: uuid
                description: "`extra` only, optional: the project the work was for."
              amount: { type: number }
              paid:
                type: boolean
                description: True once the line is fully settled (ledger money, else its paid flag).
              paidAmount:
                type: number
                description: Client money collected against the line, capped at `amount`.
              outstanding:
                type: number
                description: "`amount` − `paidAmount`; the two always sum to `amount`."
        projects:
          type: array
          description: >-
            Project-level prices (fixed prices / package deals). `status` is
            `approved` once every active task in the project is
            approved/posted/archived, else `pending`; `revenueDate` (the project's
            start date, falling back to its creation date) drives the
            `from`/`to` window and trend month. Set via the app UI
            (read-only here).
          items:
            type: object
            required: [projectId, projectName, brandId, amount, label, status, paid, paidAmount, outstanding, revenueDate]
            properties:
              projectId: { type: string, format: uuid }
              projectName: { type: string }
              brandId: { type: ["string", "null"], format: uuid }
              amount: { type: number }
              label: { type: ["string", "null"] }
              status: { type: string, enum: [approved, pending] }
              paid:
                type: boolean
                description: >-
                  True only once the project price is fully settled — derived
                  from the same ledger money `paidAmount` reports (1.85.0). A
                  project holding a deposit reads `false` with a non-zero
                  `paidAmount`; before 1.85.0 this was the raw paid flag and
                  could contradict the brand/total rollups beside it.
              paidAmount:
                type: number
                description: >-
                  Client money collected against this project price — live
                  Payment rows in the 'in' direction, capped at `amount`. A
                  project with no ledger entry falls back to its paid flag
                  (0 or `amount`).
              outstanding:
                type: number
                description: >-
                  What the client owes on this project right now. On an
                  `approved` row this is `amount` − `paidAmount`, and the two
                  sum to `amount`. A `pending` row is not owed yet, so it
                  reports 0 while its `amount` sits in `totals.pending`
                  (1.97.0). Never negative.
              revenueDate: { type: string }

    PricingPayables:
      type: object
      required: [from, to, totals, editors, salaries]
      properties:
        from: { type: ["string", "null"] }
        to: { type: ["string", "null"] }
        totals:
          type: object
          description: >-
            Per-task payables only. Members on a monthly salary are excluded
            for their salaried periods and reported under `salaries` instead.
          required: [approved, pending, paid, unpaid]
          properties:
            approved: { type: number }
            pending: { type: number }
            paid: { type: number }
            unpaid:
              type: number
              description: >-
                Approved pay not yet paid out. Pay on work still in `pending`
                is not owed yet and contributes 0 (1.135.0).
        editors:
          type: array
          items:
            type: object
            required: [editorId, approved, pending, paid, unpaid]
            properties:
              editorId: { type: string, format: uuid }
              editorName: { type: ["string", "null"] }
              payBasis:
                type: string
                enum: [perTask, perProject, salary, pod, hourly, mixed]
                description: >-
                  How this member is paid, summarized across the projects
                  they are paid in during the window — the projects they hold a
                  task in PLUS the projects whose fee money this response
                  reports for them. `salary` = a monthly MemberCompensation
                  row, decided at member level so it needs no project at all;
                  `pod` = paid through a pod's one monthly figure (1.95.0);
                  `perProject` = a ProjectMemberPay fee or a fixedProject team
                  mode; `hourly` = the project prices by the hour (an hourly
                  rate is per-project, never a member setting); `mixed` = their
                  projects disagree, so no single basis is reported. Matches
                  the label the Finance cards show.
              approved: { type: number }
              pending: { type: number }
              paid: { type: number }
              unpaid:
                type: number
                description: >-
                  Approved pay not yet paid out to this member. Their
                  `pending` pay contributes 0 (1.135.0).
        salaries:
          type: object
          description: >-
            Monthly-salary cost for the window — the "was it worth it?"
            dataset. `windowCost` prorates each salary across the overlapped
            calendar months (never accruing past today); `delivered` counts
            the member's approved/posted/archived tasks in the window (variants count,
            parent containers don't); `activeCount` counts their still-open
            tasks (in progress / revisions / awaiting approval);
            `costPerVideo` = windowCost / delivered (null when nothing was
            delivered); `attributedRevenue` is the BOOKED client revenue
            credited to the member (task prices split evenly across a task's
            editors + project-level prices allocated by delivered share
            within the project) — compare it against `windowCost` to judge
            return. Set via the app UI (read-only here). Since 1.100.1 the
            response actually emits `payModel`, `podId` and `podMembers` on
            every `byMember` row, as this schema has required since 1.91.0
            (earlier builds dropped them).
          required: [totals, byMember]
          properties:
            totals:
              type: object
              required: [windowCost]
              properties:
                windowCost: { type: number }
            byMember:
              type: array
              items:
                type: object
                required: [editorId, payModel, podId, podMembers, monthlyAmount, windowCost, delivered, activeCount, costPerVideo, attributedRevenue]
                properties:
                  editorId: { type: string, format: uuid }
                  editorName: { type: ["string", "null"] }
                  payModel:
                    type: string
                    enum: [salary, pod]
                    description: >-
                      `salary` — this member's own monthly salary. `pod` (1.91.0)
                      — this row is a pod's LEAD and carries the whole pod's
                      monthly figure; `delivered` / `activeCount` /
                      `attributedRevenue` then cover every member in
                      `podMembers`. Covered pod members get no row of their own.
                  podId: { type: ["string", "null"], format: uuid }
                  podMembers:
                    type: ["array", "null"]
                    items: { type: string, format: uuid }
                    description: Every member the pod figure covers, lead included (`payModel` = `pod` only).
                  monthlyAmount: { type: ["number", "null"] }
                  windowCost: { type: number }
                  delivered: { type: number }
                  activeCount: { type: number }
                  costPerVideo: { type: ["number", "null"] }
                  attributedRevenue: { type: ["number", "null"] }

    MemberProfitability:
      type: object
      required: [from, to, pooledExcludes, members]
      properties:
        from: { type: ["string", "null"] }
        to: { type: ["string", "null"] }
        pooledExcludes:
          type: array
          description: |
            Networks `viewsAttributed` / `engagementAttributed` leave out
            (v1.231.0, YouTube API Services) — always `["youtube"]`. Say so
            wherever those figures are shown.
          items: { type: string }
        members:
          type: array
          items:
            type: object
            required:
              [memberId, payType, totalCost, costBreakdown, paidOut, attributedRevenue, netReturn, roiRatio, roiVerdict, delivered, inProgress, costPerVideo, viewsAttributed, engagementAttributed]
            properties:
              memberId: { type: string, format: uuid }
              memberName: { type: ["string", "null"] }
              payType: { type: string, enum: [monthly, perTask, perProject, mixed] }
              totalCost:
                type: number
                description: perTask pay + fixed project fees + prorated salary for the window.
              costBreakdown:
                type: object
                required: [perTask, projectFees, salary]
                properties:
                  perTask: { type: number }
                  projectFees: { type: number }
                  salary: { type: number }
              paidOut:
                type: number
                description: >-
                  Actually paid out (per-task paid bucket + paid fees; salary
                  counts as paid). LEDGER-derived since 1.85.0 — the live
                  Payment money on each pay row / fee, so a partial payout
                  reads as partially paid. Equals the `paid` this member gets
                  on `GET /api/v1/pricing/payables` over the same window.
              attributedRevenue:
                type: number
                description: >-
                  BOOKED client revenue credited to the member — billing-mode
                  aware (client-fixed projects' task prices are excluded; the
                  project price allocates by delivered share).
              netReturn: { type: number }
              roiRatio: { type: ["number", "null"] }
              roiVerdict:
                type: ["string", "null"]
                enum: [strong, thin, underwater, null]
                description: "≥2× strong, ≥1× thin, <1× underwater; null when there is no cost."
              delivered: { type: number }
              inProgress: { type: number }
              costPerVideo: { type: ["number", "null"] }
              viewsAttributed:
                type: ["integer", "null"]
                description: >-
                  Video views on the member's published videos over the SAME
                  window, even-split across each video's editors (the identical
                  rule as `attributedRevenue`, so cost and views are
                  commensurable), on every network EXCEPT YouTube (v1.231.0 —
                  see `pooledExcludes`). `null` = this workspace has no
                  social-distribution data (no distribution plan, or the social
                  read failed) — NOT the same as `0`, which means no attributed
                  views outside YouTube (the member's videos may all have gone
                  to YouTube, which this figure never counts). The
                  member roster is money-driven and unchanged by this field: a
                  member with views but no cost/revenue/delivered is still
                  omitted.
              engagementAttributed:
                type: ["integer", "null"]
                description: >-
                  Engagement (likes + comments + shares + saves) on the member's
                  published videos over the same window, even-split per editor,
                  YouTube left out (v1.231.0). Same `null`-vs-`0` semantics as
                  `viewsAttributed`.
              projects:
                type: array
                description: >-
                  Present only with `includeProjects=true` — the per-project
                  breakdown of this member's pay: which model applies there
                  ("most specific wins": a project fee beats the member
                  default), the fee row (if any), their per-task pay buckets
                  (zeros when a fee/salary suppresses them), tagged /
                  delivered / in-progress counts, and the member-scoped days
                  span (first tagged task created → last delivery approved;
                  null while nothing is approved yet).
                items:
                  type: object
                  required: [projectId, payModel, fee, perTaskPay, taggedCount, delivered, inProgress, firstTaskAt, lastDeliveryAt, daysSpan, memberCost]
                  properties:
                    projectId: { type: string, format: uuid }
                    payModel: { type: string, enum: [salary, perProject, perTask] }
                    fee:
                      type: ["object", "null"]
                      properties:
                        amount: { type: number }
                        paidAt: { type: ["string", "null"], format: date-time }
                    perTaskPay:
                      type: object
                      properties:
                        approved: { type: number }
                        pending: { type: number }
                        paid: { type: number }
                        unpaid:
                          type: number
                          description: >-
                            Approved per-task pay not yet paid. `pending` pay
                            contributes 0 (1.135.0).
                    taggedCount: { type: integer }
                    delivered: { type: integer }
                    inProgress: { type: integer }
                    firstTaskAt: { type: ["string", "null"], format: date-time }
                    lastDeliveryAt: { type: ["string", "null"], format: date-time }
                    daysSpan: { type: ["integer", "null"] }
                    memberCost: { type: number }
      example:
        from: "2026-06-01"
        to: "2026-06-30"
        members:
          - memberId: "11111111-1111-1111-1111-111111111111"
            memberName: "Dana Levi"
            payType: perTask
            totalCost: 1500
            costBreakdown: { perTask: 1500, projectFees: 0, salary: 0 }
            paidOut: 1500
            attributedRevenue: 3000
            netReturn: 1500
            roiRatio: 2
            roiVerdict: strong
            delivered: 12
            inProgress: 2
            costPerVideo: 125
            viewsAttributed: 48200
            engagementAttributed: 3140

    ProjectPnl:
      type: object
      required: [projectId, billing, revenue, cost, margin, marginPct, delivered, unpricedTasks]
      properties:
        projectId: { type: string, format: uuid }
        from: { type: ["string", "null"] }
        to: { type: ["string", "null"] }
        billing:
          type: object
          required: [client, team]
          properties:
            client: { type: string, enum: [perTask, fixedPrice, legacyAdditive] }
            team: { type: string, enum: [perTask, fixedProject] }
        revenue:
          type: object
          required: [approved, pending, paid, outstanding]
          properties:
            approved: { type: number }
            pending: { type: number }
            paid: { type: number }
            outstanding:
              type: number
              description: >-
                Approved revenue not yet received on this project. Revenue
                still in `pending` is not owed yet and contributes 0 (1.97.0).
        cost:
          type: object
          required: [teamApproved, teamPending, teamPaid, teamUnpaid, memberFees, salaryAllocated]
          properties:
            teamApproved: { type: number }
            teamPending: { type: number }
            teamPaid: { type: number }
            teamUnpaid:
              type: number
              description: >-
                Owed to the team on this project right now — approved per-task
                pay not yet paid, plus unpaid member fees. Pay still in
                `teamPending` contributes 0 (1.135.0), matching
                `/api/v1/pricing/payables`.
            memberFees: { type: number }
            salaryAllocated: { type: number }
        margin:
          type: number
          description: Realized — approved revenue minus (approved team cost + fees + allocated salary).
        marginPct: { type: ["number", "null"] }
        delivered: { type: number }
        unpricedTasks:
          type: number
          description: Tasks carrying no money on the counted axis — margin is an "at least" figure when > 0.

    Payment:
      type: object
      required: [id, amount, direction, paid_at, voided]
      properties:
        id: { type: string, format: uuid }
        created_at: { type: string, format: date-time }
        amount: { type: number }
        currency: { type: ["string", "null"] }
        direction: { type: string, enum: [in, out] }
        paid_at:
          type: string
          format: date-time
          description: The BUSINESS date the money moved (backdateable), not the row's creation time.
        editor:
          type: ["string", "null"]
          description: Member profile id — the counterparty of an 'out' payment.
        node:
          type: ["string", "null"]
          description: Brand node id — the counterparty of an 'in' payment.
        task: { type: ["string", "null"] }
        task_editor_pay: { type: ["string", "null"] }
        project_member_pay: { type: ["string", "null"] }
        project: { type: ["string", "null"] }
        brand_charge:
          type: ["string", "null"]
          description: >-
            The brand retainer month or one-off charge this 'in' payment
            settles (1.91.0) — a `brandCharges[].chargeId` from
            `GET /api/v1/pricing/receivables`.
        method: { type: ["string", "null"] }
        note: { type: ["string", "null"] }
        recorded_by: { type: ["string", "null"] }
        reverses:
          type: ["string", "null"]
          description: Set on reversal rows — the id of the payment this row cancels.
        backfill_key: { type: ["string", "null"] }
        idempotency_key: { type: ["string", "null"] }
        voided:
          type: boolean
          description: True when a reversal row cancels this payment.

    PaymentInput:
      type: object
      required: [direction, amount]
      properties:
        direction: { type: string, enum: [in, out] }
        amount: { type: number, exclusiveMinimum: 0 }
        memberId:
          type: string
          format: uuid
          description: The member paid — required when direction is 'out'.
        nodeId:
          type: string
          format: uuid
          description: The paying brand — required when direction is 'in'.
        projectId:
          type: string
          format: uuid
          description: Optional project this payment belongs to.
        paidAt:
          type: string
          description: Optional ISO business date to backdate the payment.
        method: { type: string, maxLength: 40 }
        note: { type: string, maxLength: 500 }
        idempotencyKey:
          type: string
          maxLength: 100
          description: Client-chosen replay-safety key (unique per workspace).

    MarkPayablesInput:
      type: object
      required: [paid]
      description: At least one id list must be non-empty.
      properties:
        editorPayIds:
          type: array
          maxItems: 100
          items: { type: string, format: uuid }
          description: TaskEditorPay row ids to flip.
        memberFeeIds:
          type: array
          maxItems: 100
          items: { type: string, format: uuid }
          description: ProjectMemberPay fee row ids to flip.
        paid: { type: boolean }
        paidAt:
          type: string
          description: Optional ISO date to backdate (ignored when paid=false).

    MarkReceivablesInput:
      type: object
      required: [paid]
      description: Exactly ONE of taskIds / projectId.
      properties:
        taskIds:
          type: array
          minItems: 1
          maxItems: 100
          items: { type: string, format: uuid }
          description: Task ids whose client price is being marked.
        projectId:
          type: string
          format: uuid
          description: A project whose PROJECT-LEVEL price is being marked.
        paid: { type: boolean }
        paidAt:
          type: string
          description: Optional ISO date to backdate (ignored when paid=false).

    TaskPricingInput:
      type: object
      additionalProperties: false
      description: At least one of templateId / editorRoles.
      properties:
        templateId:
          type: string
          format: uuid
          description: Pricing template to apply (from GET /api/v1/pricing/templates). Omit to keep the current one.
        editorRoles:
          type: array
          maxItems: 50
          items:
            type: object
            additionalProperties: false
            required: [memberId, role]
            properties:
              memberId:
                type: string
                format: uuid
                description: An editor assigned to the task.
              role:
                type: [string, "null"]
                description: 'The template role this editor fills; null saves the editor as "No role (not paid)" — they earn nothing on the task (no split, rate, default pay or bonus) and are never re-tagged automatically. To clear a tag instead, send null with `untag: true`.'
              untag:
                type: boolean
                description: "Since 1.103.4. `true` (with `role: null`) returns the editor to untagged — no opt-out is stored, and automatic role assignment may tag them again. A role together with `untag: true` is a 400."
    TaskPricingResult:
      type: object
      required: [taskId, templateId, templateName, templateRoles, clientPrice, teamPay, editorPays]
      properties:
        taskId: { type: string, format: uuid }
        templateId: { type: [string, "null"], format: uuid }
        templateName: { type: [string, "null"] }
        templateRoles:
          type: array
          items: { type: string }
          description: The split roles this template defines (empty for a template without role splits).
        clientPrice: { type: [number, "null"] }
        teamPay:
          type: [number, "null"]
          description: Total team pay on the task (sum of editorPays).
        editorPays:
          type: array
          items:
            type: object
            required: [id, memberId, role, roleSource, amount, paidAt]
            properties:
              id:
                type: string
                format: uuid
                description: TaskEditorPay id — pass to POST /api/v1/pricing/payables/mark-paid.
              memberId: { type: string, format: uuid }
              role: { type: [string, "null"] }
              roleSource:
                type: [string, "null"]
                enum: [manual, auto, optOut, null]
                description: "Since 1.103.4. How `role` was set: `manual` (explicitly tagged), `auto` (assigned from the workspace sub-role), `optOut` (\"No role (not paid)\"), or null (untagged, or set before 1.103.4). Undo a change with `untag: true` for an editor whose previous roleSource was null — never `role: null`."
              amount: { type: number }
              paidAt: { type: [string, "null"], format: date-time }
    ProjectBillingInput:
      type: object
      description: At least one axis (client and/or team) must be present.
      properties:
        client:
          type: object
          required: [mode]
          properties:
            mode: { type: string, enum: [perTask, fixedPrice] }
            amount:
              type: number
              minimum: 0
              description: Required when mode is 'fixedPrice'.
            label: { type: string, maxLength: 80 }
        team:
          type: object
          required: [mode]
          properties:
            mode: { type: string, enum: [perTask, fixedProject] }
            memberFees:
              type: array
              maxItems: 50
              description: Replaces the fee list — only with mode 'fixedProject'.
              items:
                type: object
                required: [memberId, amount]
                properties:
                  memberId: { type: string, format: uuid }
                  amount: { type: number, minimum: 0 }
            feeUpdates:
              type: array
              maxItems: 50
              description: >-
                MERGE single-member fee changes (any team mode; mutually
                exclusive with memberFees). Each entry upserts that member's
                fee; `amount: null` removes it. Paid fees refuse edits (409).
              items:
                type: object
                required: [memberId, amount]
                properties:
                  memberId: { type: string, format: uuid }
                  amount:
                    type: ["number", "null"]
                    minimum: 0
                    description: The member's project fee; null removes it.

    ProjectBillingResult:
      type: object
      properties:
        data:
          type: object
          required: [projectId, clientBillingMode, teamBillingMode, amount, label]
          properties:
            projectId: { type: string, format: uuid }
            clientBillingMode:
              type: ["string", "null"]
              enum: [perTask, fixedPrice, null]
              description: Null = grandfathered legacy-additive (no mode chosen yet).
            teamBillingMode: { type: string, enum: [perTask, fixedProject] }
            amount: { type: ["number", "null"] }
            label: { type: ["string", "null"] }
            memberFees:
              type: integer
              description: Present when a fee list was applied — how many entries it now has.

    Analytics:
      type: object
      required: [statusCounts, financialTrend, editorPerformance, revisionStats, productionMomentum, topEditors, topClients]
      properties:
        from: { type: ["string", "null"] }
        to: { type: ["string", "null"] }
        brandId: { type: ["string", "null"] }
        projectId:
          type: ["string", "null"]
          description: The `projectId` filter echoed back (1.158.0).
        memberId: { type: ["string", "null"] }
        statusCounts:
          type: array
          items:
            type: object
            properties:
              status: { type: string }
              count:
                type: integer
                description: >-
                  Top-level tasks in this status group — a parent counts once,
                  its variants are not counted separately.
              percentage: { type: integer }
        financialTrend:
          type: array
          items:
            type: object
            properties:
              period: { type: string, description: "YYYY-MM" }
              clientApproved: { type: number }
              clientPending: { type: number }
              editorApproved:
                type: number
                description: >-
                  Approved team cost for the month — per-task editor pay plus
                  the per-member project fees created in that month. Excludes
                  salaried members' per-task pay (their salary is the
                  `salaryCost` line) and the per-task pay of any (project,
                  member) covered by a fee.
              editorPending: { type: number }
              salaryCost:
                type: number
                description: >-
                  Prorated monthly-salary cost attributed to this month. With
                  `brandId`, each salaried member's cost is multiplied by their
                  delivered share in that brand — approved deliveries in the
                  brand over approved deliveries across the workspace, same
                  date window (a pod member's delivery counts for the pod
                  lead) — so a brand carries only the payroll its work used,
                  exactly as the Analytics screen's brand filter does (1.107.3;
                  before, the line was 0 under `brandId`). `projectId` prorates
                  the same way, by the member's share in that project (1.158.0).
                  With `memberId`, only that member's salary.
              netMargin:
                type: number
                description: >-
                  clientApproved − editorApproved − salaryCost. Summed over the
                  months, it matches the Analytics screen's PROFIT for the same
                  brand filter and date range.
        editorPerformance:
          type: array
          items:
            type: object
            properties:
              editorId: { type: string, format: uuid }
              editorName: { type: ["string", "null"] }
              approvedTasks: { type: integer }
              inProgressTasks: { type: integer }
              onTimePct: { type: integer }
              delayedPct: { type: integer }
              avgRevisionRounds: { type: number }
        revisionStats:
          type: object
          properties:
            avgInternal: { type: number }
            avgExternal: { type: number }
            totalTasks: { type: integer }
            editors:
              type: array
              items:
                type: object
                properties:
                  editorId: { type: string, format: uuid }
                  editorName: { type: ["string", "null"] }
                  avgInternal: { type: number }
                  pctVsAvg: { type: integer }
            brands:
              type: array
              items:
                type: object
                properties:
                  brandId: { type: string, format: uuid }
                  brandName: { type: ["string", "null"] }
                  avgExternal: { type: number }
                  pctVsAvg: { type: integer }
            trend:
              type: array
              items:
                type: object
                properties:
                  period: { type: string }
                  avgInternal: { type: number }
                  avgExternal: { type: number }
        productionMomentum:
          type: array
          items:
            type: object
            properties:
              period: { type: string }
              approved: { type: integer }
              pending: { type: integer }
              approvalRate: { type: integer }
        topEditors:
          type: array
          items:
            type: object
            properties:
              id: { type: string, format: uuid }
              editorName: { type: ["string", "null"] }
              value: { type: number }
              taskCount: { type: integer }
              pctAbove: { type: integer }
        topClients:
          type: array
          items:
            type: object
            properties:
              id: { type: string, format: uuid }
              brandName: { type: ["string", "null"] }
              value: { type: number }
              taskCount: { type: integer }
              pctAbove: { type: integer }
        teamWorkload:
          type: array
          items:
            type: object
            properties:
              editorId: { type: string, format: uuid }
              editorName: { type: ["string", "null"] }
              byStatus:
                type: object
                additionalProperties: { type: integer }
              total: { type: integer }
        timeTracking:
          type: array
          description: >-
            Per-member tracked time (completed Time Tracking entries, filtered
            on when the time was logged). Narrowed by `brandId` and `projectId`
            to time tracked on those tasks, and by `memberId` to the time that
            member tracked — the in-app Time Tracking card's rules (1.158.0).
          items:
            type: object
            properties:
              editorId: { type: string, format: uuid }
              editorName: { type: ["string", "null"] }
              totalSeconds: { type: integer }
              taskCount: { type: integer }

    CreateTaskInput:
      type: object
      required: [projectId, title]
      properties:
        projectId:
          type: string
          format: uuid
        title:
          type: string
          minLength: 1
          maxLength: 200
        type:
          type: string
          enum: [media, doc]
          default: media
        text:
          type: string
          maxLength: 1000000
          description: |
            `type: doc` only. The document as plain text. Each line becomes a
            paragraph and each blank line a blank line, so a text-first post
            publishes with exactly this spacing. Markup is treated as literal
            text. Mutually exclusive with `contentHtml`.
        contentHtml:
          type: string
          maxLength: 1000000
          description: |
            `type: doc` only. The document as HTML (`<p>`, `<strong>`, `<em>`,
            `<ul>` / `<ol>`) for copy that needs bold or lists; an empty
            `<p></p>` is a blank line. Mutually exclusive with `text`.
        kind:
          type: string
          enum: [regular, variant]
          default: regular
        parentTaskId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            Only valid when `kind=variant`, where it is required. Must be an
            active task in the same project that is not itself a variant and
            carries no file of its own. A `regular` task named here is PROMOTED
            to `kind: parent` by the same call, so the variant shows up nested
            under it in the app; a task that is already a parent is added to
            unchanged. Sending it on a `regular` create (including when `kind`
            is omitted, which defaults to `regular`) returns 400
            `` `parentTaskId` can only be set when `kind` is 'variant' ``.
        position:
          type:
            - integer
            - "null"
          minimum: 0
          description: |
            `kind: variant` only (1.163.1). The new variant's 0-based slot among
            the parent's active variants — `0` makes it the first slide; a
            number past the end puts it last. Omit it (or send `null`) to add
            the variant after the parent's last one. Sent on a non-variant
            create it returns 400
            `` `position` can only be set when `kind` is 'variant' ``; a value
            that is not a whole number from 0 returns 400 naming `position`.
        subFolderId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            Sub-folder (task group) inside the project to place the task in.
            Must belong to the same project (400 otherwise). Omit or `null`
            for the project root.
        statusGroup:
          type: string
          enum:
            - toDo
            - inProgress
            - supervisorApproval
            - clientApproval
            - endClientApproval
            - approved
            - posted
            - inRevision
          default: toDo
          description: |
            Defaults to `toDo`. On a variant create (`kind: variant`) an omitted
            `statusGroup` inherits the parent task's stage instead, matching how
            the app creates variants; an explicit value always wins.
        internalDeadline:
          type:
            - string
            - "null"
          format: date
          description: Internal team deadline (YYYY-MM-DD), or null.
        externalDeadline:
          type:
            - string
            - "null"
          format: date
          description: Client-facing deadline (YYYY-MM-DD), or null.
        startDate:
          type:
            - string
            - "null"
          format: date
          description: |
            Workload work-window start (YYYY-MM-DD), or null. With a deadline,
            assignees and an estimate the task appears on the Workload view,
            its hours spread across working days.
        estimatedMinutes:
          type:
            - integer
            - "null"
          minimum: 0
          maximum: 60000
          description: Total time estimate in minutes (1440 = 24h), or null.
        externalMetadata:
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        pricingTemplateId:
          type: string
          format: uuid
          description: |
            Since 1.125.0. Price the task at creation with this pricing
            template (ids from `GET /api/v1/pricing/templates`) — the task gets
            the template's pricing tag, its default client price and the
            editors' default pay, exactly as picking the template in the app's
            pricing dialog. Checked before the task is created: an unknown
            template is a 404 and nothing is created. Needs the
            `write:finance` scope (403 otherwise). `assigneeRoles` is not
            accepted here (a new task has no assignees) — send it with
            `assigneeIds` on `PATCH /api/v1/tasks/{id}`.

    UpdateTaskInput:
      type: object
      description: Provide at least one of the allow-listed fields.
      minProperties: 1
      properties:
        title:
          type: string
          minLength: 1
          maxLength: 200
        statusGroup:
          type: string
          enum:
            - toDo
            - inProgress
            - supervisorApproval
            - clientApproval
            - endClientApproval
            - approved
            - posted
            - inRevision
        customStatusId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            Move the task into one of the workspace's custom statuses (ids from
            `GET /api/v1/custom-statuses`); its `statusGroup` becomes the
            status's base — omit `statusGroup` or send that base (another value
            is a 400). `null` takes the task out of its custom status, back to
            the plain base (or to the `statusGroup` sent with it). 400 when the
            status is not in this workspace, is not used on the task's brand,
            or the task is a variant (a variant follows its parent's status).
            A move inside one base fires no notifications; entering one from
            another base notifies exactly like moving to that base. As with
            `statusGroup`, the API key acts with the workspace's authority —
            a status's in-app editor limits do not apply.
        internalDeadline:
          type:
            - string
            - "null"
          format: date
        externalDeadline:
          type:
            - string
            - "null"
          format: date
        assigneeIds:
          type: array
          items:
            type: string
            format: uuid
          description: |
            Full-replace list of team-member ids to assign to the task (the
            `Task.editors` set). Send the complete desired list; `[]` clears all
            assignees. Every id must be a team member of this workspace — guests
            and members of other workspaces are rejected with 400. Newly-added
            members are notified the same way the UI assignment notifies them.
            Reserved system ids are rejected the same way unless enabled for
            the workspace (1.136.0).
        subFolderId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            Move the task into a sub-folder (task group) of its project, or
            `null` to move it back to the project root. The sub-folder must
            belong to the task's project (400 otherwise) — with `projectId`,
            to the project the task moves to.
        projectId:
          type: string
          format: uuid
          description: |
            1.221.0. Move the task to this project (from
            `GET /api/v1/projects`) — in the same brand, under another folder,
            or under another brand of the workspace. Lands at the project root
            unless `subFolderId` names one of its sub-folders. Refused (400) on
            a variant: send it to the `parentTaskId`, which moves every variant
            too. 404 when the project is not in this workspace.
        position:
          type: integer
          minimum: 0
          description: |
            Variants only (1.163.1). Move this variant to this 0-based slot
            among its parent's active variants — `0` makes it the first slide
            of the carousel; a number past the end puts it last. The other
            variants keep their order around it. 400 on a regular or parent
            task (`` `position` can only be set on a variant … ``), on a
            variant in the trash, and on a value that is not a whole number
            from 0.
        startDate:
          type:
            - string
            - "null"
          format: date
          description: Workload work-window start (YYYY-MM-DD), or null to clear.
        estimatedMinutes:
          type:
            - integer
            - "null"
          minimum: 0
          maximum: 60000
          description: |
            Total time estimate in minutes. `null` clears the estimate AND any
            per-assignee breakdown.

            When the task already carries a per-assignee breakdown and you send
            `estimatedMinutes` WITHOUT `assigneeEstimates`, the existing rows
            are rescaled proportionally to the new total (largest-remainder
            rounding, so they still sum exactly to it) — the same behaviour as
            editing the total in the app. Send `assigneeEstimates` to set the
            split explicitly instead.
        assigneeEstimates:
          type: array
          items:
            type: object
            required: [memberId, estimatedMinutes]
            properties:
              memberId:
                type: string
                format: uuid
              estimatedMinutes:
                type: integer
                minimum: 0
                maximum: 60000
          description: |
            **Full replace** of the per-assignee estimate breakdown (minutes
            each). Every `memberId` must be an assignee of the task after this
            PATCH; `[]` clears the breakdown (keeping any total-only estimate).
            When present the breakdown is authoritative and the task's
            `estimatedMinutes` becomes its sum. The entries must sum to at
            most 60000 minutes — an over-cap breakdown is rejected with
            `400 Bad Request` (previously it surfaced as a 500).
        externalMetadata:
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        pricingTemplateId:
          type: string
          format: uuid
          description: |
            Since 1.125.0. Apply this pricing template (ids from
            `GET /api/v1/pricing/templates`) — the same write as
            `PUT /api/v1/tasks/{id}/pricing` `templateId`: pricing tag, default
            client price and editor pay recomputed by the in-app engine.
            Needs the `write:finance` scope.
        assigneeRoles:
          type: array
          maxItems: 50
          description: |
            Since 1.125.0. Which pricing-template role each assignee fills, so
            only they draw that role's pay — the same write as
            `PUT /api/v1/tasks/{id}/pricing` `editorRoles`. Each member must
            be an assignee AFTER this request (send `assigneeIds` in the same
            body to assign and tag in one call). Uses the task's current
            template, or `pricingTemplateId` when sent together; a task with no
            template is a 400. An editor's pay is the template's default for
            their role — a custom `pay` amount is not supported (400). Needs
            the `write:finance` scope.
          items:
            type: object
            additionalProperties: false
            required: [memberId, roleLabel]
            properties:
              memberId:
                type: string
                format: uuid
              roleLabel:
                type: [string, "null"]
                description: |
                  A role the template defines, e.g. `Online Editor`
                  (case-insensitive). `null` saves the assignee as "No role
                  (not paid)" — they earn nothing on the task.

    ShareLink:
      type: object
      required: [id, token, url, accessLevel, isActive, contentType]
      properties:
        id:
          type: string
          format: uuid
        token:
          type: string
          description: |
            Opaque share token embedded in the public review URL. Treat it like a
            password: anyone holding it opens the link. Since 1.217.1 Timeliner
            stores new and re-issued links only in hashed and encrypted form, so
            the same token is still returned on every later call.
        url:
          type: string
          format: uri
          description: The full public share URL (e.g. `https://timeliner.io/share/<token>`).
        accessLevel:
          type: string
          enum: [viewer, commenter, approver]
        isActive:
          type: boolean
        expiresAt:
          type:
            - string
            - "null"
          format: date-time
          description: When the link expires. `null` for forever-links.
        createdAt:
          type: string
          format: date-time
        contentType:
          type: string
          description: Internal share scope. Project-level and task-level share links use `tasks`; brand-level share links use `files`.

    CreateShareLinkInput:
      type: object
      properties:
        accessLevel:
          type: string
          enum: [viewer, commenter, approver]
          default: viewer
          description: Level of access the share link grants to anyone who opens it.
        duration:
          type: string
          enum: [24h, 7d, 30d, 60d, 90d, forever]
          default: 30d
          description: How long the link stays active (only applied when creating or reactivating).

    BatchShareLink:
      type: object
      description: |
        ONE public link that opens a hand-picked, ordered set of a project's
        tasks (`contentType: batch`). The `token` IS the URL — never log it.
      required: [id, token, url, accessLevel, isActive, expiresAt, createdAt, contentType, projectId, label, note, taskIds, taskCount]
      properties:
        id:
          type: string
          format: uuid
        token:
          type: string
          description: Opaque share token embedded in the public review URL.
        url:
          type: string
          format: uri
          description: The full public share URL (e.g. `https://timeliner.io/share/<token>`).
        accessLevel:
          type: string
          enum: [viewer, commenter, approver]
        isActive:
          type: boolean
          description: "`false` once revoked; `PATCH { isActive: true }` re-issues it with a new url."
        expiresAt:
          type:
            - string
            - "null"
          format: date-time
          description: When the link expires. `null` for forever-links.
        createdAt:
          type: string
          format: date-time
        contentType:
          type: string
          enum: [batch]
        projectId:
          type: string
          format: uuid
        label:
          type: string
          description: The title the client sees on the link.
        note:
          type:
            - string
            - "null"
          description: An optional note from the agency, shown above the videos.
        taskIds:
          type: array
          description: The tasks the link opens, in display order.
          items:
            type: string
            format: uuid
        taskCount:
          type: integer

    CreateBatchShareLinkInput:
      type: object
      required: [taskIds]
      properties:
        taskIds:
          type: array
          minItems: 1
          maxItems: 100
          description: Active regular or parent tasks of this project, in the order the client should see them. No duplicates, no variants.
          items:
            type: string
            format: uuid
        label:
          type: string
          maxLength: 120
          description: The title the client sees. Defaults to "<Project name> · N videos".
        note:
          type:
            - string
            - "null"
          maxLength: 2000
          description: An optional note shown above the videos.
        accessLevel:
          type: string
          enum: [viewer, commenter, approver]
          default: approver
          description: Level of access the link grants to anyone who opens it.
        duration:
          type: string
          enum: [24h, 7d, 30d, 60d, 90d, forever]
          default: 30d
          description: How long the link stays active.

    UpdateBatchShareLinkInput:
      type: object
      minProperties: 1
      properties:
        label:
          type: string
          minLength: 1
          maxLength: 120
        note:
          type:
            - string
            - "null"
          maxLength: 2000
          description: "`null` clears the note."
        taskIds:
          type: array
          minItems: 1
          maxItems: 100
          description: FULL replacement of the task set and its order.
          items:
            type: string
            format: uuid
        accessLevel:
          type: string
          enum: [viewer, commenter, approver]
        duration:
          type: string
          enum: [24h, 7d, 30d, 60d, 90d, forever]
          description: Resets the expiry from now.
        isActive:
          type: boolean
          description: "`false` switches the link off; `true` on a switched-off link re-issues it with a NEW token/url."

    AttachRawFileRequest:
      type: object
      additionalProperties: false
      required: [fileId]
      properties:
        fileId:
          type: string
          format: uuid
          description: The raw file's id, all 36 characters — `files[].id` from the task's project header or its brand header (`GET /api/v1/projects/{id}/header`, `GET /api/v1/brands/{id}/header`).

    AttachedRawFile:
      type: object
      required: [id, taskId, sourceFileId, source, name, mimeType, size, versionNumber]
      properties:
        id:
          type: string
          format: uuid
          description: The post's new attachment — its own file entry, sharing the raw file's stored file.
        taskId:
          type: string
          format: uuid
        sourceFileId:
          type: string
          format: uuid
          description: The raw file it was taken from (unchanged, still in Raw files & assets).
        source:
          type: string
          enum: [project, brand]
          description: Where the raw file lives — the task's project or the brand above it.
        name:
          type: string
        mimeType:
          type: string
        size:
          type: integer
          description: Bytes.
        versionNumber:
          type: integer
          description: The task version the attachment became.

    MoveFileRequest:
      type: object
      additionalProperties: false
      description: |
        `projectId` OR `brandId` (never both), each optionally with `folderId`;
        or `folderId` alone for a folder of the file's current project or brand.
      properties:
        projectId:
          type: string
          format: uuid
          description: Move the file into this project's Raw files & assets.
        brandId:
          type: string
          format: uuid
          description: Move the file into this brand header's Raw files & assets.
        folderId:
          type: string
          format: uuid
          nullable: true
          description: A folder of the destination; `null` (or omitted with `projectId` / `brandId`) = the top level.

    RawFolderResult:
      type: object
      required: [data]
      properties:
        data:
          type: object
          required: [id, name, scope, projectId, brandId, parentId, created, rawFilesCard]
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            scope:
              type: string
              enum: [project, brand]
            projectId:
              type: string
              format: uuid
              nullable: true
            brandId:
              type: string
              format: uuid
              nullable: true
            parentId:
              type: string
              format: uuid
              nullable: true
            created:
              type: boolean
              description: false when a folder with that name was already there.
            rawFilesCard:
              type: object
              required: [id, added, restored]
              properties:
                id:
                  type: string
                  format: uuid
                added:
                  type: boolean
                restored:
                  type: boolean
    MovedFile:
      type: object
      required: [id, name, scope, projectId, brandId, folderId, renamed, rawFilesCard]
      properties:
        id:
          type: string
          format: uuid
          description: The file's id — unchanged by the move.
        name:
          type: string
          description: The file's name at the destination.
        scope:
          type: string
          enum: [project, brand]
          description: Whether the file now lives in a project's or a brand's Raw files & assets.
        projectId:
          type: string
          format: uuid
          nullable: true
        brandId:
          type: string
          format: uuid
          nullable: true
        folderId:
          type: string
          format: uuid
          nullable: true
        renamed:
          type: boolean
          description: true when the name was already used at the destination and got a " (N)" suffix.
        rawFilesCard:
          $ref: "#/components/schemas/MovedFileRawFilesCard"

    MovedFileRawFilesCard:
      type: object
      description: |
        The destination header's Raw files & Assets card — where the file
        shows in the app (1.125.0).
      required: [id, added, restored]
      properties:
        id:
          type: string
          format: uuid
          description: The card's id (a header card of the destination project or brand).
        added:
          type: boolean
          description: true when the header had no Raw files & Assets card and this call added one.
        restored:
          type: boolean
          description: true when the card was hidden from everyone and this call showed it again.

    UploadFileFromUrlRequest:
      type: object
      required: [url]
      description: |
        Exactly one destination is required: `taskId` (attach as the task's new
        version) or `projectId` (save as a project raw file). Passing both is
        allowed only when `projectId` is the task's own project.
      properties:
        url:
          type: string
          format: uri
          maxLength: 2048
          description: |
            Public `http(s)` URL of the file. Must be reachable without
            authentication and must not resolve to a private, loopback,
            link-local or cloud-metadata address. Max 100 MB.
        taskId:
          type: string
          format: uuid
          description: Attach the file as this task's new version (the deliverable).
        projectId:
          type: string
          format: uuid
          description: >-
            Save the file as a raw file in this project. Required when `taskId`
            is omitted. The project's own id, all 36 characters — never a task,
            sub-folder, brand, folder, HQ item or file id (a miss names which,
            see 404).
        folderId:
          type: string
          format: uuid
          description: |
            Optional project folder to file it under. Must belong to the same
            project: `folders[].id` from `GET /api/v1/projects/{id}/files`, all
            36 characters — never a brand header's folder, another project's
            folder, a sidebar folder or a sub-folder of tasks (a miss names
            which, see 404). Project files only — sending it together with
            `taskId` is rejected with `400`.
        fileName:
          type: string
          maxLength: 200
          description: |
            Override the filename inferred from `Content-Disposition` or the
            URL path. A name already used in the project gets a ` (1)` suffix
            (a `projectFile` backup keeps its own name).
        target:
          $ref: "#/components/schemas/TaskUploadTarget"

    UploadedFile:
      type: object
      required: [id, name, mimeType, size, projectId, taskId, versionNumber, folderId, sourceUrl]
      properties:
        id:
          type: string
          format: uuid
          description: The new file's id. When the file is a JPEG, PNG or WebP image, pass it to `update_post` / `PATCH /api/v1/posts/{taskId}` as `thumbnailFileId` to use it as a post cover.
        name:
          type: string
          description: The stored filename, after de-duplication.
        mimeType:
          type: string
        size:
          type: integer
          description: File size in bytes.
        projectId:
          type: string
          format: uuid
        taskId:
          type: string
          format: uuid
          nullable: true
          description: Set when the file was sent with a `taskId` — attached as a task version, or (by `target`) put on the task's Project files tab.
        versionNumber:
          type: integer
          nullable: true
          description: The version number created on the task, when `taskId` was supplied.
        folderId:
          type: string
          format: uuid
          nullable: true
        sourceUrl:
          type:
            - string
            - "null"
          format: uri
          description: The URL the bytes were pulled from (upload-from-url), after following any redirects. Null for multipart uploads.
        target:
          type:
            - string
            - "null"
          enum: [version, taskFiles, projectFile, null]
          description: Where on the task the file went (1.159.0); null for a project upload.

    TaskUploadTarget:
      type: string
      enum: [version, taskFiles, projectFile]
      description: |
        Where on the task (`taskId`) the file goes; needs `taskId` (1.159.0).
        `version` (default) — the task's new version. `taskFiles` — the task's
        Project files tab, "Files on this task" (a raw project file in the
        folder named after the task). `projectFile` — that tab's team-only
        editing-project backup: `.prproj`, `.aep`, `.drp`, `.drt`, `.psd`,
        `.ai` or `.zip`, on a media task; it becomes the Current backup and
        notifies no one.

    TaskProjectFiles:
      type: object
      required: [taskId, taskFiles, projectFile]
      properties:
        taskId:
          type: string
          format: uuid
        taskFiles:
          type: object
          required: [folderId, files]
          properties:
            folderId:
              type:
                - string
                - "null"
              format: uuid
              description: The Raw files folder named after the task; null until the first file.
            files:
              type: array
              items:
                type: object
                required: [id, name, size, mimeType, createdAt, fromClient, uploaderId, mediaRemoved]
                properties:
                  id:
                    type: string
                    format: uuid
                  name:
                    type: string
                  size:
                    type: integer
                  mimeType:
                    type: string
                  createdAt:
                    type: string
                    format: date-time
                  fromClient:
                    type: boolean
                    description: Dropped by a client (share link or signed-in guest).
                  uploaderId:
                    type:
                      - string
                      - "null"
                    format: uuid
                  mediaRemoved:
                    type: boolean
                    description: The file's content was removed after the workspace's subscription ended.
        projectFile:
          type:
            - object
            - "null"
          description: Null on a document task (no backup slot).
          required: [backups]
          properties:
            backups:
              type: array
              items:
                type: object
                required: [id, name, size, mimeType, createdAt, label, isCurrent, uploaderId]
                properties:
                  id:
                    type: string
                    format: uuid
                  name:
                    type: string
                  size:
                    type: integer
                  mimeType:
                    type: string
                  createdAt:
                    type: string
                    format: date-time
                  label:
                    type:
                      - string
                      - "null"
                  isCurrent:
                    type: boolean
                    description: The backup the next editor should open.
                  uploaderId:
                    type:
                      - string
                      - "null"
                    format: uuid

    UploadDocAttachmentFromUrlRequest:
      type: object
      required: [url]
      properties:
        url:
          type: string
          format: uri
          maxLength: 2048
          description: |
            Public `http(s)` URL of the image or file. Must be reachable
            without authentication and must not resolve to a private,
            loopback, link-local or cloud-metadata address.
        fileName:
          type: string
          maxLength: 200
          description: |
            Override the filename inferred from `Content-Disposition` or the
            URL path. Include the extension.

    UploadedDocAttachment:
      type: object
      required: [id, url, filename, mimeType, size, embedHtml, sourceUrl]
      properties:
        id:
          type: string
          format: uuid
          description: The stored attachment's id.
        url:
          type: string
          description: |
            App-relative URL the document renders from
            (`/api/brief-attachment/{id}/{filename}`). Viewers need a
            Timeliner session in the owning workspace. Once the workspace's
            media is removed after its subscription ended (see *Removed
            media*), this URL answers 404, and an embedded image or video
            shows a placeholder in its place (since 1.109.0).
        filename:
          type: string
          description: The stored filename, after sanitization.
        mimeType:
          type: string
        size:
          type: integer
          description: Size in bytes.
        embedHtml:
          type: string
          description: |
            Ready-to-paste markup for the document body — an `<img>` for
            images, an inline player block for videos, a download chip for
            everything else. Insert it into the `contentHtml` you send to
            `PUT /api/v1/hq/items/{id}/doc` or `PATCH /api/v1/tasks/{id}/doc`.
        sourceUrl:
          type: string
          format: uri
          description: The URL the bytes were pulled from, after following any redirects.

    FileVariantGenerating:
      type: object
      required: [status, type, height, retryAfterSeconds]
      properties:
        status:
          type: string
          enum: [generating]
        type:
          type: string
          enum: [variant]
        height:
          type: integer
          description: The requested height.
        retryAfterSeconds:
          type: integer
          description: Seconds to wait before calling the same URL again.
          example: 15

    FileDownload:
      type: object
      required: [url, expiresAt, type, fileName, mimeType, size]
      properties:
        url:
          type: string
          format: uri
          description: Presigned, time-limited URL pointing to the file in R2 storage.
        expiresAt:
          type: string
          format: date-time
        type:
          type: string
          enum: [original, preview, thumbnail, variant]
        fileName:
          type: string
        mimeType:
          type: string
        size:
          type: integer
          description: File size in bytes.

    BrandSummary:
      type: object
      required: [id, name, type, socialLinks, socialAccounts, createdAt, updatedAt]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        type:
          type: string
          enum: [brand, client, folder]
          description: |
            Node type. `folder` appears only on `GET /api/v1/brands?type=folder`
            (the sidebar folders); every other brand endpoint returns `brand`
            or `client`.
        parentId:
          type:
            - string
            - "null"
          format: uuid
          description: |
            The Node this one sits in — a sidebar folder (or, for an end
            client, its parent client) — or `null` at the top level. A
            folder's contents are the rows whose `parentId` is its id.
            (1.206.0)
        archived:
          type: boolean
          description: |
            `true` when this brand or folder is in the Timeliner sidebar's
            Archive — archived itself, or inside an archived folder. Archived
            brands stay fully readable. (1.206.0)
        description:
          type:
            - string
            - "null"
        language:
          type:
            - string
            - "null"
          description: The brand's language code, if set.
        picture:
          type:
            - string
            - "null"
          description: Logo / avatar URL, if set.
        logoUrl:
          type:
            - string
            - "null"
          format: uri
          description: |
            A public, non-expiring URL of the brand's logo (1200px WebP), ready
            for an `<img>` in your own dashboards — no API key needed to load it.
            It points at `/api/brand-logo?key=…` (since 1.210.1; earlier
            versions answered `/api/v1/brand-logo?key=…`) — use the value as
            given rather than building it. The `key` is an unguessable id that
            only API-key holders and the brand's own members are ever shown.
            The image is the 1200px WebP (the 128px one when an older logo has
            no large size), always `image/webp` with
            `Content-Security-Policy: default-src 'none'; sandbox` (since
            1.202.0); a logo that has neither WebP size answers 404 — the
            uploaded original is never served. Cached for a year; the URL
            changes only when the logo is replaced. `null` when the brand has
            no logo. (1.197.0)
        socialLinks:
          type: array
          items:
            $ref: "#/components/schemas/SocialLink"
          description: |
            Named links configured on the brand — any label, not just social
            (e.g. `Website`, `Drive`, `instagram`). Empty array if none. This IS
            the brand header's **Brand Links** card (1.98.1): links added in the
            app are included, each card row's name comes back as `platform`, and
            an unnamed link comes back labelled the way the app labels it (`IG`,
            `Drive`, or the domain). A brand whose header has no links card at all
            reports the links stored before the card existed.
        socialAccounts:
          type: array
          items:
            $ref: "#/components/schemas/SocialAccount"
          description: |
            The brand's connected social channels (platform, handle, displayName,
            avatar, follower count, status) — so you can see which channels are on
            which brand directly from the list. Credentials are never included.
            Empty array if none are connected.
        metricoolBlogId:
          type:
            - string
            - "null"
          description: |
            Convenience read of `externalMetadata.metricool.blogId` (coerced to a
            string). `null` when not set. Set it via `PATCH` with
            `{ "externalMetadata": { "metricool": { "blogId": "…" } } }`.
        externalMetadata:
          description: |
            Arbitrary JSON stored on the brand — put any custom fields here
            (CRM ids, internal notes, integration config). Ignored by core
            Timeliner logic; namespace by integration to avoid collisions
            (e.g. `{ "metricool": { "blogId": "…" }, "crm": { "accountId": "A-123" } }`).
            `null` when never set.
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        guestAllStagesVisible:
          type: ["boolean", "null"]
          description: |
            This brand's "Show clients every workflow stage" override: `true`
            lets the brand's clients (signed in and on its share links) see
            tasks in every non-archive stage — early-stage media as a view-only
            placeholder card, early-stage documents as `guestEarlyStageDocAccess`
            allows (at `placeholder` a signed-in client gets no document card,
            only its name in the progress tracker) — `false` keeps them on the
            client stages, `null` (the default) inherits the workspace's
            `guestAllStagesVisible` from `GET /api/v1/workspace/settings`. A
            signed-in guest the task already reaches through an assignment
            keeps the rights it had before the setting, exactly as that
            workspace setting documents. Omit
            to leave unchanged. The literal string `"inherit"` is rejected —
            inheritance is expressed as `null`. Setting `true` is plan-gated
            (403 names the plan); `false` / `null` are always accepted. Writing
            it notifies no one.
        guestEarlyStageDocAccess:
          type: ["string", "null"]
          enum: [placeholder, view, comment, edit, null]
          description: |
            This brand's early-stage DOCUMENT access while every stage is
            visible: `placeholder` | `view` | `comment` | `edit`, or `null`
            (the default) to inherit the workspace's `guestEarlyStageDocAccess`.
            Each level means exactly what the workspace setting documents
            (`GET /api/v1/workspace/settings`): `placeholder` withholds the
            document from a signed-in client's Grid, List and Board (a share
            link shows a content-free placeholder card), `view` reads, `comment`
            reads + comments, `edit` also edits inside the early editing
            stages. Media is a placeholder. A guest the task reaches through
            an assignment keeps its pre-setting rights, as the workspace
            setting documents. Omit to leave unchanged;
            anything past `placeholder` is plan-gated.
        adminApprovalMode:
          type: ["string", "null"]
          enum: ["on", "off", null]
          description: |
            This brand's Admin Approval override. On the **Agency + 2 approvers**
            workflow `"on"` forces the stage, `"off"` removes it, `null` (the
            default) inherits the workspace's `adminApprovalScope` from
            `GET /api/v1/workspace/settings` — including `none`, where `"on"` is
            the only thing that gives a brand the stage. On the **Agency**,
            **Agency + End Client** and **Internal** workflows `"on"` adds the
            stage after Supervisor Approval for this brand only, and `null` /
            `"off"` mean no stage (1.98.0). Always `null` unless explicitly set.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

    Brand:
      allOf:
        - $ref: "#/components/schemas/BrandSummary"
        - type: object
          required: [intakeForm, shareLink]
          properties:
            intakeForm:
              description: The brand's effective brief (its question template + catalog items), or `null` when none is configured.
              oneOf:
                - $ref: "#/components/schemas/IntakeForm"
                - type: "null"
            shareLink:
              description: |
                The brand's working client-portal share link — switched on and
                not past its expiry — or `null` when it has none (create one
                with `POST /api/v1/brands/{id}/share-link`). When several access
                levels each have a working link, this is the one the brand's
                Share dialog shows. Since 1.112.0.
              oneOf:
                - $ref: "#/components/schemas/ShareLink"
                - type: "null"

    SocialAccount:
      type: object
      description: |
        A social channel connected to a brand. Credentials are never included.
        Since 1.233.0 a YouTube channel disconnected through Timeliner is still
        listed (`status: "disconnected"`) but with `handle`, `displayName`,
        `avatarUrl` and `followerCount` `null` — its YouTube data is hidden
        until it is reconnected within 6 days, and deleted after that.
      required: [id, platform, status]
      properties:
        id:
          type:
            - string
            - "null"
          format: uuid
          description: The connected account's id. Matches `Post.networks[].account.id`.
        platform:
          type: string
          description: Platform identifier (e.g. `instagram`, `tiktok`, `youtube`).
        status:
          type: string
          description: Connection status (e.g. `connected`, `expired`, `revoked`, `disconnected`).
        handle:
          type:
            - string
            - "null"
          description: The channel's handle / username (e.g. `@brand`).
        displayName:
          type:
            - string
            - "null"
        avatarUrl:
          type:
            - string
            - "null"
          description: The channel's profile-picture URL, if known.
        followerCount:
          type:
            - integer
            - "null"
        tokenExpiresAt:
          type:
            - string
            - "null"
          format: date-time

    IntakeForm:
      type: object
      required: [id, name, language, items]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        language:
          type: string
        questions:
          description: Opaque JSON template describing the brief's questions.
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        settings:
          description: Opaque JSON form settings.
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        items:
          type: array
          items:
            $ref: "#/components/schemas/IntakeFormItem"
          description: Catalog items (selectable deliverables) available in the brief.

    IntakeFormItem:
      type: object
      required: [id, title, sortOrder]
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        description:
          type:
            - string
            - "null"
        collectBrief:
          type: boolean
          description: >
            Whether this deliverable asks the client for a brief per unit
            ordered. Each brief lands on the created media task's brief when the
            request is approved.
        briefRequired:
          type: boolean
          description: >
            Whether those briefs must be filled in before the client can submit.
        collectTaskName:
          type: boolean
          description: >
            Whether this deliverable asks the client to NAME each unit ordered.
            The name becomes the created task's title when the request is
            approved; a blank one falls back to the deliverable's own title.
        maxQuantity:
          type: integer
          minimum: 1
          maximum: 50
          description: >
            The largest quantity of this deliverable a single brief may request
            (1-50, default 20). A request line above the cap is rejected, not
            truncated.
        sortOrder:
          type: integer

    BrandPage:
      type: object
      required: [data, nextBefore]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/BrandSummary"
        nextBefore:
          type:
            - string
            - "null"
          description: |
            Opaque cursor to pass as `before` on the next request. `null` when
            the list is exhausted. Treat it as opaque — do not parse it.

    UpdateBrandInput:
      type: object
      description: |
        Writable brand fields — provide at least one. An empty patch (or a body
        with no recognised field) returns `400`.
      minProperties: 1
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 200
          description: New brand name (1.199.0).
        type:
          type: string
          enum: [brand, client]
          description: |
            `client` = client brand (client approval stage, guests); `brand` =
            internal brand. client → internal is refused (`409`) while client
            work remains (1.199.0).
        description:
          type: ["string", "null"]
          maxLength: 5000
          description: |
            The brand's brief / guidelines text. A brand header doc card that
            still shows it (usually Guidelines) follows it until that card is
            written on its own with `PATCH /api/v1/header-cards/{cardId}`.
            Full text replace: `""` clears it, `null`
            or omitting it leaves the current text unchanged. Writing it notifies
            no one.
        socialLinks:
          description: |
            The brand's **Brand Links** card — any label, not just social
            (`Website`, `Drive`, `instagram`).

            **Full-array REPLACE**, exactly like `externalMetadata`: the list you
            send BECOMES the brand's links, so a one-entry patch WIPES the rest.
            Read `GET /api/v1/brands/{id}` first and send the merged array. Pass
            `null` (or `[]`) to clear every link.

            Each `url` is normalised the way the in-app editor normalises it:
            `http://` is upgraded to `https://`, and a bare host
            (`drive.google.com/folders/x`) gets an `https://` prefix — without
            that it would be stored as a relative link and break in the app. Max
            100 entries; `url` max 2000 chars (required, non-empty), `platform`
            max 80 chars (may be empty — the card then labels the link the way
            the app does, e.g. `IG`, `Drive` or the URL's domain, and that label
            is what later reads return as `platform`).
          oneOf:
            - type: array
              maxItems: 100
              items:
                $ref: "#/components/schemas/SocialLink"
            - type: "null"
        externalMetadata:
          description: |
            Replaces the brand's entire `externalMetadata` object (merge
            client-side before sending). Pass `null` to clear it. Must be a JSON
            object or `null` — not an array or primitive.
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"
        guestAllStagesVisible:
          type: ["boolean", "null"]
          description: |
            This brand's "Show clients every workflow stage" override: `true`
            lets the brand's clients (signed in and on its share links) see
            tasks in every non-archive stage — early-stage media as a view-only
            placeholder card, early-stage documents as `guestEarlyStageDocAccess`
            allows (at `placeholder` a signed-in client gets no document card,
            only its name in the progress tracker) — `false` keeps them on the
            client stages, `null` (the default) inherits the workspace's
            `guestAllStagesVisible` from `GET /api/v1/workspace/settings`. A
            signed-in guest the task already reaches through an assignment
            keeps the rights it had before the setting, exactly as that
            workspace setting documents. Omit
            to leave unchanged. The literal string `"inherit"` is rejected —
            inheritance is expressed as `null`. Setting `true` is plan-gated
            (403 names the plan); `false` / `null` are always accepted. Writing
            it notifies no one.
        guestEarlyStageDocAccess:
          type: ["string", "null"]
          enum: [placeholder, view, comment, edit, null]
          description: |
            This brand's early-stage DOCUMENT access while every stage is
            visible: `placeholder` | `view` | `comment` | `edit`, or `null`
            (the default) to inherit the workspace's `guestEarlyStageDocAccess`.
            Each level means exactly what the workspace setting documents
            (`GET /api/v1/workspace/settings`): `placeholder` withholds the
            document from a signed-in client's Grid, List and Board (a share
            link shows a content-free placeholder card), `view` reads, `comment`
            reads + comments, `edit` also edits inside the early editing
            stages. Media is a placeholder. A guest the task reaches through
            an assignment keeps its pre-setting rights, as the workspace
            setting documents. Omit to leave unchanged;
            anything past `placeholder` is plan-gated.
        adminApprovalMode:
          type: ["string", "null"]
          enum: ["on", "off", null]
          description: |
            This brand's override for the Admin Approval stage. On the
            **Agency + 2 approvers** workflow `"on"` forces the stage for this
            brand, `"off"` removes it, `null` inherits the workspace's
            `adminApprovalScope`. On the **Agency**, **Agency + End Client** and
            **Internal** workflows `"on"` adds the stage after Supervisor Approval
            for this brand only, and `null` / `"off"` leave it out (1.98.0). Omit
            to leave unchanged. The literal string `"inherit"` is rejected —
            inheritance is expressed as `null`.

            On the **Basic** or **Team + Manager + Admin** workflows any value,
            `null` included, is refused with `400` (since 1.199.0).
            Writing it notifies no one. When the brand loses the stage, its tasks
            in Admin Approval are moved back to Supervisor Approval first (1.199.0).

    BrandSettings:
      type: object
      description: |
        A brand's Portal Design, Guest Access and Workflow settings (1.199.0).
        `null` on an override = inherit the workspace value.
      required: [brandId, portal, guestAccess, workflow]
      additionalProperties: false
      properties:
        brandId: { type: string, format: uuid }
        portal:
          type: object
          additionalProperties: false
          required: [theme, allowedViews, allowIntake, headerCollapsed, welcomeMessage, allStagesVisible, earlyStageDocAccess, watermark, landing]
          properties:
            theme:
              type: ["string", "null"]
              enum: [light, dark, null]
              description: Client portal theme.
            allowedViews:
              type: ["array", "null"]
              items: { type: string, enum: [grid, row, kanban, calendar, analytics] }
              description: Views the brand's clients can switch between, in order. Plan-gated; `calendar` needs the content calendar.
            allowIntake:
              type: ["boolean", "null"]
              description: Clients may send work requests from the portal.
            headerCollapsed:
              type: ["boolean", "null"]
              description: The brand header starts collapsed for clients.
            welcomeMessage:
              type: ["string", "null"]
              maxLength: 280
              description: A welcome line clients see. `null` or `""` clears it.
            allStagesVisible:
              type: ["boolean", "null"]
              description: Show clients every workflow stage (view-only cards). Enabling is plan-gated.
            earlyStageDocAccess:
              type: ["string", "null"]
              enum: [placeholder, view, comment, edit, null]
              description: How far a client may go with an early-stage DOCUMENT. Past `placeholder` is plan-gated.
            watermark:
              oneOf:
                - $ref: "#/components/schemas/GuestWatermark"
                - type: "null"
            landing:
              type: ["string", "null"]
              enum: [media, firstView, client, null]
              description: >-
                "Where clients land" for this brand (1.227.0): `media` / `firstView`
                force a landing, `client` gives each client their own last choice
                even under a workspace that forces one, `null` inherits the
                workspace's `guestPortalLanding`.
        guestAccess:
          type: object
          additionalProperties: false
          required: [briefVisibility, notificationMode, tokenExpiryDays]
          properties:
            briefVisibility:
              type: string
              enum: [inherit, visible, hidden]
              description: Whether the brand's clients see task briefs.
            notificationMode:
              type: string
              enum: [regular, secure]
              description: "`secure` = links in client emails need a fresh one-time sign-in."
            tokenExpiryDays:
              type: integer
              minimum: 1
              maximum: 30
              description: How long a client's magic link stays valid.
        workflow:
          type: object
          additionalProperties: false
          required: [requirePostReview, adminApprovalMode, automationMode, guestRevertWindow, guestApprovalRevertWindow, approvalWindowMinutes, approvalReminderHours, revisionLimit, sharePassword]
          properties:
            requirePostReview:
              type: boolean
              description: "`false` lets scheduled posts under this brand skip the caption / thumbnail / schedule approval."
            adminApprovalMode:
              type: ["string", "null"]
              enum: ["on", "off", null]
              description: Per-brand Admin Approval override (see `PATCH /api/v1/brands/{id}`).
            automationMode:
              type: string
              enum: [workspace, brand, both]
              description: Which automation rules run on this brand. Changing it needs the Automations plan.
            guestRevertWindow:
              type: ["integer", "null"]
              description: Minutes a client may undo "send to revisions" (0 off, -1 forever).
            guestApprovalRevertWindow:
              type: ["integer", "null"]
              description: Minutes a client may undo an approval (0 off, -1 forever).
            approvalWindowMinutes:
              type: ["integer", "null"]
              description: |
                Client approval time window in minutes (0 = this brand opts out).
                When it ends, a task in client approval is auto-approved.
            approvalReminderHours:
              type: ["integer", "null"]
              description: Hours before the window ends that the client is reminded.
            revisionLimit:
              type: ["integer", "null"]
              minimum: 1
              maximum: 99
              description: Included revision rounds per task.
            sharePassword:
              type: object
              readOnly: true
              additionalProperties: false
              required: [mode, hasPassword]
              properties:
                mode: { type: string, enum: [inherit, "off", custom] }
                hasPassword: { type: boolean }
    GuestWatermark:
      type: object
      description: The branded "For review only" overlay on client previews.
      required: [enabled, scope, mode, text, useLogo, position, opacity, showViewer]
      properties:
        enabled: { type: boolean }
        scope: { type: string, enum: [deliverables, rawFiles, both] }
        mode: { type: string, enum: [always, untilApproved, syncWithDownload] }
        text: { type: string, maxLength: 60 }
        useLogo: { type: boolean }
        position: { type: string, enum: [center, topLeft, topRight, bottomLeft, bottomRight, tiled] }
        opacity: { type: integer, minimum: 10, maximum: 80 }
        showViewer: { type: boolean }
    BrandSettingsPatch:
      type: object
      description: Any of the GET groups, each with only the keys that change (1.199.0).
      additionalProperties: false
      minProperties: 1
      properties:
        portal:
          type: object
          additionalProperties: false
          minProperties: 1
          properties:
            theme: { type: ["string", "null"], enum: [light, dark, null] }
            allowedViews:
              type: ["array", "null"]
              items: { type: string, enum: [grid, row, kanban, calendar, analytics] }
            allowIntake: { type: ["boolean", "null"] }
            headerCollapsed: { type: ["boolean", "null"] }
            welcomeMessage: { type: ["string", "null"], maxLength: 280 }
            allStagesVisible: { type: ["boolean", "null"] }
            earlyStageDocAccess: { type: ["string", "null"], enum: [placeholder, view, comment, edit, null] }
            watermark:
              type: ["object", "null"]
              description: "A full watermark config, `{ \"enabled\": false }` to switch it off for this brand, or `null` to inherit. Enabling needs the Scale plan."
            landing: { type: ["string", "null"], enum: [media, firstView, client, null], description: "Where this brand's clients land; `null` inherits the workspace (1.227.0)." }
        guestAccess:
          type: object
          additionalProperties: false
          minProperties: 1
          properties:
            briefVisibility: { type: string, enum: [inherit, visible, hidden] }
            notificationMode: { type: string, enum: [regular, secure] }
            tokenExpiryDays: { type: integer, minimum: 1, maximum: 30 }
        workflow:
          type: object
          additionalProperties: false
          minProperties: 1
          properties:
            requirePostReview: { type: boolean }
            adminApprovalMode: { type: ["string", "null"], enum: ["on", "off", null] }
            automationMode: { type: string, enum: [workspace, brand, both] }
            guestRevertWindow: { type: ["integer", "null"] }
            guestApprovalRevertWindow: { type: ["integer", "null"] }
            approvalWindowMinutes: { type: ["integer", "null"] }
            approvalReminderHours: { type: ["integer", "null"] }
            revisionLimit: { type: ["integer", "null"], minimum: 1, maximum: 99 }
    BrandSharePasswordState:
      type: object
      description: A brand's share passcode state — never the passcode (1.199.0).
      additionalProperties: false
      required: [brandId, mode, hasPassword]
      properties:
        brandId: { type: string, format: uuid }
        mode:
          type: string
          enum: [inherit, "off", custom]
          description: "`inherit` = no brand passcode; `off` = pinned open; `custom` = the brand has its own."
        hasPassword: { type: boolean }
    BrandPackagePatch:
      type: object
      description: Kit fields to change; a list sent replaces that whole list (1.199.0).
      additionalProperties: false
      minProperties: 1
      properties:
        editDirection: { type: ["string", "null"], enum: [replicate, improve, null] }
        ctaText: { type: ["string", "null"], maxLength: 200 }
        ctaUrl: { type: ["string", "null"], maxLength: 500 }
        endCardNotes: { type: ["string", "null"], maxLength: 2000 }
        musicNotes: { type: ["string", "null"], maxLength: 2000 }
        sfxNotes: { type: ["string", "null"], maxLength: 2000 }
        colors:
          type: array
          maxItems: 24
          items:
            type: object
            required: [hex]
            properties:
              hex: { type: string, pattern: "^#[0-9A-Fa-f]{6}$" }
              name: { type: ["string", "null"], maxLength: 60 }
              role: { type: ["string", "null"], enum: [primary, secondary, accent, background, text, null] }
        assets:
          type: array
          maxItems: 100
          items:
            type: object
            required: [fileId, category]
            properties:
              fileId: { type: string, format: uuid }
              category: { type: string, enum: [logo, productImage, broll, music, sfx, endCard, overlay, look, reference, doc, other, productRecording, screenshot, photo] }
              variant: { type: ["string", "null"], maxLength: 60 }
              source: { type: string, enum: [manual, brandHeader, assetRequest] }
        fonts:
          type: array
          maxItems: 12
          items:
            type: object
            required: [family]
            properties:
              family: { type: string, maxLength: 100 }
              usage: { type: ["string", "null"], enum: [heading, body, caption, null] }
              fileId: { type: ["string", "null"], format: uuid }
              licenseStatus: { type: string, enum: [ofl, commercialOk, userAttested, unknown, restricted] }
              licenseNote: { type: ["string", "null"], maxLength: 500 }
              fallbackFamily: { type: ["string", "null"], maxLength: 100 }
    BrandKitItemResult:
      type: object
      additionalProperties: false
      required: [brandId, fileId, category, inKit]
      properties:
        brandId: { type: string, format: uuid }
        fileId: { type: string, format: uuid }
        category: { type: string }
        inKit: { type: boolean }
    NotificationChannelMap:
      type: object
      additionalProperties: false
      description: Per-channel on/off; an absent channel follows each person's own setting.
      properties:
        email: { type: boolean }
        whatsapp: { type: boolean }
        slack: { type: boolean }
    BrandNotificationRule:
      type: object
      additionalProperties: false
      required: [muted, channels, updatedAt]
      properties:
        muted: { type: ["boolean", "null"] }
        channels:
          $ref: "#/components/schemas/NotificationChannelMap"
        updatedAt: { type: string, format: date-time }
    BrandNotificationDefaults:
      type: object
      additionalProperties: false
      required: [brandId, defaults, notificationControls]
      properties:
        brandId: { type: string, format: uuid }
        defaults:
          type: object
          additionalProperties: false
          required: [member, guest]
          properties:
            member:
              oneOf:
                - $ref: "#/components/schemas/BrandNotificationRule"
                - type: "null"
            guest:
              oneOf:
                - $ref: "#/components/schemas/BrandNotificationRule"
                - type: "null"
        notificationControls:
          type: boolean
          description: Whether the plan allows SETTING a default (clearing is always free).
    BrandReportSchedule:
      type: object
      additionalProperties: false
      required: [brandId, exists, enabled, cadence, weekday, monthDay, sendTime, timeZone, recipients, optedOut, sections, design, message, nextSendAt, lastSentAt, shareUrl, hasSocial]
      properties:
        brandId: { type: string, format: uuid }
        exists: { type: boolean, description: "`false` = never saved (defaults shown)." }
        enabled: { type: boolean }
        cadence: { type: string, enum: [daily, weekly, monthly] }
        weekday: { type: integer, minimum: 0, maximum: 6, description: "0 = Sunday (weekly)." }
        monthDay: { type: integer, minimum: 1, maximum: 28 }
        sendTime: { type: string, description: "HH:MM in `timeZone`." }
        timeZone: { type: string }
        recipients:
          type: array
          items: { type: string }
        optedOut:
          type: array
          description: Addresses that unsubscribed — never mailed again.
          items: { type: string }
        sections:
          type: object
          required: [statusRecap, social]
          properties:
            statusRecap: { type: boolean }
            social: { type: boolean }
        design:
          $ref: "#/components/schemas/BrandReportDesign"
        message: { type: string }
        nextSendAt: { type: ["string", "null"], format: date-time }
        lastSentAt: { type: ["string", "null"], format: date-time }
        shareUrl: { type: ["string", "null"], description: The client link the email's buttons open. }
        hasSocial: { type: boolean }
    BrandReportScheduleInput:
      type: object
      additionalProperties: false
      properties:
        enabled: { type: boolean }
        cadence: { type: string, enum: [daily, weekly, monthly] }
        weekday: { type: integer, minimum: 0, maximum: 6 }
        monthDay: { type: integer, minimum: 1, maximum: 28 }
        sendTime: { type: string }
        timeZone: { type: string }
        recipients:
          type: array
          maxItems: 10
          items: { type: string, format: email }
        sections:
          type: object
          description: Not together with `design`.
          properties:
            statusRecap: { type: boolean }
            social: { type: boolean }
        design:
          description: |
            1.200.0. Merged per key onto the saved design; `stats` and `blocks` replace their
            whole lists. Decides the sections, so not together with `sections`.
          type: object
          additionalProperties: false
          properties:
            theme: { type: string, enum: [light, dark] }
            header: { type: string, enum: [accent, minimal] }
            accentColor: { type: ["string", "null"], pattern: "^#[0-9a-fA-F]{6}$" }
            title: { type: string, maxLength: 80 }
            stats:
              type: array
              maxItems: 6
              uniqueItems: true
              items: { $ref: "#/components/schemas/BrandReportStat" }
            blocks:
              type: array
              uniqueItems: true
              items: { $ref: "#/components/schemas/BrandReportBlock" }
        message: { type: string, maxLength: 1000 }
    BrandReportStat:
      type: string
      enum: [finished, awaitingReview, inProduction, approved, posted, posts, views, engagement]
      description: |
        A headline number. `finished` = finished in the period; `awaitingReview` = waiting for the
        client's review now; `inProduction` / `approved` / `posted` = how many sit there now;
        `posts` / `views` / `engagement` = social results with the change against the previous
        period (need posting).
    BrandReportBlock:
      type: string
      enum: [highlights, awaitingReview, finished, pipeline, topPosts]
      description: |
        A section. `highlights` = the headline numbers; `awaitingReview` / `finished` = the task
        lists; `pipeline` = the where-everything-stands chart; `topPosts` = the top posts chart
        (covers, platform badges, links to the live posts; needs posting).
    BrandReportDesign:
      type: object
      additionalProperties: false
      required: [theme, header, accentColor, title, stats, blocks]
      description: |
        1.200.0. How the report email looks and what it shows. A schedule saved before designs
        existed reads back the default design for its sections.
      properties:
        theme: { type: string, enum: [light, dark] }
        header: { type: string, enum: [accent, minimal], description: "`accent` = a brand-colour header card." }
        accentColor:
          type: ["string", "null"]
          description: "`#rrggbb`; `null` = the workspace's client portal colour."
        title: { type: string, description: "`\"\"` = the default (\"Your weekly report\" by cadence)." }
        stats:
          type: array
          description: The headline numbers, in order (at most 6).
          items: { $ref: "#/components/schemas/BrandReportStat" }
        blocks:
          type: array
          description: The sections, in order.
          items: { $ref: "#/components/schemas/BrandReportBlock" }
    BrandRetainer:
      type: object
      additionalProperties: false
      required: [brandId, currentMonthlyAmount, currency, schedule]
      properties:
        brandId: { type: string, format: uuid }
        currentMonthlyAmount: { type: ["number", "null"], description: "In effect this month; `null` = no retainer." }
        currency: { type: ["string", "null"], description: "`null` = the workspace currency." }
        schedule:
          type: array
          items:
            type: object
            additionalProperties: false
            required: [effectiveMonth, monthlyAmount, currency]
            properties:
              effectiveMonth: { type: string, description: YYYY-MM-01 }
              monthlyAmount: { type: ["number", "null"], description: "`null` ends the retainer from this month." }
              currency: { type: ["string", "null"] }
    BrandCharge:
      type: object
      additionalProperties: false
      required: [id, brandId, label, amount, currency, chargeDate, projectId, paid, createdAt, updatedAt]
      properties:
        id: { type: string, format: uuid }
        brandId: { type: string, format: uuid }
        label: { type: ["string", "null"] }
        amount: { type: number }
        currency: { type: ["string", "null"] }
        chargeDate: { type: ["string", "null"], description: YYYY-MM-DD }
        projectId: { type: ["string", "null"], format: uuid }
        paid: { type: boolean, description: Received in full. }
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }
    BrandChargeInput:
      type: object
      additionalProperties: false
      required: [label, amount, chargeDate]
      properties:
        label: { type: string, maxLength: 120 }
        amount: { type: number, exclusiveMinimum: 0 }
        chargeDate: { type: string, description: YYYY-MM-DD }
        projectId: { type: ["string", "null"], format: uuid }
    BrandChargePatch:
      type: object
      additionalProperties: false
      minProperties: 1
      properties:
        label: { type: string, maxLength: 120 }
        amount: { type: number, exclusiveMinimum: 0 }
        chargeDate: { type: string, description: YYYY-MM-DD }
        projectId: { type: ["string", "null"], format: uuid }
    BrandConnectInvite:
      type: object
      additionalProperties: false
      required: [id, brandId, url, platforms, expiresAt, active, usedAt, createdAt]
      properties:
        id: { type: string, format: uuid }
        brandId: { type: string, format: uuid }
        url: { type: string, description: The no-login link to send the client — a credential. }
        platforms:
          type: array
          items: { type: string }
          description: Empty = any channel.
        expiresAt: { type: string, format: date-time }
        active: { type: boolean, description: "`false` once revoked." }
        usedAt: { type: ["string", "null"], format: date-time }
        createdAt: { type: string, format: date-time }
    BrandCopywriting:
      type: object
      required: [nodeId, sections, candidates, voice]
      properties:
        nodeId: { type: string, format: uuid }
        sections:
          type: object
          required: [editing, briefing, captions]
          properties:
            editing: { type: array, items: { $ref: "#/components/schemas/BrandCopywritingRule" } }
            briefing: { type: array, items: { $ref: "#/components/schemas/BrandCopywritingRule" } }
            captions: { type: array, items: { $ref: "#/components/schemas/BrandCopywritingRule" } }
        candidates:
          type: array
          items:
            allOf:
              - $ref: "#/components/schemas/BrandCopywritingRule"
              - type: object
                required: [seenOn]
                properties:
                  seenOn: { type: integer, description: Distinct videos its evidence rests on. }
        voice:
          type: object
          required: [instructions, corrections]
          properties:
            instructions: { type: string }
            corrections:
              type: array
              items:
                type: object
                required: [id, instruction, createdAt]
                properties:
                  id: { type: string }
                  instruction: { type: string }
                  createdAt: { type: string, format: date-time }
    BrandCopywritingRule:
      type: object
      required: [id, topic, text, origin, updatedAt]
      properties:
        id: { type: string, format: uuid }
        topic: { type: string, enum: [editing, briefing, captions] }
        text: { type: string }
        origin: { type: string, description: Who wrote it — a person (`human`) or a learning pass. }
        updatedAt: { type: string, format: date-time }
    BrandInspirationPin:
      type: object
      required: [id]
      properties:
        id: { type: string, format: uuid }
        polarity: { type: string, enum: [good, bad] }
        title: { type: string }
        why: { type: string }
        taskId: { type: ["string", "null"], format: uuid }
        url: { type: ["string", "null"] }
        createdAt: { type: string, format: date-time }
        fileId:
          type: ["string", "null"]
          format: uuid
          description: A task example's video (its current file); null for a link. New in 1.201.0.
        statusGroup:
          type: ["string", "null"]
          description: A task example's status column; null for a link. New in 1.201.0.
        brandName:
          type: ["string", "null"]
          description: The brand a task example belongs to; null for a link. New in 1.201.0.
        ownBrand:
          type: boolean
          description: A task example of THIS brand (listed and studied first). New in 1.201.0.
    BrandInspiration:
      type: object
      required: [brandId, pinned, firstPass, cameBack, repeated]
      properties:
        brandId: { type: string, format: uuid }
        pinned:
          type: array
          items: { $ref: "#/components/schemas/BrandInspirationPin" }
        firstPass:
          type: array
          description: The brand's edits approved the first time.
          items: { $ref: "#/components/schemas/BrandEditOutcome" }
        cameBack:
          type: array
          description: The brand's edits that came back for revisions.
          items: { $ref: "#/components/schemas/BrandEditOutcome" }
        repeated:
          type: array
          description: Revision rules the brand's history keeps repeating.
          items:
            type: object
            required: [id, text, tasks, status]
            properties:
              id: { type: string, format: uuid }
              text: { type: string }
              tasks: { type: integer }
              status: { type: string, enum: [active, candidate] }
    BrandEditOutcome:
      type: object
      required: [taskId, title, cameBack, notes]
      properties:
        taskId: { type: string, format: uuid }
        title: { type: string }
        fileId: { type: ["string", "null"], format: uuid }
        approvedAt: { type: ["string", "null"], format: date-time }
        seconds: { type: ["number", "null"] }
        cameBack: { type: integer, description: Revision rounds it came back for. }
        byRonald: { type: boolean, description: Edited by the Timeliner AI editor. }
        notes:
          type: array
          items: { type: string }
    BrandBrainFacts:
      type: object
      description: What the AI check reviews the brand's videos against (1.199.0).
      required: [nodeId, nodeName, inheritedFromNodeId, inheritedFromNodeName, facts, suppressions]
      properties:
        nodeId: { type: string, format: uuid }
        nodeName: { type: string }
        inheritedFromNodeId: { type: ["string", "null"], format: uuid }
        inheritedFromNodeName: { type: ["string", "null"] }
        facts:
          type: array
          items:
            type: object
            additionalProperties: true
            required: [id, kind, text]
            properties:
              id: { type: string, format: uuid }
              kind: { type: string }
              text: { type: string }
        suppressions:
          type: array
          description: Checks switched off for this brand — restore one with `POST …/brain-facts/{factId}/restore`.
          items:
            type: object
            additionalProperties: true
            required: [id]
            properties:
              id: { type: string, format: uuid }
        hiddenExemplarCount: { type: integer }
        seededCount: { type: integer }
    ThumbnailRequest:
      type: object
      description: What an AI thumbnail run should make. Every field is optional — omitted fields take the composer's defaults.
      properties:
        platform: { type: string, enum: [youtube, instagram, facebook, linkedin], description: Sets the default shape. }
        youtubeShorts: { type: boolean, description: "platform youtube: a Short (9:16)." }
        instagramFormat: { type: string, enum: [feed, reels], description: "platform instagram: feed (4:5) or reels (9:16, the default)." }
        aspectRatio: { type: string, enum: ["16:9", "9:16", "1:1", "4:5"] }
        model:
          type: string
          enum: [gpt-image-2, gpt-image-2.6-flare, nano-banana-2, nano-banana-2.1, nano-banana-pro]
          description: Omit to let Timeliner choose. GPT models render on-image text; Nano Banana models make every shape but are weak at text.
        resolution: { type: string, enum: [1K, 2K, 4K] }
        quality: { type: string, enum: [low, medium, high], description: GPT models only. }
        variants: { type: integer, minimum: 1, maximum: 4, description: Versions (default 2). Each version is charged. }
        archetype: { type: string, description: A layout id (faceBigText, beforeAfter, objectArrow, reactionScreenshot, versus, numberedList, tutorialProduct, podcastTwoFaces, curiosityGap, progression, cleanMinimal). }
        hookText: { type: string, maxLength: 60, description: Text on the thumbnail — 4 words or fewer. Omit to let the AI suggest one. }
        instructions: { type: string, maxLength: 500 }
        speakerIds: { type: array, maxItems: 2, items: { type: string, format: uuid } }
        references:
          type: array
          maxItems: 4
          items:
            type: object
            required: [kind, id]
            properties:
              kind: { type: string, enum: [upload, brandFile, pastVariant, brandStyle] }
              id: { type: string, format: uuid }
        keyFrameMs: { type: integer, minimum: 0, description: A moment of the video to include. }
        brandPalette: { type: boolean }
        includeLogo: { type: boolean }
        idempotencyKey: { type: string, format: uuid }
        wait: { type: boolean }
    ThumbnailQuote:
      type: object
      required: [model, modelLabel, aspectRatio, resolution, quality, versions, creditsPerVersion, totalCredits, charged, models]
      properties:
        model: { type: string }
        modelLabel: { type: string }
        aspectRatio: { type: string }
        resolution: { type: string }
        quality: { type: ["string", "null"] }
        versions: { type: integer }
        creditsPerVersion: { type: integer }
        totalCredits: { type: integer }
        charged: { type: boolean, description: "`false` while the workspace is not charged for AI work." }
        models:
          type: array
          items:
            type: object
            required: [id, label, creditsPerVersion, rendersText]
            properties:
              id: { type: string }
              label: { type: string }
              creditsPerVersion: { type: ["integer", "null"], description: "`null` = this model cannot make the shape." }
              rendersText: { type: boolean }
    ThumbnailVersion:
      type: object
      required: [id, index, state, failure, textOverlay, layout, width, height, imageUrl, previewUrl, feedback, selectedFor, purgedAt]
      properties:
        id: { type: string, format: uuid }
        index: { type: integer }
        state: { type: string, enum: [rendering, ready, failed, cancelled] }
        failure: { type: ["string", "null"], enum: [contentRefused, vendorError, timeout, storeFailed, null] }
        textOverlay: { type: ["string", "null"] }
        layout: { type: ["string", "null"] }
        width: { type: ["integer", "null"] }
        height: { type: ["integer", "null"] }
        imageUrl: { type: ["string", "null"], description: "Signed full-resolution URL, valid 10 minutes. `null` until the version is ready, and while `purgedAt` is set." }
        previewUrl: { type: ["string", "null"], description: "Signed 640 px preview URL, valid 10 minutes. `null` like `imageUrl`." }
        feedback: { type: ["string", "null"] }
        selectedFor:
          type: array
          items:
            type: object
            required: [platform, slotId]
            properties:
              platform: { type: string }
              slotId: { type: ["string", "null"], description: YouTube slot letter (a/b/c). }
        purgedAt:
          type: ["string", "null"]
          format: date-time
          description: |
            When the version's image was removed after the workspace's
            subscription ended (1.216.0); `null` while it is there. While it is
            set the version has no image URLs and cannot be selected. Paying
            again before the permanent deletion clears it.
    ThumbnailGeneration:
      type: object
      required: [id, postId, status, platform, aspectRatio, model, resolution, quality, layout, hookText, estimateCredits, chargedCredits, createdAt, finishedAt, error, versions]
      properties:
        id: { type: string, format: uuid }
        postId: { type: string, format: uuid }
        status: { type: string, enum: [queued, directing, generating, ready, partial, failed, cancelled] }
        platform: { type: ["string", "null"] }
        aspectRatio: { type: string }
        model: { type: string }
        resolution: { type: string }
        quality: { type: ["string", "null"] }
        layout: { type: ["string", "null"] }
        hookText: { type: ["string", "null"] }
        estimateCredits: { type: integer }
        chargedCredits: { type: ["integer", "null"] }
        createdAt: { type: string, format: date-time }
        finishedAt: { type: ["string", "null"], format: date-time }
        error: { type: ["string", "null"] }
        versions: { type: array, items: { $ref: "#/components/schemas/ThumbnailVersion" } }
    BrandSpeaker:
      type: object
      required: [id, brandId, handle, displayName, description, photoCount, likeness, usable, usedCount, consent, purgedAt, createdAt]
      properties:
        id: { type: string, format: uuid }
        brandId: { type: string, format: uuid }
        handle: { type: string }
        displayName: { type: string }
        description: { type: ["string", "null"] }
        photoCount: { type: integer }
        likeness: { type: string, enum: [none, syncing, ready, failed] }
        usable: { type: boolean, description: "Consent on file, not withdrawn, at least one photo, and its photos not removed (`purgedAt` null)." }
        usedCount: { type: integer }
        consent:
          type: object
          required: [subjectName, method, consentedAt, revokedAt]
          properties:
            subjectName: { type: string }
            method: { type: string, enum: [writtenOnFile, inAppAttestation] }
            consentedAt: { type: string, format: date-time }
            revokedAt: { type: ["string", "null"], format: date-time }
        purgedAt:
          type: ["string", "null"]
          format: date-time
          description: |
            When the speaker's photos were removed after the workspace's
            subscription ended (1.216.0); `null` while they are there. While it
            is set the speaker is not `usable` and `PATCH` takes only
            `revokeConsent: true`. Paying again before the permanent deletion
            clears it; after it the speaker is gone and must be added again,
            with the person's permission.
        createdAt: { type: string, format: date-time }
    BrandThumbnailPreferences:
      type: object
      required: [palette, customColors, textStyle, favouriteArchetypes, doNotes, dontNotes, referenceCount, removedReferenceCount]
      properties:
        palette: { type: string, enum: [brandKit, auto, custom] }
        customColors: { type: array, items: { type: string } }
        textStyle: { type: string, enum: [boldCaps, titleCase, none] }
        favouriteArchetypes: { type: array, items: { type: string } }
        doNotes: { type: array, items: { type: string } }
        dontNotes: { type: array, items: { type: string } }
        referenceCount: { type: integer, description: Every reference thumbnail the brand holds (managed in the app), removed ones included. }
        removedReferenceCount:
          type: integer
          description: |
            How many of `referenceCount` were removed after the workspace's
            subscription ended (1.216.0). They come back if the workspace pays
            again before their permanent deletion.
    BrandThumbnailStyle:
      type: object
      required: [preferences, learnedNotes]
      properties:
        preferences: { $ref: "#/components/schemas/BrandThumbnailPreferences" }
        learnedNotes:
          type: array
          items:
            type: object
            required: [id, text, createdAt, permanent]
            properties:
              id: { type: string }
              text: { type: string }
              createdAt: { type: string, format: date-time }
              permanent: { type: boolean }
    TimeEntry:
      type: object
      description: |
        One time entry (1.207.0) — a row of `GET /api/v1/time-entries` and the
        `data` of `time_entry.created` / `time_entry.updated`. No money fields.
      required: [id, taskId, taskTitle, projectId, projectName, brandId, brandName, memberId, source, startedAt, endedAt, durationSeconds, running, note, createdAt, updatedAt, deleted, deletedAt]
      properties:
        id:
          type: string
          format: uuid
        taskId:
          type: string
          format: uuid
        taskTitle:
          type:
            - string
            - "null"
        projectId:
          type:
            - string
            - "null"
          format: uuid
        projectName:
          type:
            - string
            - "null"
        brandId:
          type:
            - string
            - "null"
          format: uuid
          description: The brand the task's project sits directly under.
        brandName:
          type:
            - string
            - "null"
        memberId:
          type: string
          format: uuid
          description: The workspace member who tracked the time.
        source:
          type: string
          enum: [timer, manual]
        startedAt:
          type: string
          format: date-time
          description: For a running timer, the latest start or resume.
        endedAt:
          type:
            - string
            - "null"
          format: date-time
          description: Null while the timer is running.
        durationSeconds:
          type: integer
          minimum: 0
          description: |
            Committed seconds. For a running timer, the time saved before the
            current run (which started at `startedAt`).
        running:
          type: boolean
        note:
          type:
            - string
            - "null"
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
          description: Last change. Entries from before 1.207.0 carry that release time.
        deleted:
          type: boolean
          const: false
        deletedAt:
          type: "null"
    DeletedTimeEntry:
      type: object
      description: |
        A deleted time entry (1.207.0) — an `includeDeleted=true` row of
        `GET /api/v1/time-entries` and the `data` of `time_entry.deleted`.
      required: [id, taskId, projectId, brandId, memberId, deleted, deletedAt]
      properties:
        id:
          type: string
          format: uuid
          description: The deleted entry's id.
        taskId:
          type: string
          format: uuid
        projectId:
          type:
            - string
            - "null"
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        memberId:
          type:
            - string
            - "null"
          format: uuid
        deleted:
          type: boolean
          const: true
        deletedAt:
          type: string
          format: date-time
    TimeEntriesPage:
      type: object
      description: One page of `GET /api/v1/time-entries` (1.207.0).
      required: [data, nextCursor, hasMore]
      properties:
        data:
          type: array
          description: Rows by last change, OLDEST first (then by id).
          items:
            oneOf:
              - $ref: "#/components/schemas/TimeEntry"
              - $ref: "#/components/schemas/DeletedTimeEntry"
        nextCursor:
          type:
            - string
            - "null"
          description: |
            Pass back as `cursor` to continue right after the last row in
            `data`. Echoes the request's `cursor` when nothing changed; `null`
            only when there was neither a row nor a cursor.
        hasMore:
          type: boolean
          description: True when more rows already exist after this page.
    TimeEntryCreatedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: time_entry.created
            data:
              $ref: "#/components/schemas/TimeEntry"
    TimeEntryUpdatedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: time_entry.updated
            data:
              $ref: "#/components/schemas/TimeEntry"
    TimeEntryDeletedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: time_entry.deleted
            data:
              $ref: "#/components/schemas/DeletedTimeEntry"
    RecentEventsPage:
      type: object
      description: One page of `GET /api/v1/tasks/events` (1.133.0).
      required: [data, nextCursor, hasMore]
      properties:
        data:
          type: array
          description: The events, OLDEST first — each the webhook envelope of that event.
          items:
            oneOf:
              - $ref: "#/components/schemas/VersionUploadedDataEvent"
              - $ref: "#/components/schemas/CommentCreatedDataEvent"
              - $ref: "#/components/schemas/TaskCompletedEvent"
        nextCursor:
          type:
            - string
            - "null"
          description: |
            Pass back as `cursor` to continue right after the last event in
            `data` — now (when `hasMore`) or on your next scheduled check. Echoes
            the request's `cursor` when nothing new arrived; `null` only when
            there was neither an event nor a cursor.
        hasMore:
          type: boolean
          description: "`true` when more events already exist after this page."

    ActivityEntryList:
      type: object
      required: [data, hasMore]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ActivityEntry"
          description: The entries, OLDEST first.
        hasMore:
          type: boolean
          description: |
            `true` when the task has OLDER entries than this window covers. Page
            back by re-requesting with `to=` the oldest `createdAt` returned.

    ActivityEntry:
      type: object
      description: One event in a task's history.
      required: [id, createdAt, action, isSystem, source]
      properties:
        id:
          type: string
          description: |
            Opaque entry id. Most are UUIDs; an entry read from the task's change
            history reads `th-<number>` (since 1.215.0). Treat it as an opaque
            string.
        createdAt:
          type: string
          format: date-time
          description: When the event happened — subtract consecutive ones for durations.
        action:
          type: string
          description: |
            The kind of event. `changed` (since 1.215.0) is a field change —
            `field`, `oldValue` and `newValue` say which and how.
          enum:
            [
              viewed,
              downloaded,
              deleted,
              created,
              newVersion,
              moved,
              commented,
              discussed,
              captionEditedAfterApproval,
              settingsChanged,
              postTextEdited,
              restored,
              permanentlyDeleted,
              postScheduleChanged,
              commentDeleted,
              changed,
            ]
        isSystem:
          type: boolean
          description: True when the platform made the move, not a person (then `actor` is null).
        source:
          type: ["string", "null"]
          enum: [app, api, mcp, automation, share, cron, system, null]
          description: |
            Which door the event came through (since 1.215.0): `app` = in the
            Timeliner app, `api` = this API, `mcp` = an AI assistant through the
            Timeliner MCP server, `automation` = a workspace automation (no
            `actor`), `share` = a share-link guest, `cron` / `system` = the
            platform. `null` = not recorded (views, comments, downloads…).
        field:
          type: ["string", "null"]
          enum:
            [
              title,
              assigneeIds,
              internalDeadline,
              externalDeadline,
              startDate,
              clientPrice,
              teamPay,
              pricingTemplateId,
              projectId,
              subFolderId,
              archived,
              customColumn,
              riskDecision,
              null,
            ]
          description: |
            On a `changed` entry, the task field that changed; `null` otherwise.
            `clientPrice`, `teamPay` and `pricingTemplateId` appear only for a key
            with `read:finance`.
        columnId:
          type: ["string", "null"]
          format: uuid
          description: On a `customColumn` change, the custom column (see `GET /api/v1/custom-columns`).
        oldValue:
          description: |
            On a `changed` entry, the value before (`null` = it was empty). Its
            shape follows `field`: a string for `title`, the deadlines and
            `pricingTemplateId`; an array of member ids for `assigneeIds`; a
            number for `clientPrice` / `teamPay`; `{ id, name }` for `projectId`
            / `subFolderId`; a boolean for `archived`; the cell (`text`, `date`,
            `optionId`, `tagIds`, …) for `customColumn`; `{ decision, subject }`
            for `riskDecision`. `null` on every other action.
        newValue:
          description: On a `changed` entry, the value after — same shape as `oldValue`.
        targetName:
          type: ["string", "null"]
          description: Name of the thing acted on, as it read at the time.
        movedFrom:
          type: ["string", "null"]
          description: |
            Status label the task moved OUT of, as it read at the time. `null`
            unless `action` is `moved` (and on entries older than status
            history). Display this; match on `movedFromStatusKey`.
        movedFromStatusKey:
          type: ["string", "null"]
          description: |
            Stable key of the origin status — rename-proof, so this is what a
            report should key on.
        movedTo:
          type: ["string", "null"]
          description: Status label the task moved INTO, as it read at the time.
        movedToStatusKey:
          type: ["string", "null"]
          description: Stable key of the destination status.
        taskId:
          type: ["string", "null"]
          format: uuid
        projectId:
          type: ["string", "null"]
          format: uuid
        projectName:
          type: ["string", "null"]
        brandId:
          type: ["string", "null"]
          format: uuid
        brandName:
          type: ["string", "null"]
        fileId:
          type: ["string", "null"]
          format: uuid
          description: The file involved, when the event was about one.
        actor:
          description: |
            Who did it. `null` on system events and once that person's account
            has been deleted — the event itself is kept either way.
          oneOf:
            - $ref: "#/components/schemas/ActivityActor"
            - type: "null"

    ActivityActor:
      type: object
      required: [id]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: ["string", "null"]
        email:
          type: ["string", "null"]
        picture:
          type: ["string", "null"]
        role:
          type: ["string", "null"]
          description: |
            The workspace role this person held **when they acted** — a snapshot,
            not their role today. `null` on older entries and on entries read
            from the task's change history (`id` starting `th-`).
        subRole:
          type: ["string", "null"]
          description: Their editor specialty label at the time, if any.

    SocialLink:
      type: object
      description: |
        A named link on the brand. Despite the name, this is **not** restricted
        to social networks — `platform` is a free-form label, so it doubles as a
        generic link list (website, drive folder, brand guidelines, etc.). This
        is the same data the in-app "Brand Links" card edits.
      required: [platform, url]
      properties:
        platform:
          type: string
          description: |
            Free-form label for the link — a social platform (`instagram`,
            `tiktok`, `youtube`, …) **or** any other label (`Website`, `Drive`,
            `Brand guidelines`). Known social platforms get an auto-detected icon
            in the app.
        url:
          type: string
          format: uri

    CreateBrandInput:
      type: object
      required: [name]
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 120
        type:
          type: string
          enum: [brand, client]
          default: brand
          description: Node type to create. Defaults to `brand`. Always created at the top level.
        description:
          type:
            - string
            - "null"
          maxLength: 5000
        language:
          type:
            - string
            - "null"
          description: BCP-47 language code for the brand.
        picture:
          type:
            - string
            - "null"
          description: Logo / avatar URL, if you host one externally.
        socialLinks:
          type: array
          items:
            $ref: "#/components/schemas/SocialLink"
          description: |
            Named links to attach — any label, not just social (e.g. `Website`,
            `Drive`, `instagram`). Empty if omitted. Written into the new brand's
            **Brand Links** header card (1.98.1), so they show in the app on
            first open.
        externalMetadata:
          description: |
            Arbitrary JSON to store on the brand — any custom fields you need
            (CRM ids, notes, integration config). Namespace by integration,
            e.g. `{ "metricool": { "blogId": "…" }, "crm": { "accountId": "A-123" } }`.
          oneOf:
            - type: object
              additionalProperties: true
            - type: "null"

    PaymentRecordedData:
      type: object
      required: [paymentId, direction, amount, paidAt, settlement]
      properties:
        paymentId: { type: string, format: uuid }
        direction: { type: string, enum: [in, out] }
        amount: { type: number }
        currency: { type: ["string", "null"] }
        paidAt:
          type: string
          format: date-time
          description: Business date (backdateable) — when the money actually moved.
        memberId: { type: ["string", "null"], format: uuid }
        brandId: { type: ["string", "null"], format: uuid }
        projectId: { type: ["string", "null"], format: uuid }
        taskId: { type: ["string", "null"], format: uuid }
        method: { type: ["string", "null"] }
        settlement:
          type: boolean
          description: True when the entry settles a specific owed row (mark-paid flows).

    PaymentRecordedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: payment.recorded
            data:
              $ref: "#/components/schemas/PaymentRecordedData"

    PaymentVoidedData:
      type: object
      required: [paymentId, reversalId, direction, amount, paidAt, settlement]
      properties:
        paymentId:
          type: string
          format: uuid
          description: The ORIGINAL payment that was cancelled.
        reversalId:
          type: string
          format: uuid
          description: The reversal row that cancels it.
        direction: { type: string, enum: [in, out] }
        amount: { type: number }
        currency: { type: ["string", "null"] }
        memberId: { type: ["string", "null"], format: uuid }
        brandId: { type: ["string", "null"], format: uuid }
        projectId:
          type: ["string", "null"]
          format: uuid
          description: Scope of the ORIGINAL payment (added 1.77.0) — the same fields `payment.recorded` carries, so a mirror can un-post the row to the right project/task without a follow-up read.
        taskId: { type: ["string", "null"], format: uuid }
        paidAt:
          type: string
          format: date-time
          description: Business date of the ORIGINAL payment (the reversal itself is dated now).
        settlement:
          type: boolean
          description: True when the voided row settled a specific owed row (a mark-paid or partial payment); false for a free-form record_payment entry.

    PaymentVoidedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: payment.voided
            data:
              $ref: "#/components/schemas/PaymentVoidedData"

    ApiKeyInfo:
      type: object
      required: [id, name, prefix, workspaceId, scopes, expiresAt, rateLimit, createdAt, lastUsedAt]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        prefix:
          type: string
          description: The visible portion of the key (`tlsk_xxxxxxxx`), never the secret.
        workspaceId:
          type: string
          format: uuid
        scopes:
          type: array
          items:
            $ref: "#/components/schemas/ApiKeyScope"
          description: Every scope the key holds. `write:<resource>` implies `read:<resource>`.
        expiresAt:
          type:
            - string
            - "null"
          format: date-time
          description: When the key stops working; null = never.
        rateLimit:
          type: object
          required: [perMinute, windowSeconds]
          properties:
            perMinute:
              type: integer
            windowSeconds:
              type: integer
        createdAt:
          type: string
          format: date-time
        lastUsedAt:
          type:
            - string
            - "null"
          format: date-time

    ApiKeyScope:
      type: string
      enum:
        - read:tasks
        - write:tasks
        - read:projects
        - write:projects
        - read:files
        - write:files
        - read:posts
        - write:posts
        - read:chat
        - write:chat
        - read:finance
        - write:finance
        - read:automations
        - write:automations
        - read:workspace
        - write:workspace
        - read:hq
        - write:hq
        - read:webhooks
        - write:webhooks
      description: |
        Resources: `tasks` (tasks, comments, custom columns, docs, doc attachments),
        `projects` (projects, brands, brand members, header cards), `files`
        (uploads, downloads, storage), `posts` (posts, channels, social analytics, content insights, platform guidance),
        `chat` (channels, messages, task chat), `finance` (pricing, payments,
        project P&L and billing, the credits balance), `automations` (automations, rules, intake forms),
        `workspace` (workspace, settings, members, analytics, workload), `hq`
        (HQ boards) and `webhooks`.

    WebhookTestRequest:
      type: object
      properties:
        eventType:
          $ref: "#/components/schemas/WebhookEventType"
          description: Which subscribed event to sample. Defaults to the subscription's first event.

    WebhookTestResult:
      type: object
      required: [ok, eventType, statusCode, durationMs, error, deliveryId, sentAt]
      properties:
        ok:
          type: boolean
          description: True when the endpoint answered 2xx.
        eventType:
          $ref: "#/components/schemas/WebhookEventType"
        statusCode:
          type:
            - integer
            - "null"
          description: The endpoint's HTTP status, or null when no response arrived (timeout, DNS, TLS).
        durationMs:
          type: integer
        error:
          type:
            - string
            - "null"
          enum: [timeout, refused, non2xx, blocked, null]
          description: >-
            Coarse failure reason, or null on success. Deliberately a closed set
            rather than the transport message: this endpoint POSTs to an
            arbitrary URL, so a verbatim error would let a caller distinguish a
            live internal host from a dead one. `blocked` means the stored URL
            failed Timeliner's outbound policy (non-https or a private/link-local
            host), or its host resolved only to private or internal addresses,
            and no connection was made; `non2xx` means the endpoint answered
            with a non-2xx status (including a 3xx, which is never followed).
        deliveryId:
          type: string
          format: uuid
          description: The `X-Timeliner-Delivery` header value that was sent.
        sentAt:
          type: string
          format: date-time

    WebhookDeliveryLogItem:
      type: object
      required: [id, eventId, eventType, status, attemptCount, nextAttemptAt, lastStatusCode, lastError, createdAt, deliveredAt, isTest]
      properties:
        id:
          type: string
          format: uuid
        eventId:
          type: string
          format: uuid
          description: The envelope `id` your endpoint received (or will receive).
        eventType:
          type: string
        status:
          type: string
          enum: [pending, delivered, failed, dead]
        attemptCount:
          type: integer
        nextAttemptAt:
          type:
            - string
            - "null"
          format: date-time
        lastStatusCode:
          type:
            - integer
            - "null"
        lastError:
          type:
            - string
            - "null"
          description: >-
            Why the last attempt failed, or null. A fixed wording, never the
            network's own error text: `HTTP <status>`, `HTTP <status> (redirect
            not followed)`, `Timed out after <n>s`, `blocked` (the URL failed the
            outbound policy, or its host resolved only to private or internal
            addresses, so nothing was sent), `fetch failed` (any other failure
            without a response — connection refused, DNS, TLS), `signing failed`,
            `subscription disabled`, or `expired: event older than <n>h`.
        createdAt:
          type: string
          format: date-time
        deliveredAt:
          type:
            - string
            - "null"
          format: date-time
        isTest:
          type: boolean
          description: >-
            True when this row is a "Send test event" sample rather than a real
            change. A test is attempted exactly once and never retried, so its
            `status` is terminal (`delivered` or `dead`) from the moment it is
            written.

    StartUploadRequest:
      type: object
      required: [fileName, size]
      properties:
        fileName:
          type: string
          description: File name with extension, e.g. `hero_cut_v3.mp4`. A name already used in the project gets a ` (1)` suffix.
        size:
          type: integer
          minimum: 1
          description: >-
            The file's EXACT size in bytes, as the file system reports it —
            never a rounded figure such as 143000000 for "143 MB". Completing
            refuses a video upload whose parts hold fewer bytes than this.
        mimeType:
          type: string
          description: MIME type; inferred from the name when omitted.
        parts:
          type: integer
          minimum: 1
          maximum: 10000
          description: >-
            How many parts you will PUT. Omit to use the server's
            recommendation. Either way the answer's `partBytes` is the exact
            size of every part but the last; a count no equal size of at least
            5 MiB can fill is refused (since 1.214.0).
        projectId:
          type: string
          format: uuid
          description: >-
            Destination project for a raw project file. The project's own id,
            all 36 characters — never a task, sub-folder, brand, folder, HQ item
            or file id (a miss names which, see 404).
        taskId:
          type: string
          format: uuid
          description: Destination task when the file is its new version (the project is derived), or — with `target` — goes on its Project files tab.
        target:
          $ref: "#/components/schemas/TaskUploadTarget"

    UploadPartUrl:
      type: object
      required: [partNumber, url]
      properties:
        partNumber:
          type: integer
        url:
          type: string
          format: uri
          description: Presigned `PUT` URL for this part's bytes.

    StartedUpload:
      type: object
      required: [id, key, multipartUploadId, name, mimeType, size, projectId, parts, partUrlsExpireAt, recommendedPartBytes, minPartBytes, partsTotal, partBytes]
      properties:
        id:
          type: string
          format: uuid
          description: The upload id — pass it to complete / part-urls / abort. Also the resulting file's id.
        key:
          type: string
          description: Storage object key (informational).
        multipartUploadId:
          type: string
          description: Storage multipart id (informational).
        name:
          type: string
          description: The stored filename, after de-duplication.
        mimeType:
          type: string
        size:
          type: integer
        projectId:
          type: string
          format: uuid
        parts:
          type: array
          items:
            $ref: "#/components/schemas/UploadPartUrl"
        partUrlsExpireAt:
          type: string
          format: date-time
        recommendedPartBytes:
          type: integer
        minPartBytes:
          type: integer
          description: Every part except the last must be at least this many bytes.
        partsTotal:
          type: integer
          minimum: 1
          description: >-
            The number of parts this upload was opened with — the `parts` you
            sent, or the server's count from `size` (since 1.214.0).
        partBytes:
          type: integer
          minimum: 1
          description: >-
            The exact byte count of every part except the last — cut the file
            back to back at this size, the last part the rest (since 1.214.0).
            With `parts` sent it is the equal size that fits that count; with
            `parts` omitted, the recommended 64 MiB.

    CompleteUploadRequest:
      type: object
      required: [parts]
      properties:
        parts:
          type: array
          items:
            type: object
            required: [partNumber, etag]
            properties:
              partNumber:
                type: integer
                minimum: 1
              etag:
                type: string
                description: The `ETag` response header of that part's PUT.
        taskId:
          type: string
          format: uuid
          description: Attach as this task's new version (or, with `target`, put it on its Project files tab). Must belong to the upload's project.
        folderId:
          type: string
          format: uuid
          description: >-
            Project-file folder: a folder of the upload's own project,
            `folders[].id` from `GET /api/v1/projects/{id}/files`, all 36
            characters — never a brand header's folder, another project's folder,
            a sidebar folder or a sub-folder of tasks (a miss names which, see
            404). To put the file in a brand's or another project's folder,
            complete without it, then `POST /api/v1/files/{id}/move`. Never
            together with `taskId`.
        target:
          $ref: "#/components/schemas/TaskUploadTarget"

    RefreshPartUrlsRequest:
      type: object
      required: [partNumbers]
      properties:
        partNumbers:
          type: array
          minItems: 1
          maxItems: 100
          items:
            type: integer
            minimum: 1
            maximum: 10000

    RefreshedPartUrls:
      type: object
      required: [parts, partUrlsExpireAt]
      properties:
        parts:
          type: array
          items:
            $ref: "#/components/schemas/UploadPartUrl"
        partUrlsExpireAt:
          type: string
          format: date-time

    TaskStatusChangedData:
      type: object
      required: [taskId, projectId, title, statusGroup, changedAt]
      properties:
        taskId:
          type: string
          format: uuid
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        title:
          type: string
        statusGroup:
          type: string
        previousStatusGroup:
          type:
            - string
            - "null"
        actorId:
          type:
            - string
            - "null"
          format: uuid
          description: The member who moved it; null for share-link guests and automations.
        actorName:
          type:
            - string
            - "null"
        changedAt:
          type: string
          format: date-time
          description: >-
            When this status change was recorded, stamped server-side as the move
            was processed — not the task's last-edited timestamp. The paired
            `task.updated` event for the same move carries the identical instant
            in `updatedAt`, and two moves of the same task always carry different
            values.
        assigneeIds:
          type: array
          items: { type: string, format: uuid }
          description: Assigned team members at the moment of the event; `[]` when nobody is. *(1.99.0)*
        kind:
          type: string
          enum: [regular, parent, variant]
          description: Same values as the task resource's `kind`. *(1.99.0)*
        parentTaskId:
          type: ["string", "null"]
          format: uuid
          description: The task this one is a variant of; null unless `kind` is `variant`. *(1.99.0)*
    TaskStatusChangedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: task.status_changed
            data:
              $ref: "#/components/schemas/TaskStatusChangedData"

    CommentCreatedData:
      type: object
      required: [commentId, taskId, projectId, taskTitle, text, commentType, isGuest, authorKind, agentName, mentionedUserIds, visibility, createdAt]
      properties:
        commentId:
          type: string
          format: uuid
        taskId:
          type: string
          format: uuid
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        taskTitle:
          type: string
        text:
          type: string
          description: Plain text, mention markup stripped, capped at 2,000 characters.
        commentType:
          type: string
          description: general, video-point, video-range, text-selection, drawing, …
        startTime:
          type:
            - number
            - "null"
          description: Seconds into the media for time-coded comments.
        endTime:
          type:
            - number
            - "null"
        authorId:
          type:
            - string
            - "null"
          format: uuid
          description: Workspace member id, or null for a share-link guest.
        authorName:
          type:
            - string
            - "null"
        isGuest:
          type: boolean
        authorKind:
          type: string
          enum: [team, guest, ai]
          description: >-
            Who wrote it: `team` (a teammate), `guest` (a client) or `ai` — an
            AI note, whose `authorId` / `authorName` are the API key's person
            and `agentName` the name it is signed with. An AI answering
            `comment.created` should skip `ai` events, or at least its own
            `agentName`, so it never replies to itself (since 1.137.0).
        agentName:
          type:
            - string
            - "null"
          description: >-
            The name an AI note is signed with — an outside AI's `aiLabel`, or
            `Ronald` for Timeliner's own AI editor (it replaced
            `Timeliner Editor` in 1.152.0; Smith's notes, the AI check's,
            send no `comment.created` while the AI check is a staff beta,
            since 1.172.0) — else null (since
            1.137.0).
        mentionedUserIds:
          type: array
          items:
            type: string
            format: uuid
        visibility:
          type: string
          enum: [public, team]
        parentId:
          type:
            - string
            - "null"
          format: uuid
        createdAt:
          type: string
          format: date-time
    CommentCreatedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: comment.created
            data:
              $ref: "#/components/schemas/CommentCreatedData"

    VersionUploadedData:
      type: object
      required: [taskId, projectId, taskTitle, fileId, fileName, size, versionNumber, uploadedBy, source, uploadedAt]
      properties:
        taskId:
          type: string
          format: uuid
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        taskTitle:
          type: string
        fileId:
          type: string
          format: uuid
        fileName:
          type: string
        mimeType:
          type:
            - string
            - "null"
        size:
          type: integer
        versionNumber:
          type: integer
        uploadedBy:
          type: string
          format: uuid
        source:
          type: string
          enum: [app, api, desktop, ai]
          description: >-
            Where the upload came from: the web app, the API, the desktop
            drive, or `ai` (since 1.140.0) for a version Ronald, Timeliner's
            AI editor, delivered.
        uploadedAt:
          type: string
          format: date-time
    VersionUploadedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: version.uploaded
            data:
              $ref: "#/components/schemas/VersionUploadedData"

    FileUploadedData:
      type: object
      required: [fileId, projectId, fileName, size, uploadedBy, source, uploadedAt]
      properties:
        fileId:
          type: string
          format: uuid
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        folderId:
          type:
            - string
            - "null"
          format: uuid
        fileName:
          type: string
        mimeType:
          type:
            - string
            - "null"
        size:
          type: integer
        uploadedBy:
          type: string
          format: uuid
        source:
          type: string
          enum: [app, api, desktop, ai]
          description: >-
            Where the upload came from: the web app, the API, the desktop
            drive, or `ai` (since 1.140.0) for a version Ronald, Timeliner's
            AI editor, delivered.
        uploadedAt:
          type: string
          format: date-time
    FileUploadedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: file.uploaded
            data:
              $ref: "#/components/schemas/FileUploadedData"

    ProjectCreatedData:
      type: object
      required: [projectId, name, createdAt]
      properties:
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        brandName:
          type:
            - string
            - "null"
        name:
          type: string
        createdBy:
          type:
            - string
            - "null"
          format: uuid
        createdAt:
          type: string
          format: date-time
    ProjectCreatedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: project.created
            data:
              $ref: "#/components/schemas/ProjectCreatedData"

    PostPlatformOutcome:
      type: object
      required: [platform, status, permalink, error]
      properties:
        platform:
          type: string
        status:
          type: string
          description: published, failed, manual, pending, publishing.
        permalink:
          type:
            - string
            - "null"
          description: Provider URL of the live post; null when not published there.
        error:
          type:
            - string
            - "null"
          description: |
            Why this network did not publish — the same text as
            `networks[].error` in `GET /api/v1/posts` (a YouTube daily upload
            limit as one plain sentence, never Google's internal project
            identifiers — 1.228.1). `null` unless `status` is `failed`.

    PostPublishedData:
      type: object
      required: [postId, taskId, projectId, title, partial, platforms, publishedAt]
      properties:
        postId:
          type: string
          format: uuid
        taskId:
          type: string
          format: uuid
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        title:
          type: string
        partial:
          type: boolean
          description: True when another channel failed or was left for manual posting.
        platforms:
          type: array
          items:
            $ref: "#/components/schemas/PostPlatformOutcome"
        publishedAt:
          type: string
          format: date-time
    PostPublishedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: post.published
            data:
              $ref: "#/components/schemas/PostPublishedData"

    PostFailedData:
      type: object
      required: [postId, taskId, projectId, title, platforms, failedAt]
      properties:
        postId:
          type: string
          format: uuid
        taskId:
          type: string
          format: uuid
        projectId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        title:
          type: string
        platforms:
          type: array
          items:
            $ref: "#/components/schemas/PostPlatformOutcome"
        failedAt:
          type: string
          format: date-time
    PostFailedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: post.failed
            data:
              $ref: "#/components/schemas/PostFailedData"

    IntakeSubmittedData:
      type: object
      required: [requestId, title, isResubmission, itemCount, items, submittedAt]
      properties:
        requestId:
          type: string
          format: uuid
        formId:
          type:
            - string
            - "null"
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        title:
          type: string
        submittedBy:
          type:
            - string
            - "null"
          format: uuid
        isResubmission:
          type: boolean
        itemCount:
          type: integer
          description: Sum of the requested quantities.
        items:
          type: array
          items:
            type: object
            required: [name, quantity]
            properties:
              name:
                type: string
              quantity:
                type: integer
        submittedAt:
          type: string
          format: date-time
    IntakeSubmittedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: intake.submitted
            data:
              $ref: "#/components/schemas/IntakeSubmittedData"

    ShareOpenedData:
      type: object
      required: [shareId, contentType, openedAt]
      properties:
        shareId:
          type: string
          format: uuid
        contentType:
          type: string
          description: What the link points at — task, project, node, file, folder, … A batch link (a hand-picked set of a project's tasks) reports `batch` with `taskId` null and `projectId` set.
        taskId:
          type:
            - string
            - "null"
          format: uuid
        projectId:
          type:
            - string
            - "null"
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        viewerUserId:
          type:
            - string
            - "null"
          format: uuid
        viewerEmail:
          type:
            - string
            - "null"
        openedAt:
          type: string
          format: date-time
    ShareOpenedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: share.opened
            data:
              $ref: "#/components/schemas/ShareOpenedData"

    MemberInvitedData:
      type: object
      required: [invitationId, inviteeUserId, role, invitationType, invitedBy, invitedAt]
      properties:
        invitationId:
          type: string
          format: uuid
        inviteeUserId:
          type: string
          format: uuid
        inviteeEmail:
          type:
            - string
            - "null"
        role:
          type: string
        invitationType:
          type: string
          enum: [team, guest]
        brandId:
          type:
            - string
            - "null"
          format: uuid
        projectId:
          type:
            - string
            - "null"
          format: uuid
        invitedBy:
          type: string
          format: uuid
        invitedAt:
          type: string
          format: date-time
    MemberInvitedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: member.invited
            data:
              $ref: "#/components/schemas/MemberInvitedData"

    MemberJoinedData:
      type: object
      required: [userId, role, invitationType, joinedAt]
      properties:
        userId:
          type: string
          format: uuid
        email:
          type:
            - string
            - "null"
        role:
          type: string
        invitationType:
          type: string
          enum: [team, guest]
        brandId:
          type:
            - string
            - "null"
          format: uuid
        projectId:
          type:
            - string
            - "null"
          format: uuid
        joinedAt:
          type: string
          format: date-time
    MemberJoinedDataEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: member.joined
            data:
              $ref: "#/components/schemas/MemberJoinedData"


    AutomationTriggeredData:
      type: object
      required: [ruleId, triggerType, taskId, taskTitle, statusGroup, changeLabel, firedAt]
      properties:
        ruleId:
          type: string
          format: uuid
        triggerType:
          type: string
          description: The rule's trigger type (statusChanged, stageChanged, versionUploaded, …).
        taskId:
          type: string
          format: uuid
        taskTitle:
          type: string
        statusGroup:
          type: string
        projectId:
          type:
            - string
            - "null"
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        changeLabel:
          type: string
          description: The change that fired the rule, in the run log's words.
        firedAt:
          type: string
          format: date-time
    AutomationTriggeredEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: automation.triggered
            data:
              $ref: "#/components/schemas/AutomationTriggeredData"

    WebhookEventType:
      type: string
      enum:
        - task.completed
        - post.status_changed
        - task.created
        - task.updated
        - task.trashed
        - project.trashed
        - custom.column_changed
        - payment.recorded
        - payment.voided
        - task.status_changed
        - comment.created
        - version.uploaded
        - file.uploaded
        - project.created
        - post.published
        - post.failed
        - intake.submitted
        - share.opened
        - member.invited
        - member.joined
        - automation.triggered
        - time_entry.created
        - time_entry.updated
        - time_entry.deleted
      description: |
        - `task.completed` — a task transitioned into the `approved` status group.
        - `post.status_changed` — a post's approval or scheduling status changed.
        - `task.created` — a task was created.
        - `task.updated` — a task's fields changed (title, status, deadlines, assignees, metadata); `data.changed` lists which.
        - `task.trashed` — a task was moved to Trash.
        - `project.trashed` — a project was moved to Trash (cascades to its tasks; one event for the project).
        - `custom.column_changed` — a task's custom-column cell value was set.
        - `payment.recorded` — a payment landed in the append-only ledger (settlement or free-form).
        - `payment.voided` — a ledger payment was cancelled by its reversal row.
        - `task.status_changed` — a task moved to another status group, from any surface (1.80.0).
        - `comment.created` — a review comment landed, from a member or a share-link guest (1.80.0).
        - `version.uploaded` — a new version landed on a task (1.80.0).
        - `file.uploaded` — a raw project file finished uploading (1.80.0).
        - `project.created` — a project was created (1.80.0).
        - `post.published` — a scheduled post went live on at least one channel (1.80.0).
        - `post.failed` — a scheduled post failed to publish (1.80.0).
        - `intake.submitted` — a client submitted an intake form (1.80.0).
        - `share.opened` — a share link was opened; one event per viewer per link per hour (1.80.0).
        - `member.invited` — a team member or guest was invited (1.80.0).
        - `member.joined` — an invitation was accepted (1.80.0).
        - `automation.triggered` — delivered ONLY by the "Call a webhook" automation action to the endpoint a rule names; a subscription cannot list it (1.80.0).
        - `time_entry.created` — a timer was started or a time entry added by hand (1.207.0).
        - `time_entry.updated` — a time entry was paused, resumed, stopped or edited (1.207.0).
        - `time_entry.deleted` — a time entry was deleted or a just-started timer discarded (1.207.0).

    WebhookSubscription:
      type: object
      required: [id, url, events, active, failureCount, secretPrefix, createdAt]
      properties:
        id:
          type: string
          format: uuid
        url:
          type: string
          format: uri
          description: HTTPS endpoint deliveries are POSTed to.
        events:
          type: array
          items:
            $ref: "#/components/schemas/WebhookEventType"
        active:
          type: boolean
          description: When `false`, no deliveries are sent.
        failureCount:
          type: integer
          description: Count of failed delivery attempts.
        lastDeliveryStatus:
          type:
            - string
            - "null"
          description: HTTP status (or error string) of the most recent delivery attempt; `null` if never attempted.
        lastDeliveryAt:
          type:
            - string
            - "null"
          format: date-time
        secretPrefix:
          type: string
          description: Non-sensitive prefix of the signing secret, shown to identify it (e.g. `whsec_a1b2c3d4`).
        createdAt:
          type: string
          format: date-time

    CreatedWebhook:
      allOf:
        - $ref: "#/components/schemas/WebhookSubscription"
        - type: object
          required: [secret]
          properties:
            secret:
              type: string
              description: |
                Plaintext signing secret (`whsec_` followed by 64 hex chars).
                Returned **only** here and from rotate-secret — store it now, it
                is never shown again. Use it to verify each delivery's
                `X-Timeliner-Signature`.

    RotatedSecret:
      type: object
      required: [id, secret, secretPrefix]
      properties:
        id:
          type: string
          format: uuid
        secret:
          type: string
          description: The new plaintext signing secret. Returned only once — store it now.
        secretPrefix:
          type: string

    WebhookList:
      type: object
      required: [data]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/WebhookSubscription"

    CreateWebhookInput:
      type: object
      required: [url, events]
      properties:
        url:
          type: string
          format: uri
          description: |
            HTTPS endpoint to deliver events to. Must be a public `https://` URL.
            A host that is, or literally names, a private or internal address is
            rejected with a `400` (`` `url` host is not allowed ``): loopback,
            private, link-local / cloud metadata, carrier-grade NAT
            (`100.64.0.0/10`), `0.0.0.0/8`, multicast, IPv6 unique-local and
            link-local, IPv4-mapped forms such as `[::ffff:7f00:1]`, and the names
            `localhost` (with or without a trailing dot), `*.localhost`, `*.local`
            and `*.internal`. A public name that RESOLVES to such an address is
            accepted here but never connected to: each delivery checks the
            addresses the name resolves to and reports `blocked` instead.
        events:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/WebhookEventType"
          description: Event types to subscribe to. Duplicates are de-duplicated.

    UpdateWebhookInput:
      type: object
      description: Provide at least one of `url`, `events`, or `active`.
      minProperties: 1
      properties:
        url:
          type: string
          format: uri
          description: Same rule as on create — a private or internal host is a `400`.
        events:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/WebhookEventType"
        active:
          type: boolean

    WebhookEnvelope:
      type: object
      description: The signed JSON body Timeliner POSTs to your endpoint.
      required: [id, type, apiVersion, createdAt, workspaceId, data]
      properties:
        id:
          type: string
          format: uuid
          description: Unique delivery / event id. Dedupe on it — delivery is at-least-once.
        type:
          $ref: "#/components/schemas/WebhookEventType"
        apiVersion:
          type: string
          description: Payload schema version (date-based). Bumped only on an incompatible change.
          example: "2026-06-02"
        createdAt:
          type: string
          format: date-time
        workspaceId:
          type: string
          format: uuid
        data:
          type: object
          description: Event-specific payload — see the per-event `*Data` schemas.
        test:
          type: boolean
          const: true
          description: Present (and true) only on deliveries sent by "Send test event" — the payload is a sample, not a real change. Absent on real events.

    TaskCompletedData:
      type: object
      required: [taskId, projectId, title, statusGroup]
      properties:
        taskId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        brandName:
          type:
            - string
            - "null"
        projectId:
          type: string
          format: uuid
        title:
          type: string
        statusGroup:
          type: string
          description: The new status group — always `approved` for this event.
        previousStatusGroup:
          type:
            - string
            - "null"
        approvedAt:
          type:
            - string
            - "null"
          format: date-time

    PostStatusChangedData:
      type: object
      required: [postId, taskId, projectId, statusKind, platforms]
      properties:
        postId:
          type: string
          format: uuid
          description: Currently equal to `taskId` (a post is modeled on its task row).
        taskId:
          type: string
          format: uuid
        brandId:
          type:
            - string
            - "null"
          format: uuid
        projectId:
          type: string
          format: uuid
        statusKind:
          type: string
          enum: [approval, scheduling]
          description: Which axis changed — the approval status group or the scheduling status.
        status:
          type:
            - string
            - "null"
          description: New status on the changed axis (`null` when cleared).
        previousStatus:
          type:
            - string
            - "null"
        platforms:
          type: array
          items:
            type: string
          description: Target platform identifiers for the post.
        scheduledPostAt:
          type:
            - string
            - "null"
          format: date-time

    TaskCompletedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: task.completed
            data:
              $ref: "#/components/schemas/TaskCompletedData"

    PostStatusChangedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: post.status_changed
            data:
              $ref: "#/components/schemas/PostStatusChangedData"

    TaskCreatedData:
      type: object
      required: [taskId, projectId, title, type, statusGroup]
      properties:
        taskId: { type: string, format: uuid }
        projectId: { type: string, format: uuid }
        brandId: { type: ["string", "null"], format: uuid }
        title: { type: string }
        type: { type: string, enum: [media, doc] }
        statusGroup: { type: string }
        createdAt: { type: ["string", "null"], format: date-time }
        assigneeIds:
          type: array
          items: { type: string, format: uuid }
          description: Assigned team members at the moment of the event; `[]` when nobody is. *(1.99.0)*
        kind:
          type: string
          enum: [regular, parent, variant]
          description: Same values as the task resource's `kind`. *(1.99.0)*
        parentTaskId:
          type: ["string", "null"]
          format: uuid
          description: The task this one is a variant of; null unless `kind` is `variant`. *(1.99.0)*

    TaskCreatedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: task.created
            data:
              $ref: "#/components/schemas/TaskCreatedData"

    TaskUpdatedData:
      type: object
      required: [taskId, projectId, title, statusGroup, changed]
      properties:
        taskId: { type: string, format: uuid }
        projectId: { type: string, format: uuid }
        brandId: { type: ["string", "null"], format: uuid }
        title: { type: string }
        statusGroup: { type: string }
        previousStatusGroup: { type: ["string", "null"] }
        changed:
          type: array
          items: { type: string }
          description: The fields that changed (e.g. title, statusGroup, internalDeadline, assigneeIds).
        updatedAt:
          type: ["string", "null"]
          format: date-time
          description: >-
            When this update was recorded, stamped server-side as the change was
            processed — not the task's last-edited timestamp. For a status move it
            matches the paired `task.status_changed` event's `changedAt`.
        previousAssigneeIds:
          type: array
          items: { type: string, format: uuid }
          description: >-
            Assignees BEFORE this update. Differs from `assigneeIds` exactly when
            `changed` includes `assigneeIds` — diff the two to learn who was added
            or removed (there is no separate `task.assigned` event). An automation's
            Auto-assign pick arrives this way. *(1.99.0)*
        actorId:
          type: ["string", "null"]
          format: uuid
          description: >-
            The workspace member who made the change — for an API change, the
            member who created the API key. Null for share-link clients and for
            automations or approval windows acting under a system name. Same
            value as the paired `task.status_changed` event's `actorId`. *(1.127.0)*
        actorName:
          type: ["string", "null"]
          description: >-
            Display name of whoever made the change — a member, a share-link
            client's typed name, or the system's name (e.g. "Automation"). Null
            only when no actor is known. *(1.127.0)*
        assigneeIds:
          type: array
          items: { type: string, format: uuid }
          description: Assigned team members at the moment of the event; `[]` when nobody is. *(1.99.0)*
        kind:
          type: string
          enum: [regular, parent, variant]
          description: Same values as the task resource's `kind`. *(1.99.0)*
        parentTaskId:
          type: ["string", "null"]
          format: uuid
          description: The task this one is a variant of; null unless `kind` is `variant`. *(1.99.0)*

    TaskUpdatedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: task.updated
            data:
              $ref: "#/components/schemas/TaskUpdatedData"

    TaskTrashedData:
      type: object
      required: [taskId, projectId, title]
      properties:
        taskId: { type: string, format: uuid }
        projectId: { type: string, format: uuid }
        brandId: { type: ["string", "null"], format: uuid }
        title: { type: string }
        trashedAt: { type: ["string", "null"], format: date-time }

    TaskTrashedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: task.trashed
            data:
              $ref: "#/components/schemas/TaskTrashedData"

    ProjectTrashedData:
      type: object
      required: [projectId, name]
      properties:
        projectId: { type: string, format: uuid }
        brandId: { type: ["string", "null"], format: uuid }
        name: { type: string }
        trashedAt: { type: ["string", "null"], format: date-time }

    ProjectTrashedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: project.trashed
            data:
              $ref: "#/components/schemas/ProjectTrashedData"

    CustomColumnChangedData:
      type: object
      required: [taskId, projectId, columnId, columnName, kind, value]
      properties:
        taskId: { type: string, format: uuid }
        projectId: { type: string, format: uuid }
        brandId: { type: ["string", "null"], format: uuid }
        columnId: { type: string, format: uuid }
        columnName: { type: string }
        kind: { type: string, enum: [text, date, priority, link, dateRange, select, tag] }
        value:
          description: |
            The new public value for the cell (per the column's kind), or null if
            cleared. For `tag` this is the array of `tagId`s the write set —
            the request's own value, not the resolved `{ tagId, label }` pairs
            the read endpoints return.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
            - type: array
              items: { type: string, format: uuid }
            - type: "null"

    CustomColumnChangedEvent:
      allOf:
        - $ref: "#/components/schemas/WebhookEnvelope"
        - type: object
          properties:
            type:
              const: custom.column_changed
            data:
              $ref: "#/components/schemas/CustomColumnChangedData"

    # ── HQ (internal team boards) ─────────────────────────────────────────

    HqBoardKind:
      type: string
      enum: [tasks, docs, crm, assets, checklist]
      description: Template flavor of the board — drives default card styling only.

    HqBoardAccess:
      type: string
      enum: [open, restricted]
      description: |
        `restricted` = explicit board members + workspace admins; the board
        answers from its own member list alone.

        `open` = the board INHERITS the audience of the gallery folder it is
        filed under, minus anyone it explicitly hides. A board in no folder (or
        in an open folder) therefore resolves to every team member, which is
        what `open` has always meant; a board inside a members-only folder is
        visible to that folder's members plus workspace admins. Folders and
        per-board exclusions are managed in the app and are not exposed by this
        API.

        The workspace API key is admin-equivalent, so it sees every board
        either way.

    HqFieldKind:
      type: string
      enum: [text, number, currency, date, select, link, email, phone, user, timeTracker]
      description: |
        The value type of a board's custom field. `timeTracker` is a
        play/pause time tracker — its value is the total logged seconds; the
        running-timer state is app-internal and not exposed through this API.

    HqBoard:
      type: object
      required:
        [id, name, kind, access, archivedAt, itemCount, memberCount, createdAt, editedAt]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        icon:
          type:
            - string
            - "null"
          description: Emoji (or curated icon name) shown on the board card.
        color:
          type:
            - string
            - "null"
          description: Palette color token (e.g. `blue`, `emerald`).
        kind:
          $ref: "#/components/schemas/HqBoardKind"
        access:
          $ref: "#/components/schemas/HqBoardAccess"
        archivedAt:
          type:
            - string
            - "null"
          format: date-time
          description: Non-null when the board is archived (reversible removal).
        itemCount:
          type: integer
          description: Number of items on the board (archived items included).
        memberCount:
          type: integer
          description: Number of explicit HqBoardMember rows (meaningful on restricted boards).
        createdAt:
          type: string
          format: date-time
        editedAt:
          type: string
          format: date-time

    HqStage:
      type: object
      required: [id, name, outcome, sortOrder]
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          description: User-defined column name (e.g. "Incoming", "Filming").
        color:
          type:
            - string
            - "null"
          description: Palette color token.
        outcome:
          type: string
          enum: [none, done, won, lost]
          description: Done/won/lost semantics for CRM & checklist boards — never an approval state.
        sortOrder:
          type: number

    HqFieldOption:
      type: object
      required: [id, label, sortOrder]
      properties:
        id:
          type: string
          format: uuid
        label:
          type: string
        color:
          type:
            - string
            - "null"
        sortOrder:
          type: integer

    HqField:
      type: object
      required: [id, kind, name, config, sortOrder]
      properties:
        id:
          type: string
          format: uuid
        kind:
          $ref: "#/components/schemas/HqFieldKind"
        name:
          type: string
        config:
          type: object
          additionalProperties: true
          description: Kind extras, e.g. `{"currency":"USD"}` on currency fields, the stored value. HQ screens and public links always show the workspace currency.
        sortOrder:
          type: integer
        options:
          type: array
          items:
            $ref: "#/components/schemas/HqFieldOption"
          description: Present only on `select`-kind fields.

    HqBoardMembership:
      type: object
      required: [userId, role]
      properties:
        userId:
          type: string
          format: uuid
          description: A member id — match against `GET /api/v1/members`.
        role:
          type: string
          enum: [manager, member]

    HqBoardDetail:
      allOf:
        - $ref: "#/components/schemas/HqBoard"
        - type: object
          required: [stages, fields, members, columnOrder, viewOrder]
          properties:
            columnOrder:
              type: array
              items:
                type: string
              description: |
                The board's property order — the list view's columns AND the
                item page's details: built-ins `stage`, `assignees`,
                `dueDate` and custom field ids. Change it with
                `PATCH /api/v1/hq/boards/{id}` `columnOrder`.
            viewOrder:
              type: array
              items:
                type: string
                enum: [board, list, files]
              description: |
                The Board / List / Files toggle order. The FIRST view is the
                one the board opens in for everyone.
            stages:
              type: array
              items:
                $ref: "#/components/schemas/HqStage"
            fields:
              type: array
              items:
                $ref: "#/components/schemas/HqField"
            members:
              type: array
              items:
                $ref: "#/components/schemas/HqBoardMembership"

    CreateHqBoardInput:
      type: object
      required: [name]
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 80
        description:
          type:
            - string
            - "null"
          maxLength: 5000
        icon:
          type:
            - string
            - "null"
          description: Emoji or curated icon name. Defaults to the template's icon.
        color:
          type:
            - string
            - "null"
          description: Palette token. Invalid tokens are coerced to null.
        kind:
          $ref: "#/components/schemas/HqBoardKind"
        access:
          $ref: "#/components/schemas/HqBoardAccess"
        template:
          type: string
          enum: [companyOps, salesPipeline, sops, assetLibrary, onboarding, blank]
          description: |
            Template preset to seed stages/fields from
            (`lib/hq/boardTemplates.ts`). Seeded with English names. Omit for
            a blank board with a single "To do" stage.

    UpdateHqBoardInput:
      type: object
      description: Provide at least one field.
      minProperties: 1
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 80
        description:
          type:
            - string
            - "null"
          maxLength: 5000
        icon:
          type:
            - string
            - "null"
        color:
          type:
            - string
            - "null"
        access:
          $ref: "#/components/schemas/HqBoardAccess"
        archived:
          type: boolean
          description: true archives the board (reversible); false restores it.
        columnOrder:
          type: array
          minItems: 1
          maxItems: 32
          uniqueItems: true
          items:
            type: string
          description: |
            New property order: `stage`, `assignees`, `dueDate` and this
            board's field ids, each at most once. Keys left out fall in behind
            in their default order. Unknown keys are refused (400).
        viewOrder:
          type: array
          minItems: 1
          maxItems: 3
          uniqueItems: true
          items:
            type: string
            enum: [board, list, files]
          description: |
            New Board / List / Files toggle order — its first view becomes the
            board's default for everyone. Views left out fall in behind.

    HqItemValue:
      type: object
      required: [fieldId, kind, value]
      properties:
        fieldId:
          type: string
          format: uuid
        kind:
          $ref: "#/components/schemas/HqFieldKind"
        value:
          description: |
            The cell value per the field's kind — string for
            text/email/phone/date/link, number for number/currency, an option
            id for select, a member id for user, total logged seconds for
            timeTracker.
          oneOf:
            - type: string
            - type: number
            - type: "null"

    HqItem:
      type: object
      required:
        [id, boardId, stageId, title, assigneeIds, dueDate, sortOrder, archivedAt, createdAt, editedAt, values]
      properties:
        id:
          type: string
          format: uuid
        boardId:
          type: string
          format: uuid
        stageId:
          type: string
          format: uuid
        title:
          type: string
        icon:
          type:
            - string
            - "null"
          description: Emoji shown on the card.
        assigneeIds:
          type: array
          items:
            type: string
            format: uuid
          description: Assigned team members (always active team members — never guests).
        dueDate:
          type:
            - string
            - "null"
          format: date
        sortOrder:
          type: number
        archivedAt:
          type:
            - string
            - "null"
          format: date-time
        createdAt:
          type: string
          format: date-time
        editedAt:
          type: string
          format: date-time
        values:
          type: array
          items:
            $ref: "#/components/schemas/HqItemValue"

    HqItemDetail:
      allOf:
        - $ref: "#/components/schemas/HqItem"
        - type: object
          required: [contentText]
          properties:
            contentText:
              type:
                - string
                - "null"
              description: The item's doc body as HTML (SOPs / notes), or null.

    HqItemPage:
      type: object
      required: [data, nextBefore]
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/HqItem"
        nextBefore:
          type:
            - string
            - "null"
          description: Opaque cursor for the next page; null when done.

    HqItemCreated:
      description: |
        The created item. Identical to `HqItem` unless the request carried
        `contentHtml`, in which case the two doc fields are present too.
      allOf:
        - $ref: "#/components/schemas/HqItem"
        - type: object
          properties:
            contentText:
              type:
                - string
                - "null"
              description: |
                The document body that was saved, echoed back. Only present when
                the request carried `contentHtml`; `null` if the document write
                did not land (see `docSaved`).
            docSaved:
              type: boolean
              description: |
                Only present when the request carried `contentHtml`. `false`
                means the item WAS created but its document was not written —
                retry the body with `PUT /api/v1/hq/items/{id}/doc` rather than
                re-POSTing, which would create a second item.

    CreateHqItemInput:
      type: object
      required: [title, stageId]
      properties:
        title:
          type: string
          minLength: 1
          maxLength: 200
        stageId:
          type: string
          format: uuid
          description: A stage of this board — from `GET /api/v1/hq/boards/{id}`.
        icon:
          type:
            - string
            - "null"
          description: Emoji shown on the card.
        contentHtml:
          type:
            - string
            - "null"
          maxLength: 1000000
          description: |
            Optional document body for the new item, so creating an item **and**
            writing its doc is ONE call instead of a create followed by
            `PUT /api/v1/hq/items/{id}/doc`. Same HTML rules as that endpoint
            (1–1,000,000 characters). Omit it (or send `null`) to create the item
            with an empty document.

            When you send it, the `201` body carries `contentText` and
            `docSaved`. `docSaved: false` means the item was created but the
            document write did not land — retry the body alone with
            `PUT /api/v1/hq/items/{id}/doc`; do **not** re-POST, that would
            create a second item.

    UpdateHqItemInput:
      type: object
      description: Provide at least one field.
      minProperties: 1
      properties:
        title:
          type: string
          minLength: 1
          maxLength: 200
        icon:
          type:
            - string
            - "null"
        stageId:
          type: string
          format: uuid
          description: A stage of the item's board (cross-board moves are rejected).
        assigneeIds:
          type: array
          items:
            type: string
            format: uuid
          description: FULL REPLACE; [] clears all. Ids you add must be active team members; people already on the item may stay.
        dueDate:
          type:
            - string
            - "null"
          format: date
          description: YYYY-MM-DD, or null to clear.
        sortOrder:
          type: number
        archived:
          type: boolean

    SetHqItemValuesInput:
      type: object
      required: [values]
      properties:
        values:
          type: array
          minItems: 1
          maxItems: 20
          description: One entry per field; duplicate fieldIds are rejected.
          items:
            type: object
            required: [fieldId, kind, value]
            properties:
              fieldId:
                type: string
                format: uuid
              kind:
                $ref: "#/components/schemas/HqFieldKind"
              value:
                description: The value per the kind; null clears the cell.
                oneOf:
                  - type: string
                  - type: number
                  - type: "null"

    HqItemValuesResult:
      type: object
      required: [itemId, values]
      properties:
        itemId:
          type: string
          format: uuid
        values:
          type: array
          items:
            $ref: "#/components/schemas/HqItemValue"

    HqCommentAuthor:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          format: uuid
        name:
          type:
            - string
            - "null"

    HqComment:
      type: object
      required: [id, itemId, text, author, createdAt, editedAt]
      properties:
        id:
          type: string
          format: uuid
        itemId:
          type: string
          format: uuid
        text:
          type: string
        author:
          oneOf:
            - $ref: "#/components/schemas/HqCommentAuthor"
            - type: "null"
        createdAt:
          type: string
          format: date-time
        editedAt:
          type: string
          format: date-time

    CreateHqCommentInput:
      type: object
      required: [text]
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 5000

    HqStageInput:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 60
          description: Required when creating.
        color:
          type:
            - string
            - "null"
          description: Palette token. Invalid tokens are coerced to null.
        outcome:
          type: string
          enum: [none, done, won, lost]
          description: Defaults to `none` when creating.

    CreateHqFieldInput:
      type: object
      required: [kind, name]
      properties:
        kind:
          $ref: "#/components/schemas/HqFieldKind"
        name:
          type: string
          minLength: 1
          maxLength: 60
        currency:
          type: string
          pattern: "^[A-Z]{3}$"
          description: Currency fields only (ISO 4217). Stored and returned here; HQ screens and public links always show the workspace currency.
        options:
          type: array
          maxItems: 20
          description: Select fields only — the options, in order.
          items:
            $ref: "#/components/schemas/HqFieldOptionInput"

    HqFieldOptionInput:
      type: object
      properties:
        label:
          type: string
          minLength: 1
          maxLength: 40
          description: Required when creating.
        color:
          type:
            - string
            - "null"
          description: Palette token. Invalid tokens are coerced to null.

    HqFile:
      type: object
      required: [id, itemId, name, size, mimeType, uploadedBy, createdAt, downloadUrl]
      properties:
        id:
          type: string
          format: uuid
        itemId:
          type:
            - string
            - "null"
          format: uuid
          description: The item it is attached to (null for a board-shelf file).
        name:
          type: string
        size:
          type: integer
          description: Bytes.
        mimeType:
          type: string
        uploadedBy:
          type:
            - string
            - "null"
          format: uuid
        createdAt:
          type: string
          format: date-time
        downloadUrl:
          type:
            - string
            - "null"
          description: Presigned download link, valid for 7 days.

    StorageOverview:
      type: object
      required: [usedBytes, capacityGb, breakdown]
      properties:
        usedBytes:
          type: integer
          description: Total bytes counted against the workspace quota.
        capacityGb:
          type: [integer, "null"]
          description: The plan's storage ceiling in decimal GB.
        breakdown:
          type: array
          items:
            $ref: "#/components/schemas/StorageBreakdownRow"

    StorageBreakdownRow:
      type: object
      description: |
        One (brand, project, category) byte bucket. projectId is null for
        brand-level buckets (brandFile); brandId AND projectId are both null
        for workspace-level buckets (hqFile — an HQ board is not a brand).
        Summing totalBytes across every row equals the overview's usedBytes.
        A file stored once but shared by several copies counts in ONE bucket
        (since 1.223.1), so a bucket can hold a fileCount with totalBytes 0.
      required:
        [
          brandId,
          brandName,
          brandArchived,
          projectId,
          projectName,
          projectArchived,
          category,
          fileCount,
          totalBytes,
        ]
      properties:
        brandId: { type: ["string", "null"], format: uuid }
        brandName: { type: ["string", "null"] }
        brandArchived: { type: ["boolean", "null"] }
        projectId: { type: ["string", "null"], format: uuid }
        projectName: { type: ["string", "null"] }
        projectArchived: { type: ["boolean", "null"] }
        category:
          type: string
          enum: [deliverableCurrent, versionOld, raw, headerAttachment, brandFile, commentAttachment, hqFile, trashed]
        fileCount: { type: integer }
        totalBytes: { type: integer }

    StorageItem:
      type: object
      required: [id, source, name, mimeType, totalBytes, category, createdAt, brandId, brandName, isCurrentVersion]
      properties:
        id: { type: string, format: uuid }
        source:
          type: string
          enum: [file, brandFile]
        name: { type: string }
        mimeType: { type: string }
        totalBytes:
          type: integer
          description: Original bytes plus every transcoded proxy rung.
        duration: { type: ["number", "null"], description: Seconds (video/audio only). }
        width: { type: ["integer", "null"] }
        height: { type: ["integer", "null"] }
        fps: { type: ["number", "null"] }
        category:
          type: string
          enum: [deliverableCurrent, versionOld, raw, headerAttachment, brandFile]
        createdAt: { type: string, format: date-time }
        uploadedBy: { type: ["string", "null"], format: uuid }
        brandId: { type: string, format: uuid }
        brandName: { type: string }
        projectId: { type: ["string", "null"], format: uuid }
        projectName: { type: ["string", "null"] }
        projectArchived: { type: ["boolean", "null"] }
        taskId: { type: ["string", "null"], format: uuid }
        taskTitle: { type: ["string", "null"] }
        taskStatus: { type: ["string", "null"], description: The related task's statusGroup. }
        approvedAt: { type: ["string", "null"], format: date-time }
        postedAt: { type: ["string", "null"], format: date-time }
        archivedAt: { type: ["string", "null"], format: date-time }
        versionNumber: { type: ["integer", "null"] }
        isCurrentVersion:
          type: boolean
          description: True when this file is some task's CURRENT deliverable — reclaim it by trashing the task, not the file.

    StorageItemsPage:
      type: object
      required: [items, nextCursor]
      properties:
        items:
          type: array
          items:
            $ref: "#/components/schemas/StorageItem"
        nextCursor:
          type: ["string", "null"]
          description: Echo back as `cursor` for the next page; null on the last page.
        totalCount:
          type: integer
          description: Size of the FULL filtered set — first (cursor-less) page only.
        totalBytes:
          type: integer
          description: Byte total of the FULL filtered set — first page only.

    StorageSuggestion:
      type: object
      required: [ruleKey, itemCount, totalBytes]
      properties:
        ruleKey:
          type: string
          description: One of the cleanup rules, or `_total` — the DISTINCT union across rules (the honest reclaimable figure).
          enum: [oldVersions, approvedOldTasks, archivedTaskMedia, oldProjectRawFiles, largeStaleFiles, _total]
        itemCount: { type: integer }
        totalBytes: { type: integer }

    StorageCleanupRequest:
      type: object
      description: Provide exactly one of `selection` or `rule`.
      properties:
        selection:
          type: object
          description: Explicit ids to trash (from /storage/items).
          properties:
            fileIds:
              type: array
              maxItems: 500
              items: { type: string, format: uuid }
            brandFileIds:
              type: array
              maxItems: 500
              items: { type: string, format: uuid }
            taskIds:
              type: array
              maxItems: 200
              description: Whole tasks (with all their media) — the only way to reclaim a current deliverable.
              items: { type: string, format: uuid }
        rule:
          type: object
          required: [ruleKey]
          properties:
            ruleKey:
              type: string
              enum: [oldVersions, approvedOldTasks, archivedTaskMedia, oldProjectRawFiles, largeStaleFiles]
            keepVersions: { type: integer, minimum: 0, maximum: 50 }
            ageMonths: { type: integer, minimum: 1, maximum: 120 }
            largeBytes: { type: integer, minimum: 1 }
            brandId: { type: string, format: uuid }
            projectId: { type: string, format: uuid }
        dryRun:
          type: boolean
          description: Validate and count without mutating.

    StorageCleanupResult:
      type: object
      required: [trashedFiles, trashedBrandFiles, trashedTasks, trashedVersions, freedBytes, dryRun]
      properties:
        trashedFiles: { type: integer }
        trashedBrandFiles: { type: integer }
        trashedTasks: { type: integer }
        trashedVersions: { type: integer }
        freedBytes: { type: integer }
        remainingCount:
          type: integer
          description: Rule mode only — items still matching the rule after this batch; repeat until 0.
        matchedFiles:
          type: integer
          description: Rule dry-run only — files the batch would trash.
        matchedTasks:
          type: integer
          description: Rule dry-run only — tasks the batch would trash.
        dryRun: { type: boolean }
