openapi: 3.1.0
info:
  title: ShortSync API
  version: 1.0.0-beta.1
  summary: Schedule and publish videos, images, carousels and text posts to 17 social platforms, including YouTube, TikTok, Instagram, LinkedIn and X.
  description: |
    The ShortSync API lets you upload media and publish it to one or more connected
    social platforms from a single call. Posts can be sent immediately, scheduled
    for a future time, or saved as drafts.

    > **Public beta.** Open to every plan, including Free. Mint a workspace
    > key in Settings -> API. Each plan has its own monthly request cap;
    > see your `GET /me` response for the current limit and usage.

    ## Authentication

    Authentication is a single workspace-scoped Bearer key:

    | Prefix      | Kind           | Scope                                            |
    |-------------|----------------|--------------------------------------------------|
    | `ss_live_`  | Workspace key  | A single workspace, pinned at creation           |

    Workspace keys publish posts and read posts/connections for the one
    workspace they're pinned to. Mint and rotate keys from Settings → API
    in the ShortSync app.

    ## Conventions

    - All timestamps are ISO 8601 with timezone (`2026-06-07T13:30:00Z`).
    - All IDs are UUIDs (`bbdeeb40-c106-4ed6-95b5-c0e76086c957`). They are
      opaque to clients; do not parse them.
    - Field names are `snake_case`.
    - Cursor-based pagination on every list endpoint.

    ## Rate limits and quotas

    - **Per-key rate limit**: 60 requests per minute. Exceeding it returns
      `429 RATE_LIMIT_EXCEEDED` with `X-RateLimit-Limit`,
      `X-RateLimit-Remaining`, `X-RateLimit-Reset`, and `Retry-After`
      headers.
    - **Per-org monthly request quota**: request count only, shared
      across every key in the organization. Plan-tier limits apply.
      Exceeding the cap returns `429 QUOTA_EXCEEDED` with
      `details.quota`, `details.used`, `details.limit`,
      `details.resets_at`, and `details.upgrade_url`.
    - **Per-user upload cap (Free only)**: `POST /posts` counts against
      the same 5-uploads-per-month cap the dashboard enforces. Free
      users who hit it get `429 UPLOAD_QUOTA_EXCEEDED` with
      `details.quota`, `details.used`, `details.limit`,
      `details.remaining`, and `details.upgrade_url`. Creator and Team
      tiers are unlimited and never hit this, under the fair use policy
      at https://www.shortsync.app/docs/platforms/limits#fair-use.
    - **Per-workspace daily posting limit**: every plan has a daily
      limit per platform, the same as in the app, reset at midnight UTC.
      A publish over it fails with `429 DAILY_LIMIT_REACHED`. X counts
      units per organization, shared by its workspaces: 20 a day on Free
      and Creator, 60 on Team, plus 10 per extra-workspace add-on. A post
      uses 1 unit, 15 with a link, first comments included; a post needing
      more than the whole day's units fails with
      `400 X_POST_TOO_LARGE`. Snapchat, Reddit and Google Business
      Profile also follow the limits of our API partner. Limits per
      platform: https://www.shortsync.app/docs/platforms/limits

    ## Idempotency

    `POST /posts`, `POST /uploads/carousel-group` and
    `POST /repurposing/workflows` accept an `Idempotency-Key` header. The first successful
    response for a given `(organization, key)` is cached for 24h; replays
    return the cached body and status code. Use a fresh UUID per logical
    operation. `POST /uploads` does not honor the header because the
    response carries a time-limited presigned URL we don't re-issue —
    on retry, call the endpoint again and PUT to the new URL.

    ## Webhooks

    Instead of polling `GET /posts/{id}`, subscribe a URL with
    `POST /webhooks` and ShortSync sends a signed POST request when a post
    is published (`post.published`), fails (`post.failed`) or is scheduled
    (`post.scheduled`), and when a DM automation collects an email
    (`dm_contact.created`, with `data.contact`). Each request carries an `X-ShortSync-Signature:
    t=<unix>,v1=<hex>` header, an HMAC-SHA256 of `<t>.<raw body>` with the
    webhook's secret. Failed deliveries are retried. Zapier, Make and n8n
    can subscribe the same way. Full guide:
    https://www.shortsync.app/docs/api/webhooks
  contact:
    name: ShortSync
    email: hilma@shortsync.app
    url: https://www.shortsync.app
  termsOfService: https://www.shortsync.app/terms-of-service
  license:
    name: Proprietary
  x-logo:
    url: https://www.shortsync.app/logo.png
    altText: ShortSync

externalDocs:
  description: ShortSync API documentation
  url: https://www.shortsync.app/docs/api

servers:
  - url: https://api.shortsync.app/v1
    description: Production (subdomain)
  - url: https://www.shortsync.app/api/v1
    description: Production (path-based, fallback while subdomain DNS lands)

security:
  - WorkspaceKey: []

tags:
  - name: Identity
    description: Token introspection — scopes, organization, workspace, plan, and current monthly API quota.
  - name: Uploads
    description: Upload media to ShortSync storage before publishing.
  - name: Posts
    description: Publish, list, reschedule, and cancel posts.
  - name: Connections
    description: Read connected social platform accounts.
  - name: Analytics
    description: Read per-post analytics and workspace summaries; trigger a fresh sync from the platforms.
  - name: Repurposing
    description: Workflows that repost an Instagram or Facebook Page account's posts to other accounts, as they're published or older ones on a weekly schedule.
  - name: Webhooks
    description: Get a signed POST request when a post is published, fails or is scheduled (beta).
  - name: Imports
    description: Bring clips, designs and videos from tools the key's creator connected in Settings > Integrations (OpusClip and more) into the library, with their captions. The /opusclip paths are deprecated aliases of /imports.
  - name: Team
    description: Workspace members (people who log in) and their email invitations. Actions run as the key's creator, with that person's workspace role.
  - name: Comment DMs
    description: Rules that send one private Instagram DM to anyone who comments a keyword, as one text, up to 5 versions, or written by AI, with an optional public reply under the comment. Included on Team, the DM automation add-on on Creator. Actions run as the key's creator.
  - name: Billing
    description: The organization's plan and add-ons, and Stripe Checkout links to buy them. Account tokens only. Nothing is charged until a person opens the link and pays.
  - name: Inbox
    description: Read and answer comments, mentions, reviews and DMs from Instagram, Facebook, YouTube, Threads, LinkedIn, Bluesky, Mastodon, Telegram and Google Business Profile, plus the workspace's saved replies.

paths:
  /me:
    get:
      tags: [Identity]
      summary: Get identity
      description: |
        Returns the kind, organization, workspace scope, granted scopes, and
        the current month's API quota snapshot for the token used to make
        this request. Safe to call on app boot to discover what the token
        can do and how much headroom is left on the monthly caps.
      operationId: getIdentity
      responses:
        "200":
          description: Token introspection.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Identity"
              examples:
                workspaceKey:
                  summary: Workspace key
                  value:
                    kind: workspace
                    key_id: 0425b194-e9c1-4eca-ba35-ddd1ca84d7e9
                    prefix: ss_live_iUqoW6fj
                    organization_id: 55c3dca4-1a0e-4fe9-8ece-895b477fce91
                    workspace_id: bbdeeb40-c106-4ed6-95b5-c0e76086c957
                    scopes:
                      [posts:write, posts:read, uploads:write, connections:read]
                    plan: team
                    quota:
                      requests: { used: 1247, limit: 500000, remaining: 498753 }
                      resets_at: "2026-07-01T00:00:00.000Z"
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /uploads:
    get:
      tags: [Uploads]
      summary: List uploads
      description: |
        Returns uploads in the workspace, newest first. Cursor-paginated.
        The `status` field is derived: `reserved` means the slot exists
        but the bytes haven't been finalized, `ready` means the upload
        has been finalized and has metadata available. List calls do
        **not** trigger lazy-finalize for stale reservations — that
        happens on `GET /uploads/{upload_id}` (and on the opportunistic
        background timer after `POST /uploads`).

        Carousels include `carousel_items`: their images and videos in
        order. Those items are uploads too, so they also appear in the
        list on their own.
      operationId: listUploads
      security:
        - WorkspaceKey: []
      parameters:
        - name: status
          in: query
          schema:
            type: array
            items: { type: string, enum: [reserved, ready] }
          style: form
          explode: false
        - name: content_kind
          in: query
          description: Only uploads of this kind, e.g. `carousel`.
          schema:
            type: string
            enum: [video, image, text, carousel]
        - name: created_after
          in: query
          schema: { type: string, format: date-time }
        - name: created_before
          in: query
          schema: { type: string, format: date-time }
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Uploads.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/PaginatedEnvelope"
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: "#/components/schemas/Upload" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    post:
      tags: [Uploads]
      summary: Start a media upload
      description: |
        Reserves an upload slot and returns a presigned `PUT` URL targeting
        ShortSync's media storage. The request body is **empty** — no
        filename or content type is required at this step. Your `PUT` may
        set whatever `Content-Type` header you want; ShortSync stores
        whatever bytes arrive.

        The URL is valid for **1 hour** (see `expires_at`). If your upload
        doesn't start within that window, call `POST /uploads` again to
        mint a fresh URL — the prior `upload_id` is harmless and will be
        garbage collected.

        Type validation is **deferred to finalize**. The first time you
        call `GET /uploads/{upload_id}` or `POST /posts` with this
        `upload_id`, ShortSync reads the stored `Content-Type` and rejects
        it with `415 UNSUPPORTED_FILE_TYPE` if it isn't in the allow-list
        (`video/mp4`, `video/quicktime`, `video/webm`, `video/x-msvideo`,
        `video/x-matroska`, `image/jpeg`, `image/png`, `image/webp`,
        `image/heic`, `image/gif`). Bad uploads waste the PUT bandwidth, so
        set the `Content-Type` header correctly on your `PUT`.

        The same finalize step also validates per-kind size caps (2 GB
        video, 20 MB image) and the workspace storage quota, then marks
        the upload `ready`. There is no explicit "complete" call.
      operationId: createUpload
      security:
        - WorkspaceKey: []
      requestBody:
        required: false
        content:
          application/json:
            schema: { $ref: "#/components/schemas/UploadCreate" }
            examples:
              empty:
                summary: No body required
                value: {}
              fromUrl:
                summary: Import from a public URL
                value:
                  source_url: https://example-bucket.s3.amazonaws.com/clips/recipe.mp4
      responses:
        "201":
          description: |
            Upload reserved. Use `presigned_url` to PUT the bytes. With
            `source_url`, ShortSync downloads the file and returns a ready
            upload instead (`UploadFromUrl`).
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/UploadTicket"
                  - $ref: "#/components/schemas/UploadFromUrl"
              examples:
                video:
                  value:
                    upload_id: up_01HW0ZAB3CDEFGHJKMNPQRSTUV
                    presigned_url: https://media.shortsync.app/up_01HW0ZAB3CDEFGHJKMNPQRSTUV?X-Amz-...
                    method: PUT
                    expires_at: "2026-06-07T13:35:00Z"
                    workspace_id: ws_01HW0Z9XJ2K3R4M5N6P7Q8S9TU
                fromUrl:
                  value:
                    upload_id: up_01HW0ZAB3CDEFGHJKMNPQRSTUV
                    status: ready
                    filename: recipe.mp4
                    content_type: video/mp4
                    size_bytes: 12450112
                    source_url: https://example-bucket.s3.amazonaws.com/clips/recipe.mp4
                    workspace_id: ws_01HW0Z9XJ2K3R4M5N6P7Q8S9TU
        "400": { $ref: "#/components/responses/Validation" }
        "422":
          description: |
            `source_url` couldn't be imported: the download failed, the
            server sent no Content-Length, the file isn't a supported video
            or image, it's too large, or the storage quota is full.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /uploads/carousel-group:
    post:
      tags: [Uploads]
      summary: Group uploads into a carousel
      description: |
        Groups an ordered list of already-uploaded items into a single carousel
        post. Each item must have been uploaded via `POST /uploads` and finalized
        (bytes landed in S3) before calling this endpoint.

        Creates a carousel parent with `content_type: "carousel"` and returns a
        new `upload_id` that you pass to `POST /posts` to publish.

        The global item limit is 50. Per-platform limits are enforced at publish
        time: Instagram (10), TikTok (35, images only), Facebook (30, images
        only), LinkedIn (20, images only), Threads (10), X (4, images only),
        Bluesky (4, images only), Pinterest (5, images only), Telegram (10),
        Mastodon (4, images only), Discord (10, images and video, 10 MB
        total per post), Tumblr (10, images and one video max), Pixelfed (20, images
        and video; the connected server's album cap applies, default 4).
        Google Business Profile doesn't support carousels (one photo per post),
        and neither does Reddit.
      operationId: createCarouselGroup
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [child_upload_ids]
              properties:
                child_upload_ids:
                  type: array
                  items: { type: string }
                  minItems: 2
                  maxItems: 50
                  description: |
                    Ordered list of `upload_id` values (from `POST /uploads`)
                    to group. Position 0 is the cover by default.
                cover_index:
                  type: integer
                  minimum: 0
                  default: 0
                  description: |
                    0-based index within `child_upload_ids` to use as the
                    carousel cover image. Defaults to 0 (first item).
      responses:
        "201":
          description: Carousel created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  upload_id:
                    type: string
                    description: |
                      The carousel's `upload_id`. Pass this to `POST /posts`
                      as the `upload_id` to publish the carousel.
                  child_count:
                    type: integer
                  content_type:
                    type: string
                    enum: [carousel]
                  cover_index:
                    type: integer
                  has_video:
                    type: boolean
                  has_image:
                    type: boolean
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404":
          description: One or more upload IDs not found or not finalized.
        "429": { $ref: "#/components/responses/RateLimited" }

  /uploads/{upload_id}:
    parameters:
      - $ref: "#/components/parameters/UploadId"
    get:
      tags: [Uploads]
      summary: Retrieve an upload
      description: |
        Returns the current state of an upload. On the first call after the
        client has PUT bytes to the presigned URL, ShortSync finalizes the
        upload: it reads the stored `Content-Type`, validates it against
        the MIME allow-list, checks per-kind size caps and workspace storage
        quota, and marks the upload `ready`. Polling before the PUT is
        cheap — calls just return `status: "reserved"` with no side effects.

        If the stored `Content-Type` isn't supported, the server deletes
        the S3 object and responds `415 UNSUPPORTED_FILE_TYPE`. Reserve a
        new `upload_id` and retry with a correct `Content-Type` on the PUT.
      operationId: getUpload
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Upload.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Upload" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "413":
          description: |
            Upload exceeds per-kind size cap (2 GB video, 20 MB image) or
            workspace storage quota. The S3 object is deleted server-side
            before this response is returned.
        "415":
          description: |
            The stored `Content-Type` isn't in the allow-list (mp4, mov,
            webm, avi, mkv, jpg, png, webp, heic, gif). The S3 object is
            deleted server-side before this response is returned.
        "429": { $ref: "#/components/responses/RateLimited" }
    delete:
      tags: [Uploads]
      summary: Delete an upload
      description: |
        Deletes the upload from the library, same as deleting it in the
        dashboard. The media and thumbnails are removed and every
        scheduled, queued or draft post made from it is cancelled. Posts
        that are already published stay live on their platforms. A reserved
        upload whose bytes never arrived is simply discarded. Workspace
        clients can't delete. Scope: `uploads:write`.
      operationId: deleteUpload
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Deleted. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /posts:
    get:
      tags: [Posts]
      summary: List posts
      description: |
        Returns posts ordered by `created_at` descending, or soonest first
        with `sort=scheduled_for`. Cursor pagination: keep the same `sort`
        when passing a cursor.
      operationId: listPosts
      security:
        - WorkspaceKey: []
      parameters:
        - name: sort
          in: query
          description: |
            `created_at` (default) lists newest first. `scheduled_for` lists
            soonest first and leaves out posts with no scheduled time.
          schema:
            type: string
            enum: [created_at, scheduled_for]
            default: created_at
        - name: status
          in: query
          schema:
            type: array
            items: { $ref: "#/components/schemas/PostStatus" }
          style: form
          explode: false
        - name: platform
          in: query
          schema:
            type: array
            items: { $ref: "#/components/schemas/Platform" }
          style: form
          explode: false
        - name: connection_id
          in: query
          schema: { type: string }
        - name: created_after
          in: query
          schema: { type: string, format: date-time }
        - name: created_before
          in: query
          schema: { type: string, format: date-time }
        - name: scheduled_after
          in: query
          description: Inclusive lower bound on `scheduled_for`.
          schema: { type: string, format: date-time }
        - name: scheduled_before
          in: query
          description: Exclusive upper bound on `scheduled_for`.
          schema: { type: string, format: date-time }
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Posts.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/PaginatedEnvelope"
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: "#/components/schemas/Post" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    post:
      tags: [Posts]
      summary: Create posts
      description: |
        Creates one post per `target` entry. A single call can fan out an upload
        to multiple platforms; you'll receive one post object per target back,
        each with its own status that progresses asynchronously.

        ### Publish modes

        - `immediate` - publish as soon as processing finishes
        - `scheduled` - publish at `scheduled_for` (top-level or per-target)
        - `draft` - save without publishing; can be promoted via `PATCH /posts/{id}`

        ### Captions and copy

        Top-level `caption` is the default for every non-YouTube target;
        per-target `caption` overrides it. `first_comment` works the same
        way: top-level is the default, per-target overrides. YouTube targets
        ignore `caption` — they read per-target `title` and `description`
        instead (no top-level title/description; use `target.title` /
        `target.description` if you need them set).

        Platform-specific fields like TikTok privacy levels live under
        `target.platform_options`.

        ### Workspace defaults

        Anything you leave out of top-level `caption` / `first_comment`,
        per-target `caption` / `title` / `description` / `first_comment`,
        or `target.platform_options` falls back to the workspace's saved
        preferences. This keeps API-created posts in the same "complete
        settings" state the dashboard would produce.

        Precedence, highest to lowest:

        1. `target.<field>` and `target.platform_options.<platform>.<field>`
        2. Top-level `caption` / `first_comment`
        3. Workspace preferences for this workspace
        4. Field stays unset (publish will fail later if the platform
           requires it)

        Workspace defaults that get applied today include YouTube
        `privacy_status` / `notify_subscribers` / `category_id` /
        `default_language` / `playlist_ids` / `tags` /
        `upload_early_for_review`, TikTok `privacy_level` / `is_aigc` /
        `post_mode`, Instagram `share_to_story` / `collaborators` /
        `user_tags` / `prepend_audio_to_caption`, Facebook
        `share_to_story`, LinkedIn `visibility`, Discord `silent` /
        `mention` / `username` / `threadName`, plus the top-level
        `caption` / `first_comment` and the YouTube-only
        `title` / `description`. To intentionally publish *without* a
        workspace default, send the field explicitly with the value you
        want (an empty string clears text fields).

        ### Partial failure

        Request-shape problems (missing required fields, unknown `upload_id`,
        invalid `scheduled_for`) return `400` and create no posts.

        Per-target operational problems (the connection's token expired, the
        upstream platform rejected the post, the upload isn't ready yet) do
        **not** fail the whole request. You'll get `201` back with one post
        object per target; failed targets carry `status: "failed"` and a
        populated `error` object. Always iterate `data` and check each post's
        `status` instead of relying solely on the HTTP code.
      operationId: createPosts
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/PostCreate" }
            examples:
              fanout:
                summary: Publish one upload to TikTok and YouTube
                value:
                  upload_id: up_01HW0ZAB3CDEFGHJKMNPQRSTUV
                  publish_mode: scheduled
                  scheduled_for: "2026-06-08T15:00:00Z"
                  caption: New recipe just dropped
                  targets:
                    - connection_id: con_01HW0ZC1TIKTOKABCDEFGHJKMN
                      platform_options:
                        tiktok:
                          privacy_level: PUBLIC_TO_EVERYONE
                          disable_comment: false
                    - connection_id: con_01HW0ZC2YOUTUBEABCDEFGHJK
                      title: Quick miso soup in 5 minutes
                      description: Step by step. Full ingredients in the comments.
                      platform_options:
                        youtube:
                          privacy_status: public
                          made_for_kids: false
                          notify_subscribers: true
              textOnly:
                summary: Text-only post to X
                value:
                  publish_mode: immediate
                  caption: Shipping the API beta today.
                  targets:
                    - connection_id: con_01HW0ZC3TWITTERABCDEFGHJK
                      platform_options:
                        twitter:
                          text_only: true
                          reply_settings: everyone
              fullyPopulated:
                summary: Every field, every platform option
                description: |
                  Reference example. Shows every top-level field, every
                  per-target override, and every per-platform option the
                  API accepts. Most real requests use only a handful of
                  these. Use this for discovery, not copy-paste.

                  Only the `platform_options.<platform>` key matching the
                  target's connected platform is read. Per-target fields
                  override top-level `caption` and `first_comment`;
                  those override workspace preferences. Sending an empty
                  string for a text field clears it (the merge is `??`,
                  not `||`).
                value:
                  upload_id: up_01HW0ZAB3CDEFGHJKMNPQRSTUV
                  publish_mode: scheduled
                  scheduled_for: "2026-12-31T15:00:00Z"
                  notify_on_success: true
                  caption: Fallback caption used when a target omits its own
                  first_comment: Default first comment for every target that supports one (not TikTok)
                  targets:
                    - connection_id: con_01TIKTOKABCDEFGHJKMNPQR
                      caption: Per-target caption beats top-level caption
                      scheduled_for: "2027-01-01T12:00:00Z"
                      platform_options:
                        tiktok:
                          post_mode: direct
                          privacy_level: PUBLIC_TO_EVERYONE
                          disable_comment: false
                          disable_duet: false
                          disable_stitch: false
                          is_branded_content: false
                          is_your_brand: false
                          is_aigc: false
                    - connection_id: con_01YOUTUBEABCDEFGHJKMNP
                      title: Different title just for YouTube
                      first_comment: Per-target first comment for YouTube only
                      description: Full long-form description used only for YouTube
                      platform_options:
                        youtube:
                          privacy_status: public
                          made_for_kids: false
                          notify_subscribers: true
                          category_id: "22"
                          default_language: en
                          tags: [cooking, recipe, shorts]
                          playlist_ids: [PLabc123, PLdef456]
                          upload_early_for_review: false
                    - connection_id: con_01INSTAGRAMABCDEFGHJK
                      platform_options:
                        instagram:
                          share_to_feed: true
                          share_to_story: false
                          story_only: false
                          trial_reel: false
                          trial_graduation_strategy: SS_PERFORMANCE
                          audio_name: Original audio - cookingcreator
                          collaborators: [otheraccount]
                          user_tags: [taggeduser]
                    - connection_id: con_01FACEBOOKABCDEFGHJKM
                      platform_options:
                        facebook:
                          share_to_story: false
                          story_only: false
                    - connection_id: con_01TWITTERABCDEFGHJKMN
                      caption: Shorter caption tuned for X
                      platform_options:
                        twitter:
                          reply_settings: everyone
                          community_id: "1500000000000000000"
                          text_only: false
                          for_super_followers_only: false
                    - connection_id: con_01THREADSABCDEFGHJKMN
                      platform_options:
                        threads:
                          text_only: false
                    - connection_id: con_01BLUESKYABCDEFGHJKMN
                      platform_options:
                        bluesky:
                          langs: [en]
                          text_only: false
      responses:
        "201":
          description: |
            Posts created. Each target produced one post. Some posts may carry
            `status: "failed"` if an operational issue prevented them, so inspect
            each entry in `data`.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/Post" }
              examples:
                mixedSuccess:
                  summary: One target succeeded, one failed
                  value:
                    data:
                      - id: post_01HW0ZD1TIKTOKABCDEFGHJKMN
                        workspace_id: ws_01HW0Z9XJ2K3R4M5N6P7Q8S9TU
                        upload_id: up_01HW0ZAB3CDEFGHJKMNPQRSTUV
                        platform: tiktok
                        connection_id: con_01HW0ZC1TIKTOKABCDEFGHJKMN
                        status: scheduled
                        publish_mode: scheduled
                        scheduled_for: "2026-06-08T15:00:00Z"
                        caption: New recipe just dropped
                        error: null
                        created_at: "2026-06-07T13:30:00Z"
                        updated_at: "2026-06-07T13:30:00Z"
                      - id: post_01HW0ZD2YOUTUBEABCDEFGHJK
                        workspace_id: ws_01HW0Z9XJ2K3R4M5N6P7Q8S9TU
                        upload_id: up_01HW0ZAB3CDEFGHJKMNPQRSTUV
                        platform: youtube
                        connection_id: con_01HW0ZC2YOUTUBEABCDEFGHJK
                        status: failed
                        publish_mode: scheduled
                        scheduled_for: "2026-06-08T15:00:00Z"
                        title: Quick miso soup in 5 minutes
                        error:
                          code: CONNECTION_TOKEN_EXPIRED
                          message: YouTube connection needs to be reauthorized.
                        created_at: "2026-06-07T13:30:00Z"
                        updated_at: "2026-06-07T13:30:00Z"
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /posts/{post_id}:
    parameters:
      - $ref: "#/components/parameters/PostId"
    get:
      tags: [Posts]
      summary: Retrieve a post
      operationId: getPost
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Post.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Post" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
    patch:
      tags: [Posts]
      summary: Reschedule or edit a post
      description: |
        Posts in `scheduled`, `ready`, `draft`, or `failed` state can be
        modified. A draft can be promoted to scheduled by setting
        `publish_mode: "scheduled"` and `scheduled_for`. Captions and
        platform options are merged shallowly.

        Captions are checked against the platform's limit (for example
        Snapchat Spotlight's 160 characters) and rejected with
        `400 CAPTION_TOO_LONG` instead of failing later at publish time.

        If the post failed with `CAPTION_TOO_LONG`, fixing its caption
        re-queues it automatically: drafts stay drafts, scheduled posts keep
        their time if it is still in the future, and anything else publishes
        immediately. Pass `publish_mode` / `scheduled_for` to choose
        explicitly. Check `status` in the response.
      operationId: updatePost
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/PostUpdate" }
      responses:
        "200":
          description: Updated.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Post" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "409":
          description: Post is in a state that cannot be edited (already queued, processing, published, or deleted).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }
    delete:
      tags: [Posts]
      summary: Cancel a post
      description: |
        Cancels a `scheduled`, `draft`, or `failed` post. The post's status
        transitions to `deleted`. Use it to clear failed posts you replaced
        with a new one. Published posts cannot be unpublished via this
        endpoint; delete them from the upstream platform.
      operationId: cancelPost
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Cancelled. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "409":
          description: Post is already published and cannot be cancelled.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /posts/{post_id}/replace-media:
    parameters:
      - $ref: "#/components/parameters/PostId"
    post:
      tags: [Posts]
      summary: Replace post media
      description: |
        Swaps the video or image behind a `draft`, `ready`, `scheduled`, or
        `failed` post for another finished upload in the same workspace. The
        post keeps its schedule, captions, first comments and platform
        options; only the file changes.

        With `apply_to_batch: true`, every other post in the same batch
        (same media, same status and, for scheduled posts, the same
        `scheduled_for`) is swapped too. The new file is not re-checked
        against each platform's limits.
      operationId: replacePostMedia
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/PostReplaceMedia" }
      responses:
        "200":
          description: Media replaced. Returns every post that now uses the new media.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/Post" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /posts/{post_id}/retry:
    parameters:
      - $ref: "#/components/parameters/PostId"
    post:
      tags: [Posts]
      summary: Retry a failed post
      description: |
        Publishes a `failed` post again, like the Retry button in the
        dashboard library. Runs the same checks as a new publish
        (subscription, daily platform limit, connection health, caption
        and first comment limits), clears the old error and re-queues the
        post right away, or at `scheduled_for` when given. Doesn't use
        another monthly upload credit. Scope: `posts:write`.
      operationId: retryPost
      security:
        - WorkspaceKey: []
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                scheduled_for:
                  type: string
                  format: date-time
                  description: Publish at this time instead of now. Must be in the future and at most a year out.
      responses:
        "200":
          description: Post re-queued.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Post" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "409":
          description: The post isn't failed (POST_NOT_RETRYABLE), or its account needs reconnecting (CONNECTION_NOT_FOUND, ACCOUNT_NEEDS_RECONNECT, TOKEN_EXPIRED, ACCOUNT_SUSPENDED, RATE_LIMITED).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /posts/{post_id}/delete-from-platform:
    parameters:
      - $ref: "#/components/parameters/PostId"
    post:
      tags: [Posts]
      summary: Delete a published post from its platform
      description: |
        Deletes a `published` post from the social platform it went out
        on, like "Delete from platform" in the dashboard. Irreversible. The
        ShortSync post stays as an audit record with status `removed`; the
        upload is kept. If the platform says the post is already gone, the
        call still succeeds with `already_deleted: true`.

        Not every platform allows it. TikTok, Snapchat and Reddit return
        400 `PLATFORM_DELETE_UNSUPPORTED` (delete in the app instead), as do
        Instagram and Threads until deletion is enabled for the account.
        A connection missing the delete permission returns
        `PLATFORM_DELETE_MISSING_SCOPE`; a disconnected one returns
        `PLATFORM_NOT_CONNECTED`. Posts that aren't published return
        `INVALID_POST_STATUS`: to drop a draft, scheduled or failed post,
        use `DELETE /posts/{post_id}`. Scope: `posts:write`.
      operationId: deletePostFromPlatform
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Deleted from the platform.
          content:
            application/json:
              schema:
                type: object
                required: [post_id, platform, status, already_deleted]
                properties:
                  post_id: { type: string, format: uuid }
                  platform: { type: string }
                  status: { type: string, enum: [removed] }
                  already_deleted:
                    type: boolean
                    description: True when the platform reported the post was already gone.
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /posting-slots:
    get:
      tags: [Posts]
      summary: Get posting time slots
      description: |
        The API key owner's saved daily posting times in this workspace (the
        queue set in Settings and the scheduling step) and `next_slots`, the
        next free slots as UTC timestamps. A slot is free when no scheduled
        post in the workspace sits at that minute and it isn't inside a
        "no posts" break on the calendar, the same checks the web
        scheduling step uses. Times are read in `timezone`;
        `effective_timezone` is `UTC` when none is saved.
        `move_posts_past_limits` is the workspace setting that moves a
        scheduled post to its next free slot when it hits a daily limit.
        Scope: `posts:read`.
      operationId: getPostingSlots
      security:
        - WorkspaceKey: []
      parameters:
        - name: count
          in: query
          description: How many next free slots to return (1 to 50). Defaults to 5.
          schema: { type: integer, minimum: 1, maximum: 50, default: 5 }
      responses:
        "200":
          description: Posting slots.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/PostingSlots" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    put:
      tags: [Posts]
      summary: Update posting time slots
      description: |
        Replace the key owner's posting times in this workspace. Pass `times`
        (hand-picked, clears `interval`) or `interval` (a range that generates
        the times), not both. Omitted fields are left as they are.
        `move_posts_past_limits` changes a workspace setting, so the key owner
        must be a workspace owner or admin; it can be sent on its own.
        Scope: `posts:write`.
      operationId: updatePostingSlots
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                times:
                  type: array
                  items: { type: string, pattern: "^([01]\\d|2[0-3]):[0-5]\\d$" }
                  maxItems: 96
                  description: Daily 24-hour "HH:mm" times. An empty array clears them.
                interval:
                  type: object
                  nullable: true
                  description: Generate times from a range. An end at or before the start wraps past midnight. null clears the interval and keeps the times.
                  required: [start_time, end_time, interval_minutes]
                  properties:
                    start_time: { type: string, example: "08:00" }
                    end_time: { type: string, example: "22:00" }
                    interval_minutes: { type: integer, enum: [15, 30, 60, 120, 180, 240, 360, 480, 720] }
                timezone:
                  type: string
                  nullable: true
                  description: IANA timezone the times are in, e.g. Europe/Helsinki. null clears it (UTC is used).
                platform_times:
                  type: object
                  nullable: true
                  additionalProperties: { type: string }
                  description: 'Per-platform default times, e.g. { "twitter": "07:00" }. null clears them.'
                move_posts_past_limits:
                  type: boolean
                  description: Workspace setting, on by default. true moves a scheduled post to its next free slot when it hits a daily limit; false lets it fail. Applies to the whole workspace.
      responses:
        "200":
          description: Saved slots plus the next 5 free slots.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/PostingSlots" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /connections:
    get:
      tags: [Connections]
      summary: List connected platform accounts
      operationId: listConnections
      security:
        - WorkspaceKey: []
      parameters:
        - name: platform
          in: query
          schema:
            type: array
            items: { $ref: "#/components/schemas/Platform" }
          style: form
          explode: false
        - name: status
          in: query
          schema:
            type: array
            items: { $ref: "#/components/schemas/ConnectionStatus" }
          style: form
          explode: false
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Connections.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/PaginatedEnvelope"
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: "#/components/schemas/Connection" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /connections/{connection_id}:
    parameters:
      - $ref: "#/components/parameters/ConnectionId"
    get:
      tags: [Connections]
      summary: Retrieve a connection
      operationId: getConnection
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Connection.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Connection" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /connections/connect-link:
    post:
      tags: [Connections]
      summary: Create a connect link
      description: |
        Returns a link the user opens to connect a platform to the
        workspace, or to reconnect one. It opens ShortSync, switches to the
        workspace and starts the platform's sign-in, the same as the Connect
        button. Connecting always needs the user (platform sign-in and
        consent), so show or send this link instead of handling OAuth
        yourself, then poll `GET /connections`.

        The link carries no credentials and doesn't expire: it only works
        in a browser where someone is signed in to ShortSync with access to
        the workspace.
      operationId: createConnectLink
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [platform]
              properties:
                platform: { $ref: "#/components/schemas/Platform" }
      responses:
        "200":
          description: Connect link.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ConnectLink" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /auth/discord/webhook:
    post:
      tags: [Connections]
      summary: Connect a Discord channel
      description: |
        Adds a Discord channel to the workspace by its webhook URL. In
        Discord, open Server Settings → Integrations → Webhooks, pick the
        channel, and use Copy Webhook URL.

        Works for every channel type, including forum channels, which the
        dashboard's "Add a channel with Discord" screen can't list. In a
        forum channel each post becomes a new forum post titled with
        `platform_options.discord.thread_name` (or the caption's first
        line), and `first_comment` is its first reply. In text channels
        `first_comment` is a separate message right after the post.

        The URL is checked against Discord and stored encrypted; it is never
        returned. A workspace has one Discord connection that can hold
        several channels: each call with a new webhook adds a channel and
        returns the same connection `id`; posting a webhook that's already
        connected refreshes that channel. The first channel becomes a
        default channel; later ones are added with `is_default: false`
        (change it with `PATCH /api/v1/discord/channels/{channel_id}`).
      operationId: connectDiscordWebhook
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [webhook_url]
              properties:
                webhook_url:
                  type: string
                  format: uri
                  example: https://discord.com/api/webhooks/123456789012345678/abcDEF...
                label:
                  type: string
                  maxLength: 100
                  description: Display name for the channel. Defaults to the webhook's name.
      responses:
        "200":
          description: |
            The workspace's Discord connection, plus the channel that was
            added in `channel`.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/Connection"
                  - type: object
                    required: [channel]
                    properties:
                      channel: { $ref: "#/components/schemas/DiscordChannel" }
        "400":
          description: |
            Missing or malformed webhook URL (`MISSING_WEBHOOK_URL`,
            `INVALID_WEBHOOK_URL`), the webhook no longer exists
            (`WEBHOOK_NOT_FOUND`), it isn't a regular incoming webhook
            (`UNSUPPORTED_WEBHOOK_TYPE`), or Discord couldn't be reached
            (`WEBHOOK_LOOKUP_FAILED`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /discord/channels:
    get:
      tags: [Connections]
      summary: List Discord channels
      description: |
        Lists the Discord channels connected to the workspace, oldest
        first. Use a channel's `id` in
        `platform_options.discord.channel_ids`; posts that don't set it go
        to every channel with `is_default: true`. Webhook URLs are never
        returned.
      operationId: listDiscordChannels
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Channels.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/DiscordChannel" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /discord/channels/{channel_id}:
    parameters:
      - name: channel_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    patch:
      tags: [Connections]
      summary: Update a Discord channel
      description: Rename a channel or change whether it's a default target.
      operationId: updateDiscordChannel
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  minLength: 1
                  maxLength: 100
                is_default:
                  type: boolean
                  description: Pre-select this channel for posts that don't set `channel_ids`.
      responses:
        "200":
          description: The updated channel.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/DiscordChannel" }
        "400":
          description: |
            Invalid or empty body (`INVALID_LABEL`, `INVALID_IS_DEFAULT`,
            `EMPTY_UPDATE`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
    delete:
      tags: [Connections]
      summary: Remove a Discord channel
      description: |
        Removes the channel from ShortSync. The webhook itself stays in
        the Discord server; delete it there to revoke it. Removing the
        last channel deactivates the workspace's Discord connection.
      operationId: deleteDiscordChannel
      security:
        - WorkspaceKey: []
      responses:
        "204":
          description: Removed.
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /google-business/locations:
    get:
      tags: [Connections]
      summary: List Google Business Profile locations
      description: |
        Lists the business locations the workspace's Google Business
        Profile connection manages (one Google login can manage several).
        Use a location's `id` in
        `platform_options.google_business.location_ids`; posts that don't
        set it go to every location with `is_default: true`. Returns an
        empty list when Google Business Profile isn't connected. Beta:
        accounts without access get `403 GOOGLE_BUSINESS_BETA_REQUIRED`.
      operationId: listGoogleBusinessLocations
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Locations.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/GoogleBusinessLocation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    patch:
      tags: [Connections]
      summary: Set default Google Business Profile locations
      description: |
        Replaces which locations posts go to when they don't set
        `location_ids`. Locations not in the list stop being defaults.
      operationId: updateGoogleBusinessDefaultLocations
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [default_location_ids]
              properties:
                default_location_ids:
                  type: array
                  items: { type: string }
                  description: Location ids from `GET /api/v1/google-business/locations`.
      responses:
        "200":
          description: All locations, with the updated `is_default`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/GoogleBusinessLocation" }
        "400":
          description: |
            Invalid body (`INVALID_DEFAULT_LOCATION_IDS`) or an id that
            isn't one of the connection's locations
            (`GOOGLE_BUSINESS_LOCATION_NOT_FOUND`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404":
          description: Google Business Profile isn't connected (`GOOGLE_BUSINESS_NOT_CONNECTED`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /platforms/pinterest/boards:
    get:
      tags: [Connections]
      summary: List Pinterest boards
      description: |
        Lists the boards on the Pinterest account connected to the
        workspace. Use a board's `id` as `platform_options.pinterest.board_id`.
      operationId: listPinterestBoards
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Boards.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: { type: string }
                        name: { type: string }
                        description: { type: string, nullable: true }
                        privacy:
                          type: string
                          description: e.g. `PUBLIC`, `PROTECTED`, `SECRET`.
        "400":
          description: Pinterest is not connected for this workspace (`PINTEREST_NOT_CONNECTED`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /platforms/pinterest/boards/{board_id}/sections:
    get:
      tags: [Connections]
      summary: List a Pinterest board's sections
      description: |
        Lists the sections of one board on the connected Pinterest account.
        Use a section's `id` as `platform_options.pinterest.board_section_id`
        to put the Pin in that section. Empty when the board has none.
      operationId: listPinterestBoardSections
      security:
        - WorkspaceKey: []
      parameters:
        - name: board_id
          in: path
          required: true
          schema: { type: string }
          description: A board `id` from List Pinterest boards.
      responses:
        "200":
          description: Sections.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: { type: string }
                        name: { type: string }
        "400":
          description: Pinterest isn't connected (`PINTEREST_NOT_CONNECTED`) or the board id is invalid (`INVALID_BOARD_ID`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /opusclip/projects:
    get:
      tags: [Imports]
      summary: List OpusClip projects
      description: |
        The OpusClip projects of the key's creator, newest first, 24 per
        page. Uses the OpusClip API key they saved in Settings >
        Integrations (OpusClip Pro plan or higher). Pass `project_id` and
        `org_id` to list and import a project's clips.
      operationId: listOpusClipProjects
      deprecated: true
      security:
        - WorkspaceKey: []
      parameters:
        - name: page
          in: query
          schema: { type: integer, minimum: 0, default: 0 }
          description: 0-based page number.
      responses:
        "200":
          description: Projects.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/OpusClipProject" }
                  has_next: { type: boolean }
                  total: { type: integer }
        "400":
          description: |
            OpusClip isn't connected (`OPUSCLIP_NOT_CONNECTED`), the saved
            key was rejected (`OPUSCLIP_KEY_REJECTED`) or OpusClip returned
            an error (`OPUSCLIP_ERROR`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /opusclip/projects/{project_id}/clips:
    get:
      tags: [Imports]
      summary: List an OpusClip project's clips
      description: |
        The clips OpusClip made in one project, with the caption an import
        gets (OpusClip's description plus hashtags).
      operationId: listOpusClipClips
      deprecated: true
      security:
        - WorkspaceKey: []
      parameters:
        - name: project_id
          in: path
          required: true
          schema: { type: string }
        - name: org_id
          in: query
          required: true
          schema: { type: string }
          description: The project's `org_id` from `GET /opusclip/projects`.
      responses:
        "200":
          description: Clips.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/OpusClipClip" }
        "400":
          description: Missing `org_id` (`MISSING_ORG_ID`) or an OpusClip error (see list projects).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /opusclip/imports:
    post:
      tags: [Imports]
      summary: Import OpusClip clips
      description: |
        Imports up to 20 clips of one project into the workspace library.
        OpusClip renders each clip first, so this takes 15 to 90 seconds.
        Returns per clip the new `upload_id` (pass it to `POST /posts`),
        the caption and the title. Clips that fail come back with
        `ok: false` and an error; the others are still imported.
      operationId: importOpusClipClips
      deprecated: true
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [project_id, org_id, clip_ids]
              properties:
                project_id: { type: string }
                org_id: { type: string }
                clip_ids:
                  type: array
                  maxItems: 20
                  items: { type: string }
                  description: Clip ids from the project's clip list.
      responses:
        "201":
          description: Import results.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ClipImportResults" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /imports/sources:
    get:
      tags: [Imports]
      summary: List import sources
      description: |
        The sources the key creator can import from (OpusClip, Canva, Twitch,
        ...), whether each is connected in Settings > Integrations, whether
        its items sit in projects (`has_containers`), search support, the
        per-call cap and its options. Sources in beta only appear for
        accounts that have them.
      operationId: listImportSources
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Sources.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/ImportSource" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /imports/{source}/items:
    get:
      tags: [Imports]
      summary: List items to import
      description: |
        For a source with projects, returns `kind: containers` until a
        `container_id` is passed, then that project's items. Pass
        `next_cursor` back as `cursor` for the next page. List options
        (e.g. `range` for twitch) go in the query string.
      operationId: listImportItems
      security:
        - WorkspaceKey: []
      parameters:
        - name: source
          in: path
          required: true
          schema: { type: string, example: opusclip }
        - name: container_id
          in: query
          schema: { type: string }
        - name: query
          in: query
          schema: { type: string }
          description: Search text, for sources with `supports_query`.
        - name: cursor
          in: query
          schema: { type: string }
          description: "`next_cursor` from the previous page."
      responses:
        "200":
          description: Containers or items.
          content:
            application/json:
              schema:
                type: object
                properties:
                  source: { type: string }
                  kind: { type: string, enum: [containers, items] }
                  container_id: { type: string, nullable: true }
                  containers:
                    type: array
                    items: { $ref: "#/components/schemas/ImportContainer" }
                  items:
                    type: array
                    items: { $ref: "#/components/schemas/ImportItem" }
                  next_cursor: { type: string, nullable: true }
        "400":
          description: |
            Unknown source (`UNKNOWN_SOURCE`), a bad option (`BAD_OPTION`),
            the source isn't connected (`<SOURCE>_NOT_CONNECTED`), its key or
            sign-in was rejected (`<SOURCE>_KEY_REJECTED`) or it returned an
            error (`<SOURCE>_ERROR`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /imports:
    post:
      tags: [Imports]
      summary: Import items
      description: |
        Imports items from a connected source into the workspace library.
        Returns per item the new `upload_id` (pass it to `POST /posts`), a
        caption and a title. Items that fail come back with `ok: false` and
        an error; the others are still imported. Sources that render first
        can take up to 2.5 minutes.
      operationId: importItems
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [source, item_ids]
              properties:
                source: { type: string, example: opusclip }
                item_ids:
                  type: array
                  items: { type: string }
                  description: Item ids from `GET /imports/{source}/items`, up to the source's `max_per_import`.
                container_id:
                  type: string
                  description: Required for sources with projects.
                options:
                  type: object
                  additionalProperties: { type: string }
                  description: 'Import options from the source, e.g. `{ "format": "mp4" }`.'
      responses:
        "201":
          description: Import results.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ImportResults" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/account-growth:
    get:
      tags: [Analytics]
      summary: Account growth
      description: |
        Per connected account: current follower, subscriber, following and
        post counts, the previous counts at `from`, and the growth between
        them. YouTube, Facebook and Instagram deltas come live from the
        platform when `from` is set (Instagram caps at 30 days, flagged by
        `growth_window_days`); others come from daily snapshots. Google
        Business Profile entries add `google_business` profile stats.
        Scope: `analytics:read`.
      operationId: getAccountGrowth
      security:
        - WorkspaceKey: []
      parameters:
        - name: from
          in: query
          description: ISO 8601 window start. Omit for lifetime counts without deltas.
          schema: { type: string, format: date-time }
        - name: to
          in: query
          description: ISO 8601 window end. Defaults to now.
          schema: { type: string, format: date-time }
        - name: platform
          in: query
          description: Comma-separated platform filter.
          schema: { type: string }
      responses:
        "200":
          description: Account growth per connection.
          content:
            application/json:
              schema:
                type: object
                required: [account_growth]
                properties:
                  account_growth: { type: array, items: { type: object } }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/summary:
    get:
      tags: [Analytics]
      summary: Workspace analytics summary
      description: |
        Cross-platform totals and a per-platform breakdown for a time
        window. Numbers are post-summed from ShortSync's store. The
        dashboard additionally overlays account-level API numbers for
        Instagram, YouTube, and TikTok when they're available; that
        overlay isn't wired through the public API yet, so results here
        may undercount vs. the dashboard. The per-row `last_synced_at`
        tells you how stale the data is; `POST /analytics/sync` to
        refresh.
      operationId: getAnalyticsSummary
      security:
        - WorkspaceKey: []
      parameters:
        - name: from
          in: query
          description: ISO 8601 lower bound on the post's `published_at`. Defaults to the beginning of time.
          schema: { type: string, format: date-time }
        - name: to
          in: query
          description: ISO 8601 upper bound. Defaults to now.
          schema: { type: string, format: date-time }
        - name: platform
          in: query
          description: Comma-separated platform filter. e.g. `instagram,youtube`.
          schema: { type: string }
      responses:
        "200":
          description: Summary.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data: { $ref: "#/components/schemas/AnalyticsSummary" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/instagram-compare:
    get:
      tags: [Analytics]
      summary: Compare Instagram accounts
      description: |
        Compares the workspace's Instagram account with up to 5 other
        public Instagram Business or Creator accounts, read live from
        Instagram: followers, total posts, and over each account's last 12
        posts the average likes, comments and Reel views, engagement rate
        (average likes + comments / followers, in percent) and posts per
        week. The workspace's own account is always returned as `own`.
        Personal or age-gated accounts come back with `ok: false` and an
        `error`. Needs Facebook Login for Instagram on the workspace;
        without it the response is 428 `FACEBOOK_LOGIN_REQUIRED`.
      operationId: compareInstagramAccounts
      security:
        - WorkspaceKey: []
      parameters:
        - name: usernames
          in: query
          description: Comma-separated Instagram usernames, up to 5 (with or without @, or profile links). Omit to get only your own account.
          schema: { type: string }
          example: natgeo,instagram
      responses:
        "200":
          description: Comparison.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    properties:
                      workspace_id: { type: string }
                      own: { $ref: "#/components/schemas/InstagramCompareAccount" }
                      accounts:
                        type: array
                        items: { $ref: "#/components/schemas/InstagramCompareAccount" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "428":
          description: The workspace has no Facebook Login for Instagram, or it was connected before account comparison was available. Reconnect Facebook Login.
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/posts:
    get:
      tags: [Analytics]
      summary: List post analytics
      description: |
        Per-post analytics snapshots, cursor-paginated. `metrics.*` fields
        use `null` (not `0`) to mean "unknown" or "the platform's insights
        scope wasn't granted on this connection". Treat them differently
        in aggregations you display.

        The cursor is bound to the current `sort` key; don't switch sort
        mid-pagination.
      operationId: listPostAnalytics
      security:
        - WorkspaceKey: []
      parameters:
        - name: platform
          in: query
          description: Comma-separated platform filter.
          schema: { type: string }
        - name: connection_id
          in: query
          description: Narrow to one connection.
          schema: { type: string }
        - name: published_after
          in: query
          description: ISO 8601 lower bound on the post's `published_at`.
          schema: { type: string, format: date-time }
        - name: published_before
          in: query
          description: ISO 8601 upper bound.
          schema: { type: string, format: date-time }
        - name: sort
          in: query
          description: |
            Sort key. `fetched_at_desc` (default), `published_at_desc`, or
            `views_desc`.
          schema:
            type: string
            enum: [fetched_at_desc, published_at_desc, views_desc]
            default: fetched_at_desc
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Page of analytics rows.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/PaginatedEnvelope"
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: "#/components/schemas/PostAnalytics" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/posts/{post_id}:
    parameters:
      - name: post_id
        in: path
        required: true
        description: The post's UUID (matches the id returned by `POST /posts`).
        schema: { type: string, format: uuid }
    get:
      tags: [Analytics]
      summary: Retrieve post analytics
      description: |
        The same shape as one row of `GET /analytics/posts`, for a specific
        post. Returns `404` when the post isn't in the resolved workspace
        so callers can't probe for arbitrary ids.
      operationId: getPostAnalytics
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Post analytics.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data: { $ref: "#/components/schemas/PostAnalytics" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/posts/{post_id}/retention:
    parameters:
      - name: post_id
        in: path
        required: true
        description: The YouTube post's UUID (matches the id returned by `POST /posts`).
        schema: { type: string, format: uuid }
    get:
      tags: [Analytics]
      summary: Get YouTube retention
      description: |
        Audience retention for one published YouTube post, read live from
        YouTube: the share of viewers still watching through the video, how
        each point compares with YouTube videos of similar length, and a
        summary at 25%, 50% and the end. Call once per post to compare
        videos. Other platforms return 404 `YOUTUBE_POST_NOT_FOUND`; videos
        without retention data yet return 400 `RETENTION_UNAVAILABLE`.
        Beta: accounts without YouTube insights get 403.
      operationId: getYouTubeRetention
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Retention curve and summary.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    properties:
                      post_id: { type: string, format: uuid }
                      video_id: { type: string, description: YouTube videoId. }
                      duration_seconds: { type: [integer, "null"] }
                      summary:
                        type: object
                        properties:
                          retention_25: { type: [number, "null"], description: Percent still watching at 25% of the video. }
                          retention_50: { type: [number, "null"], description: Percent still watching halfway. }
                          retention_end: { type: [number, "null"], description: Percent still watching at the end. }
                          vs_similar_videos:
                            type: [string, "null"]
                            description: Above, Like or Below similar videos, averaged over the video.
                      points:
                        type: array
                        items:
                          type: object
                          properties:
                            ratio: { type: number, description: Position in the video, 0 to 1. }
                            watch_ratio: { type: number, description: Share of viewers still watching; can pass 1 on rewatches. }
                            relative_performance:
                              type: [number, "null"]
                              description: Compared with YouTube videos of similar length, 0 to 1 (0.5 is typical).
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/youtube-audience:
    get:
      tags: [Analytics]
      summary: Get YouTube audience
      description: |
        Who watches the workspace's YouTube channel, read live from YouTube
        for a date window: age, gender, top 10 countries, devices, views from
        subscribers vs. not, and traffic sources. Age and gender can be empty
        for small channels. Without a connected YouTube account the response
        is 404 `YOUTUBE_NOT_CONNECTED`. Beta: accounts without YouTube
        insights get 403.
      operationId: getYouTubeAudience
      security:
        - WorkspaceKey: []
      parameters:
        - name: from
          in: query
          description: Window start (ISO 8601). Omit for the channel's lifetime.
          schema: { type: string }
        - name: to
          in: query
          description: Window end (ISO 8601). Defaults to today.
          schema: { type: string }
      responses:
        "200":
          description: Audience breakdown.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    properties:
                      workspace_id: { type: string }
                      start_date: { type: string, format: date }
                      end_date: { type: string, format: date }
                      age: { type: array, items: { $ref: "#/components/schemas/YouTubeAudienceSlice" } }
                      gender: { type: array, items: { $ref: "#/components/schemas/YouTubeAudienceSlice" } }
                      countries: { type: array, items: { $ref: "#/components/schemas/YouTubeAudienceSlice" } }
                      devices: { type: array, items: { $ref: "#/components/schemas/YouTubeAudienceSlice" } }
                      subscribed: { type: array, items: { $ref: "#/components/schemas/YouTubeAudienceSlice" } }
                      traffic_sources: { type: array, items: { $ref: "#/components/schemas/YouTubeAudienceSlice" } }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/sync:
    post:
      tags: [Analytics]
      summary: Trigger an async sync
      description: |
        Kicks off a fresh sync from every connected platform (or one, if
        `platform` is set). Returns `202 Accepted` immediately with a
        `job_id`; the actual multi-minute work runs in a background
        worker. Poll `data.status_url` until the job reports
        `completed`.

        Only one queued/running sync per workspace at a time. Repeat
        requests while a job is in flight return `409 SYNC_IN_PROGRESS`
        with the existing `job_id` in `details` so clients can attach to
        it instead of retrying.

        Idempotency-safe: replay the same `Idempotency-Key` within the
        retention window and the original 202 payload is returned instead
        of enqueueing a duplicate.
      operationId: triggerAnalyticsSync
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: false
        content:
          application/json:
            schema: { $ref: "#/components/schemas/AnalyticsSyncCreate" }
      responses:
        "202":
          description: Sync job enqueued.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    { $ref: "#/components/schemas/AnalyticsSyncJobAccepted" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409":
          description: |
            Another sync is already in flight for this workspace. `details`
            carries the existing `job_id` and `status_url`.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
              example:
                status: 409
                code: SYNC_IN_PROGRESS
                message: A sync is already in progress for this workspace.
                details:
                  job_id: 42f7d1b3-c106-4ed6-95b5-c0e76086c957
                  status: running
                  status_url: https://api.shortsync.app/v1/analytics/sync/42f7d1b3-...
                  requested_at: 2026-07-08T14:11:34.221Z
        "429": { $ref: "#/components/responses/RateLimited" }

  /analytics/sync/{job_id}:
    parameters:
      - name: job_id
        in: path
        required: true
        description: The sync job's UUID (returned by `POST /analytics/sync`).
        schema: { type: string, format: uuid }
    get:
      tags: [Analytics]
      summary: Get sync job status
      description: |
        Poll a sync job's status. Requires the `analytics:read` scope only.
        Observing your own jobs is a read operation, so no write scope is
        needed.
      operationId: getAnalyticsSyncJob
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Job status.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data: { $ref: "#/components/schemas/AnalyticsSyncJob" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /webhooks:
    get:
      tags: [Webhooks]
      summary: List webhooks
      description: |
        The workspace's webhook endpoints, oldest first. Secrets are never
        returned.
      operationId: listWebhooks
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Webhooks.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/Webhook" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    post:
      tags: [Webhooks]
      summary: Create a webhook
      description: |
        Subscribe a public https URL to post events (REST hooks, as used by
        Zapier, Make and n8n). Up to 10 per workspace. The response includes
        `secret`, shown only once. Each delivery is a POST with the event
        payload and an `X-ShortSync-Signature: t=<unix>,v1=<hex>` header,
        an HMAC-SHA256 of `<t>.<raw body>` with the secret.
      operationId: createWebhook
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/WebhookCreate" }
      responses:
        "201":
          description: Created. Includes `secret`.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Webhook" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409":
          description: The workspace already has 10 webhooks (`WEBHOOK_LIMIT_REACHED`).
        "429": { $ref: "#/components/responses/RateLimited" }

  /webhooks/{webhook_id}:
    parameters:
      - name: webhook_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    get:
      tags: [Webhooks]
      summary: Get a webhook
      operationId: getWebhook
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: The webhook.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Webhook" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
    patch:
      tags: [Webhooks]
      summary: Update a webhook
      description: |
        Change the URL, events or description, or turn it on or off.
        Turning it back on resets its failure count.
      operationId: updateWebhook
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url: { type: string, format: uri }
                events:
                  type: array
                  items: { $ref: "#/components/schemas/WebhookEvent" }
                description: { type: string, maxLength: 200, nullable: true }
                active: { type: boolean }
      responses:
        "200":
          description: The updated webhook.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Webhook" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
    delete:
      tags: [Webhooks]
      summary: Delete a webhook
      operationId: deleteWebhook
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Deleted. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }

  /webhooks/{webhook_id}/test:
    parameters:
      - name: webhook_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    post:
      tags: [Webhooks]
      summary: Send a test event
      description: Deliver a signed `webhook.test` event now (one attempt) and return the endpoint's answer.
      operationId: testWebhook
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Result of the delivery.
          content:
            application/json:
              schema:
                type: object
                properties:
                  delivery_id: { type: string, format: uuid }
                  status: { type: string, enum: [delivered, failed] }
                  response_status: { type: integer, nullable: true }
                  error: { type: string, nullable: true }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
        "409":
          description: The webhook is turned off (`WEBHOOK_INACTIVE`).

  /webhooks/{webhook_id}/roll-secret:
    parameters:
      - name: webhook_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    post:
      tags: [Webhooks]
      summary: Roll the signing secret
      description: Replace the secret. The old one stops working right away.
      operationId: rollWebhookSecret
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: The webhook, including the new `secret`.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Webhook" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }

  /webhooks/{webhook_id}/deliveries:
    parameters:
      - name: webhook_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    get:
      tags: [Webhooks]
      summary: List deliveries
      description: Recent deliveries, newest first.
      operationId: listWebhookDeliveries
      security:
        - WorkspaceKey: []
      parameters:
        - name: limit
          in: query
          schema: { type: integer, minimum: 1, maximum: 100, default: 25 }
      responses:
        "200":
          description: Deliveries.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/WebhookDelivery" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }

  /repurposing/workflows:
    get:
      tags: [Repurposing]
      summary: List workflows
      description: |
        The workspace's Repurposing workflows, oldest first. Needs
        `posts:read`. Clients in the workspace can't manage workflows.
      operationId: listRepurposingWorkflows
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Workflows.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/RepurposingWorkflow" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    post:
      tags: [Repurposing]
      summary: Create a workflow
      description: |
        Repost an Instagram or Facebook Page account's posts to other
        connected accounts. `kind: new_posts` (default) reposts each new
        post; `kind: existing` reposts older posts on a weekly timetable
        (`schedule_slots` + `timezone` required) and schedules them into the
        library up to 30 days ahead. Each repost counts as one upload.
      operationId: createRepurposingWorkflow
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required: [target_connection_ids]
                  properties:
                    source_connection_id:
                      type: string
                      format: uuid
                      description: Instagram or Facebook Page connection to repost from. Send this or source_integration. Can't be changed later.
                    source_integration:
                      type: string
                      enum: [twitch]
                      description: Repost clips from the key creator's connected Twitch channel (vertical when Twitch has it, clip title as the caption), every new clip (kind new_posts) or older clips on a timetable (kind existing). Send this or source_connection_id. Can't be changed later.
                    kind:
                      type: string
                      enum: [new_posts, existing]
                      default: new_posts
                - $ref: "#/components/schemas/RepurposingWorkflowSettings"
      responses:
        "201":
          description: Created.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/RepurposingWorkflow" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /repurposing/workflows/{workflow_id}:
    parameters:
      - name: workflow_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    get:
      tags: [Repurposing]
      summary: Get a workflow
      operationId: getRepurposingWorkflow
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: The workflow.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/RepurposingWorkflow" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
    patch:
      tags: [Repurposing]
      summary: Update a workflow
      description: |
        Change any setting except the source and kind. `enabled: false`
        pauses it; for a scheduled workflow `stop_action` says what happens
        to its upcoming posts (`drafts` by default, or `remove`). A
        new-posts workflow turned back on starts from then.
      operationId: updateRepurposingWorkflow
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/RepurposingWorkflowSettings"
                - type: object
                  properties:
                    stop_action: { $ref: "#/components/schemas/RepurposingStopAction" }
      responses:
        "200":
          description: The updated workflow.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/RepurposingWorkflow" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
    delete:
      tags: [Repurposing]
      summary: Delete a workflow
      description: |
        Reposts that went out stay in the library and on the platforms. A
        scheduled workflow's upcoming posts become drafts (default) or are
        removed.
      operationId: deleteRepurposingWorkflow
      security:
        - WorkspaceKey: []
      parameters:
        - name: stop_action
          in: query
          schema: { $ref: "#/components/schemas/RepurposingStopAction" }
      responses:
        "204": { description: Deleted. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }

  /repurposing/workflows/{workflow_id}/sync:
    parameters:
      - name: workflow_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    post:
      tags: [Repurposing]
      summary: Sync a workflow
      description: |
        Run the workflow now instead of at its next 15-minute run and get
        back what it did. Once a minute for new-posts workflows, every 5
        minutes for scheduled ones (`429 SYNCED_RECENTLY` otherwise). A
        paused workflow returns `400 WORKFLOW_PAUSED`.
      operationId: syncRepurposingWorkflow
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: What the run did.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      posted: { type: integer }
                      scheduled: { type: integer }
                      drafted: { type: integer }
                      skipped: { type: integer }
                      failed: { type: integer }
                      waiting:
                        type: integer
                        description: New posts held back while ShortSync is itself publishing to the source account.
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /repurposing/workflows/{workflow_id}/posts:
    parameters:
      - name: workflow_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    get:
      tags: [Repurposing]
      summary: List a workflow's posts
      description: What the workflow reposted, scheduled or skipped, newest first.
      operationId: listRepurposingWorkflowPosts
      security:
        - WorkspaceKey: []
      parameters:
        - name: status
          in: query
          schema: { type: string, enum: [scheduled, posted, drafted, skipped, failed] }
        - name: limit
          in: query
          schema: { type: integer, minimum: 1, maximum: 100, default: 25 }
        - name: cursor
          in: query
          schema: { type: string }
      responses:
        "200":
          description: A page of entries.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/PaginatedEnvelope"
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: "#/components/schemas/RepurposingWorkflowPost" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }

  /repurposing/workflows/{workflow_id}/posts/{post_id}/cancel:
    parameters:
      - name: workflow_id
        in: path
        required: true
        schema: { type: string, format: uuid }
      - name: post_id
        in: path
        required: true
        description: The entry's `id` from the workflow's posts list.
        schema: { type: string, format: uuid }
    post:
      tags: [Repurposing]
      summary: Cancel a repost
      description: |
        Remove an upcoming repost's scheduled posts from the library. The
        workflow won't pick that source post again. `400
        ITEM_NOT_SCHEDULED` when it already went out.
      operationId: cancelRepurposingWorkflowPost
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Cancelled. }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }

  /members:
    get:
      tags: [Team]
      summary: List workspace members
      description: |
        Lists the people who can log in to the workspace, owner first. Any
        member can list. These are team members, not tagged workspace
        people. Scope: `members:read`.
      operationId: listMembers
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Members.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/Member" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }

  /members/{user_id}:
    parameters:
      - name: user_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    patch:
      tags: [Team]
      summary: Change a member's role
      description: |
        Sets a member's role to `member`, `admin` or `owner`. Only the
        workspace owner can do this, and not on themselves. Role `owner`
        transfers ownership: the acting owner becomes an admin.
        Scope: `members:write`.
      operationId: updateMemberRole
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [role]
              properties:
                role: { type: string, enum: [member, admin, owner] }
      responses:
        "200":
          description: Role updated.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/Member"
                  - type: object
                    properties:
                      ownership_transferred: { type: boolean }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
    delete:
      tags: [Team]
      summary: Remove a member
      description: |
        Removes a member from the workspace, or leaves it when `user_id` is
        the key creator. Owners and admins can remove others; admins can't
        remove owners or admins; the owner can't be removed or leave
        without transferring ownership first. Scope: `members:write`.
      operationId: removeMember
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Removed. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }

  /invitations:
    get:
      tags: [Team]
      summary: List pending invitations
      description: |
        Lists pending, unexpired invitations to the workspace. Owners and
        admins only. Scope: `members:read`.
      operationId: listInvitations
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Invitations.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/Invitation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
    post:
      tags: [Team]
      summary: Invite a member
      description: |
        Emails an invitation to join the workspace. The link is valid for 7
        days and is also returned as `invite_url`. Owners and admins can
        invite; only owners can invite admins or owners; `client` needs a
        Team plan. Inviting an email that already has a pending invitation
        refreshes it with a new link and expiry (that's how to resend).
        Rate limited to 10 per minute. Scope: `members:write`.
      operationId: createInvitation
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email]
              properties:
                email: { type: string, format: email }
                role:
                  type: string
                  enum: [member, admin, owner, client]
                  default: member
      responses:
        "201":
          description: Invitation created and emailed.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/Invitation"
                  - type: object
                    required: [invite_url, email_sent]
                    properties:
                      invite_url: { type: string, format: uri }
                      email_sent:
                        type: boolean
                        description: False if the email failed; the link still works.
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /invitations/{invitation_id}:
    parameters:
      - name: invitation_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    delete:
      tags: [Team]
      summary: Revoke an invitation
      description: |
        Revokes a pending invitation so its link stops working. Owners and
        admins only. Scope: `members:write`.
      operationId: revokeInvitation
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Revoked. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }

  /billing:
    get:
      tags: [Billing]
      summary: Get plan and add-ons
      description: |
        The organization's plan and add-ons: DM automation (included on
        Team, an add-on on Creator) and extra workspaces. Scope:
        `account:read`.
      operationId: getBilling
      security:
        - AccountToken: []
      responses:
        "200":
          description: Plan and add-ons.
          content:
            application/json:
              schema:
                type: object
                properties:
                  plan: { type: string, enum: [free, creator, team] }
                  interval: { type: string, enum: [month, year], nullable: true }
                  status: { type: string, nullable: true }
                  add_ons:
                    type: object
                    properties:
                      dm_automation:
                        type: object
                        properties:
                          active: { type: boolean }
                          via: { type: string, enum: [team, addon], nullable: true }
                          cancel_at_period_end: { type: boolean }
                      extra_workspaces: { type: integer }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }

  /billing/checkout:
    post:
      tags: [Billing]
      summary: Get a checkout link for an add-on
      description: |
        Returns a Stripe Checkout link for a person to open and pay; this
        call charges nothing. `dm_automation` is an add-on on Creator
        (billed on the plan's interval) and included on Team. On Free,
        `dm_automation` and `extra_workspace` each come with Creator in the
        same checkout. Paid plans add workspaces in Settings > Billing, so
        `extra_workspace` on a paid plan returns 409. Runs as the token's
        creator, who must be an owner or admin. Scope: `account:write`.
      operationId: createBillingCheckout
      security:
        - AccountToken: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [add_on]
              properties:
                add_on: { type: string, enum: [dm_automation, extra_workspace] }
                interval:
                  type: string
                  enum: [month, year]
                  default: month
                  description: Only when Creator comes with it (Free). An add-on on a paid plan follows the plan's interval.
      responses:
        "201":
          description: Checkout link.
          content:
            application/json:
              schema:
                type: object
                properties:
                  checkout_url: { type: string, format: uri }
                  items:
                    type: array
                    items: { type: string, enum: [creator, dm_automation, extra_workspace] }
                  price: { type: string, example: "$19.99 + $12 per month" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409":
          description: Not available for this plan, for example Team already includes DM automation.
        "429": { $ref: "#/components/responses/RateLimited" }

  /comment-dms/rules:
    get:
      tags: [Comment DMs]
      summary: List comment DM rules
      description: |
        The workspace's rules with their counts, plus whether the plan
        includes comment DMs and whether Instagram needs reconnecting.
        Scope: `inbox:read`.
      operationId: listCommentDmRules
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Rules and connection state.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  connection:
                    type: object
                    nullable: true
                    properties:
                      id: { type: string, format: uuid }
                      username: { type: string, nullable: true }
                      webhook_subscribed: { type: boolean }
                  reconnect_reason:
                    type: string
                    nullable: true
                    enum: [no_connection, missing_scopes, expired]
                  access:
                    type: object
                    properties:
                      allowed: { type: boolean }
                      via: { type: string, enum: [team, addon] }
                      reason: { type: string, enum: [free, creator_needs_addon] }
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/CommentDmRule" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    post:
      tags: [Comment DMs]
      summary: Create a comment DM rule
      description: |
        Anyone who comments a keyword gets the message as one private DM, once
        per person per rule. A rule that's on sends to real people right away.
        Scope: `inbox:write`.
      operationId: createCommentDmRule
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/CommentDmRuleInput"
                - type: object
                  required: [keywords]
                  description: Send `message` or `messages`. In `ai` mode, `ai_brief` too.
      responses:
        "201":
          description: Rule created.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/CommentDmRule" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /comment-dms/rules/{rule_id}:
    parameters:
      - name: rule_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    get:
      tags: [Comment DMs]
      summary: Get a comment DM rule
      description: "Scope: `inbox:read`."
      operationId: getCommentDmRule
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: The rule.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/CommentDmRule" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
    patch:
      tags: [Comment DMs]
      summary: Update a comment DM rule
      description: |
        Only the fields you send change. Turning a rule off always works, even
        on a lapsed plan. Scope: `inbox:write`.
      operationId: updateCommentDmRule
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/CommentDmRuleInput" }
      responses:
        "200":
          description: The updated rule.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/CommentDmRule" }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
    delete:
      tags: [Comment DMs]
      summary: Delete a comment DM rule
      description: |
        Also deletes the rule's send history, so a new rule can DM the same
        people. To stop one for now, set `enabled` to false. Scope:
        `inbox:write`.
      operationId: deleteCommentDmRule
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Deleted. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }

  /comment-dms/posts:
    get:
      tags: [Comment DMs]
      summary: List posts for a rule
      description: |
        The connected Instagram account's 30 most recent posts, read live from
        Instagram. Scope: `inbox:read`.
      operationId: listCommentDmPosts
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Recent posts.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: { type: string }
                        caption: { type: string, nullable: true }
                        thumbnail_url: { type: string, nullable: true }
                        permalink: { type: string, nullable: true }
                        timestamp: { type: string, nullable: true }
        "400": { $ref: "#/components/responses/Validation" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }

  /comment-dms/contacts:
    get:
      tags: [Comment DMs]
      summary: List DM contacts
      description: |
        Emails collected by DM automations (rules with `gate` `email` or
        `follow_email`), newest first. Page with `before`. Scope: `inbox:read`.
      operationId: listDmContacts
      security:
        - WorkspaceKey: []
      parameters:
        - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 200, default: 50 } }
        - { name: before, in: query, description: Only contacts collected before this time (the created_at of the last one you got)., schema: { type: string, format: date-time } }
        - { name: rule_id, in: query, schema: { type: string, format: uuid } }
      responses:
        "200":
          description: Contacts.
          content:
            application/json:
              schema:
                type: object
                required: [data, total]
                properties:
                  total: { type: integer }
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: { type: string, format: uuid }
                        rule_id: { type: string, format: uuid, nullable: true }
                        platform: { type: string, example: instagram }
                        username: { type: string, nullable: true }
                        email: { type: string }
                        source_media_id: { type: string, nullable: true }
                        created_at: { type: string, format: date-time }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }

  /inbox/connections:
    get:
      tags: [Inbox]
      summary: List inbox connections
      description: |
        The workspace's active connections that feed the inbox, with flags
        that say what each one can do. Check them before replying, liking or
        sending DMs so you skip calls that would fail. Scope: `inbox:read`.
      operationId: listInboxConnections
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Inbox connections.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/InboxConnection" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/conversations:
    get:
      tags: [Inbox]
      summary: List conversations
      description: |
        Comment threads, mentions, reviews and DM threads for the workspace,
        with the same filters as the inbox in the app. Reads the copy
        ShortSync saved at the last sync; call `POST /inbox/sync` for fresh
        data. Conversations from connections that need reconnecting are left
        out. Offset pagination: pass `pagination.next_offset` as `offset` to
        get the next page. Scope: `inbox:read`.
      operationId: listInboxConversations
      security:
        - WorkspaceKey: []
      parameters:
        - name: platform
          in: query
          description: Only this platform. Unknown values are ignored (all platforms).
          schema: { $ref: "#/components/schemas/InboxPlatform" }
        - name: inbox_mode
          in: query
          description: "`comments` is post and video comment threads, `messages` is DM threads (Instagram and Facebook only)."
          schema: { type: string, enum: [all, comments, messages], default: all }
        - name: sort
          in: query
          description: "`recent` by last activity, `most_liked` by `like_count`, `most_unread` by `unread_count`, `oldest_unanswered` by the oldest inbound message first."
          schema:
            type: string
            enum: [recent, most_liked, most_unread, oldest_unanswered]
            default: recent
        - name: answered
          in: query
          description: "`unanswered` is threads where the participant wrote after your last reply; `answered` is the opposite."
          schema: { type: string, enum: [all, unanswered, answered], default: all }
        - name: q
          in: query
          description: Case-insensitive search over the participant's username and the last message preview.
          schema: { type: string }
        - name: unseen_only
          in: query
          description: Set to `1` to show only conversations the workspace hasn't seen yet.
          schema: { type: string, enum: ["1"] }
        - name: include_own
          in: query
          description: Set to `1` to also include the workspace's own top-level comments (hidden by default because they need no reply).
          schema: { type: string, enum: ["1"] }
        - name: include_spam
          in: query
          description: Set to `1` to also include conversations marked as spam.
          schema: { type: string, enum: ["1"] }
        - name: media_video_id
          in: query
          description: Only comment threads on this YouTube video id (`platform_metadata.video_id`).
          schema: { type: string }
        - name: media_post_id
          in: query
          description: Only comment threads on this post id (`platform_metadata.post_id`).
          schema: { type: string }
        - name: limit
          in: query
          description: Rows per page.
          schema: { type: integer, minimum: 1, maximum: 200, default: 50 }
        - name: offset
          in: query
          description: Rows to skip.
          schema: { type: integer, minimum: 0, default: 0 }
      responses:
        "200":
          description: One page of conversations.
          content:
            application/json:
              schema:
                type: object
                required: [data, pagination]
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/InboxConversation" }
                  pagination:
                    type: object
                    required: [next_offset, limit, offset]
                    properties:
                      next_offset:
                        type: integer
                        nullable: true
                        description: Pass as `offset` for the next page. Null on the last page.
                      limit: { type: integer }
                      offset: { type: integer }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/conversations/{conversation_id}/messages:
    parameters:
      - $ref: "#/components/parameters/InboxConversationId"
    get:
      tags: [Inbox]
      summary: Get a conversation's messages
      description: |
        The conversation plus every saved message in it, oldest first. Pass
        `sync=1` to fetch new messages from the platform first (one extra
        platform call, which counts against that platform's rate limits).
        Scope: `inbox:read`.
      operationId: getInboxConversationMessages
      security:
        - WorkspaceKey: []
      parameters:
        - name: sync
          in: query
          description: Set to `1` to refresh from the platform before answering.
          schema: { type: string, enum: ["1"] }
      responses:
        "200":
          description: The conversation and its messages.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [conversation, messages]
                    properties:
                      conversation: { $ref: "#/components/schemas/InboxConversation" }
                      messages:
                        type: array
                        items: { $ref: "#/components/schemas/InboxMessage" }
        "400":
          description: The conversation's platform isn't supported (`UNSUPPORTED_PLATFORM`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404":
          description: No such conversation in this workspace (`CONVERSATION_NOT_FOUND`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/sync:
    post:
      tags: [Inbox]
      summary: Sync the inbox
      description: |
        Pulls fresh threads and their first page of messages from every
        inbox connection in the workspace, like the refresh button in the
        app. Send `platforms` to sync only some of them. Errors on one
        connection don't fail the call; they come back in that result's
        `errors`. Scope: `inbox:write`.
      operationId: syncInbox
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                platforms:
                  type: array
                  items: { $ref: "#/components/schemas/InboxPlatform" }
                  description: Leave out to sync every inbox connection. Unknown values are ignored.
      responses:
        "200":
          description: One result per synced connection.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [results]
                    properties:
                      results:
                        type: array
                        items: { $ref: "#/components/schemas/InboxSyncResult" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/conversations/{conversation_id}/reply:
    parameters:
      - $ref: "#/components/parameters/InboxConversationId"
    post:
      tags: [Inbox]
      summary: Reply to a conversation
      description: |
        Posts a reply on the platform and returns the saved outbound message.

        - Comment threads, mentions and reviews have no reply window.
        - Instagram and Facebook DMs can only be answered within Meta's 7-day
          window after the participant's last message
          (`REPLY_WINDOW_EXPIRED`), and only after they've written to you
          (`REPLY_WINDOW_AWAITING_REPLY`).
        - A reply to a private Mastodon mention keeps that visibility.
        - A Google Business Profile review takes one owner reply. Replying
          again replaces it.

        Scope: `inbox:write`.
      operationId: replyToInboxConversation
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                body:
                  type: string
                  description: The reply text. Required unless you send `attachments`. With attachments, at most 1,000 bytes.
                attachments:
                  type: array
                  description: |
                    Instagram DMs only. Up to 10 images (PNG, JPEG or GIF, 8 MB
                    each), or one PDF on its own (25 MB). They go out first as
                    their own message, then the text. If the text then fails,
                    the call still succeeds with `warning`, so resend only the
                    text.
                  items: { $ref: "#/components/schemas/InboxReplyAttachment" }
                reply_to_message_id:
                  type: string
                  description: |
                    Instagram and Facebook DMs only. The `id` or
                    `external_message_id` of a message in this conversation to
                    quote. If Meta refuses the quote, the reply is sent
                    without it and the response carries `notice`.
            example:
              body: Thanks for watching!
      responses:
        "201":
          description: Reply sent.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [message, messages]
                    properties:
                      message:
                        description: The last message sent.
                        oneOf:
                          - $ref: "#/components/schemas/InboxMessage"
                          - type: "null"
                      messages:
                        type: array
                        description: Every message sent, oldest first (attachments, then text).
                        items: { $ref: "#/components/schemas/InboxMessage" }
                      warning:
                        type: string
                        description: The attachments were sent but the text wasn't.
                      notice:
                        type: string
                        description: Sent, but without the quote of `reply_to_message_id`.
        "400":
          description: |
            Bad input or the platform won't take this reply. Codes include
            `BODY_REQUIRED`, `INVALID_ATTACHMENTS`, `INVALID_REPLY_TO`,
            `ATTACHMENTS_UNSUPPORTED`, `BODY_TOO_LONG`, `REPLY_TO_UNSUPPORTED`,
            `REPLY_WINDOW_EXPIRED` and `REPLY_WINDOW_AWAITING_REPLY`.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404":
          description: No such conversation in this workspace (`CONVERSATION_NOT_FOUND`), or the message to quote isn't in it (`REPLY_TO_NOT_FOUND`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/conversations/{conversation_id}/like:
    parameters:
      - $ref: "#/components/parameters/InboxConversationId"
    post:
      tags: [Inbox]
      summary: Like a conversation
      description: |
        Likes or unlikes the top-level comment of a comment thread on the
        platform. Instagram, Facebook and LinkedIn Company Pages only; other
        platforms return `400 LIKE_UNSUPPORTED`. DM threads can't be liked.
        Check `has_like_scope` on `GET /inbox/connections` first.
        Scope: `inbox:write`.
      operationId: likeInboxConversation
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/InboxLikeInput" }
      responses:
        "200":
          description: The new like state.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/InboxLikeResult" }
        "400":
          description: |
            `liked` isn't a boolean (`LIKED_REQUIRED`), the platform has no
            comment likes (`LIKE_UNSUPPORTED`), or the conversation is a DM
            thread (also `LIKE_UNSUPPORTED`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403":
          description: |
            Missing scope, or the Instagram connection lacks
            `instagram_manage_engagement` (`PLATFORM_SCOPE_MISSING`). That
            needs the Facebook Login for Business upgrade, which a person
            finishes in a browser; `details` carries `platform`, `scope` and
            `upgrade_url`.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/messages/{message_id}/like:
    parameters:
      - name: message_id
        in: path
        required: true
        description: A message `id` from the messages endpoint.
        schema: { type: string, format: uuid }
    post:
      tags: [Inbox]
      summary: Like a message
      description: |
        Likes or unlikes one reply inside a comment thread. Same rules as
        liking a conversation: Instagram, Facebook and LinkedIn Company Pages
        only, others return `400 LIKE_UNSUPPORTED`, and DM messages can't be
        liked. Scope: `inbox:write`.
      operationId: likeInboxMessage
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/InboxLikeInput" }
      responses:
        "200":
          description: The new like state.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/InboxLikeResult" }
        "400":
          description: |
            `liked` isn't a boolean (`LIKED_REQUIRED`), the platform has no
            comment likes (`LIKE_UNSUPPORTED`), or the message is in a DM
            thread (also `LIKE_UNSUPPORTED`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403":
          description: Missing scope, or the Instagram connection lacks `instagram_manage_engagement` (`PLATFORM_SCOPE_MISSING`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/conversations/mark-seen:
    post:
      tags: [Inbox]
      summary: Mark conversations seen
      description: |
        Sets `last_seen_at` to now on up to 500 conversations. Only changes
        ShortSync's copy, unless `send_read_receipt` is true. Ids outside the
        workspace are ignored; the response lists the ones that changed.
        Scope: `inbox:write`.
      operationId: markInboxConversationsSeen
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [conversation_ids]
              properties:
                conversation_ids:
                  type: array
                  maxItems: 500
                  items: { type: string, format: uuid }
                send_read_receipt:
                  type: boolean
                  default: false
                  description: |
                    Also send Instagram's read receipt, so the participant sees
                    their message was read. Applies to at most 25 Instagram DMs
                    per call whose last message is theirs and under 24 hours
                    old. Best effort: runs in the background and never fails
                    the call.
      responses:
        "200":
          description: Updated ids.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [updated_ids]
                    properties:
                      updated_ids:
                        type: array
                        items: { type: string, format: uuid }
        "400":
          description: "`conversation_ids` isn't an array (`INVALID_CONVERSATION_IDS`) or has more than 500 ids (`TOO_MANY_IDS`)."
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/conversations/mark-spam:
    post:
      tags: [Inbox]
      summary: Mark conversations as spam
      description: |
        Sets or clears the spam flag on up to 500 conversations. Spam is
        hidden from `GET /inbox/conversations` unless `include_spam=1`.
        Only changes ShortSync's copy; nothing is hidden or deleted on the
        platform, so unmarking always restores the row. Scope: `inbox:write`.
      operationId: markInboxConversationsSpam
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [conversation_ids, is_spam]
              properties:
                conversation_ids:
                  type: array
                  maxItems: 500
                  items: { type: string, format: uuid }
                is_spam:
                  type: boolean
                  description: true to mark, false to unmark.
      responses:
        "200":
          description: Updated ids.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [updated_ids, is_spam]
                    properties:
                      updated_ids:
                        type: array
                        items: { type: string, format: uuid }
                      is_spam: { type: boolean }
        "400":
          description: "`conversation_ids` isn't an array (`INVALID_CONVERSATION_IDS`), `is_spam` isn't a boolean (`INVALID_IS_SPAM`), or more than 500 ids (`TOO_MANY_IDS`)."
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/media/load-more:
    post:
      tags: [Inbox]
      summary: Load more comments
      description: |
        Fetches one more page of older comments for a YouTube video,
        Instagram post or reel, or Facebook post and saves them to the
        inbox. ShortSync keeps the page cursor per workspace, platform and
        media, so each call goes further back. Instagram, Facebook and
        YouTube only. Scope: `inbox:write`.
      operationId: loadMoreInboxComments
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [platform, media_source_id]
              properties:
                platform:
                  type: string
                  enum: [instagram, facebook, youtube]
                media_source_id:
                  type: string
                  description: The platform's media id, from `platform_metadata.video_id` or `platform_metadata.post_id` on a conversation.
                force:
                  type: boolean
                  default: false
                  description: Ignore the saved cursor and fetch the newest page, to catch comments posted since the last call.
            example:
              platform: instagram
              media_source_id: "18450375271136963"
      responses:
        "200":
          description: Page loaded.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: object
                    required: [new_count, total_conversations_returned, exhausted]
                    properties:
                      new_count:
                        type: integer
                        description: Comments on this page that weren't in the inbox yet.
                      total_conversations_returned:
                        type: integer
                        description: All comments on this page, new and already known.
                      exhausted:
                        type: boolean
                        description: No older pages left. Later calls do nothing until you send `force`.
        "400":
          description: |
            Missing or unsupported `platform` (`INVALID_PLATFORM`, or
            `BAD_REQUEST` for a valid inbox platform without load more),
            missing `media_source_id` (`MEDIA_SOURCE_ID_REQUIRED`), or no
            connection for this media (`BAD_REQUEST`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/saved-replies:
    get:
      tags: [Inbox]
      summary: List saved replies
      description: |
        The workspace's saved replies, sorted by name. They're reusable text
        shared by everyone in the workspace and are never sent on their own:
        to answer a thread, send the text with
        `POST /inbox/conversations/{conversation_id}/reply`. Scope: `inbox:read`.
      operationId: listInboxSavedReplies
      security:
        - WorkspaceKey: []
      responses:
        "200":
          description: Saved replies.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/InboxSavedReply" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
    post:
      tags: [Inbox]
      summary: Create a saved reply
      description: |
        Adds a saved reply for the whole workspace. Nothing is sent to any
        platform. The key's creator can't be a client in the workspace.
        Scope: `inbox:write`.
      operationId: createInboxSavedReply
      security:
        - WorkspaceKey: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/InboxSavedReplyInput"
                - type: object
                  required: [name, content]
      responses:
        "201":
          description: Saved reply created.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data: { $ref: "#/components/schemas/InboxSavedReply" }
        "400":
          description: "Invalid input (`INVALID_NAME`, `NAME_TOO_LONG`, `INVALID_CONTENT`, `CONTENT_TOO_LONG`) or the name is taken (`DUPLICATE_NAME`)."
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403":
          description: Missing scope, or the key's creator is a client (`CLIENT_ACTION_FORBIDDEN`). Clients can read saved replies but not change them.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }

  /inbox/saved-replies/{saved_reply_id}:
    parameters:
      - name: saved_reply_id
        in: path
        required: true
        schema: { type: string, format: uuid }
    patch:
      tags: [Inbox]
      summary: Update a saved reply
      description: |
        Changes the fields you send (at least one of `name` and `content`)
        and returns the updated saved reply. Scope: `inbox:write`.
      operationId: updateInboxSavedReply
      security:
        - WorkspaceKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/InboxSavedReplyInput" }
      responses:
        "200":
          description: The updated saved reply.
          content:
            application/json:
              schema:
                type: object
                required: [data]
                properties:
                  data: { $ref: "#/components/schemas/InboxSavedReply" }
        "400":
          description: "Nothing to change (`NOTHING_TO_UPDATE`), invalid input (`INVALID_NAME`, `NAME_TOO_LONG`, `INVALID_CONTENT`, `CONTENT_TOO_LONG`) or the name is taken (`DUPLICATE_NAME`)."
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403":
          description: Missing scope, or the key's creator is a client (`CLIENT_ACTION_FORBIDDEN`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "404":
          description: No such saved reply in this workspace (`SAVED_REPLY_NOT_FOUND`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }
    delete:
      tags: [Inbox]
      summary: Delete a saved reply
      description: |
        Removes the saved reply for the whole workspace. Replies already
        sent aren't affected. Scope: `inbox:write`.
      operationId: deleteInboxSavedReply
      security:
        - WorkspaceKey: []
      responses:
        "204": { description: Deleted. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403":
          description: Missing scope, or the key's creator is a client (`CLIENT_ACTION_FORBIDDEN`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "404":
          description: No such saved reply in this workspace (`SAVED_REPLY_NOT_FOUND`).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/ErrorResponse" }
        "429": { $ref: "#/components/responses/RateLimited" }

components:
  securitySchemes:
    WorkspaceKey:
      type: http
      scheme: bearer
      bearerFormat: ss_live_<random>
      description: Workspace-scoped key. Prefixed `ss_live_`. Pinned to one workspace at creation.
    AccountToken:
      type: http
      scheme: bearer
      bearerFormat: ss_acct_<random>
      description: Organization-wide token. Prefixed `ss_acct_`. Only owners and admins can create one, in Settings > API, MCP & webhooks.

  parameters:
    Cursor:
      name: cursor
      in: query
      description: Opaque cursor returned by a previous list response. Omit on the first page.
      schema: { type: string }
    Limit:
      name: limit
      in: query
      description: Maximum items to return (1-100). Default 25.
      schema: { type: integer, minimum: 1, maximum: 100, default: 25 }
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: |
        Optional client-generated unique key (e.g. a UUID) to make `POST`
        operations safe to retry. Replays within 24h return the original
        response body and status code. Use a fresh key per logical operation.
      schema: { type: string, maxLength: 255 }
    InboxConversationId:
      name: conversation_id
      in: path
      required: true
      description: A conversation `id` from `GET /inbox/conversations`.
      schema: { type: string, format: uuid }

  headers:
    X-RateLimit-Limit:
      description: Maximum requests allowed in the current window.
      schema: { type: integer }
    X-RateLimit-Remaining:
      description: Requests remaining in the current window.
      schema: { type: integer }
    X-RateLimit-Reset:
      description: Unix epoch seconds when the window resets.
      schema: { type: integer }
    Retry-After:
      description: Seconds to wait before retrying.
      schema: { type: integer }
    KeyId:
      name: key_id
      in: path
      required: true
      schema: { type: string }
    UploadId:
      name: upload_id
      in: path
      required: true
      schema: { type: string }
    PostId:
      name: post_id
      in: path
      required: true
      schema: { type: string }
    ConnectionId:
      name: connection_id
      in: path
      required: true
      schema: { type: string }

  responses:
    Unauthorized:
      description: Missing, malformed, or revoked token.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/ErrorResponse" }
          example:
            status: 401
            code: UNAUTHORIZED
            message: Missing or invalid Authorization header.
    Forbidden:
      description: |
        Token is valid but cannot access this resource. Common cases:

        - `INSUFFICIENT_SCOPE` - token lacks the required scope.
        - `WORKSPACE_NOT_ALLOWED` - account token is allowlisted to other workspaces.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/ErrorResponse" }
          example:
            status: 403
            code: INSUFFICIENT_SCOPE
            message: This endpoint requires the 'posts:write' scope.
    NotFound:
      description: Resource does not exist or is not visible to this token.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/ErrorResponse" }
    Validation:
      description: Request body or parameters failed validation.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/ErrorResponse" }
          example:
            status: 400
            code: VALIDATION_ERROR
            message: scheduled_for must be in the future.
            details:
              field: scheduled_for
    RateLimited:
      description: |
        Per-key sliding-window rate limit (60 req/min), per-org monthly
        request quota, or per-user upload cap was hit.
        `RATE_LIMIT_EXCEEDED` carries the window headers;
        `QUOTA_EXCEEDED` carries `details.quota` (which counter),
        `used`, `limit`, `resets_at`, and `upgrade_url`.
        `UPLOAD_QUOTA_EXCEEDED` (Free tier on `POST /posts` only)
        carries the same shape plus `details.remaining`.
      headers:
        X-RateLimit-Limit: { $ref: "#/components/headers/X-RateLimit-Limit" }
        X-RateLimit-Remaining:
          { $ref: "#/components/headers/X-RateLimit-Remaining" }
        X-RateLimit-Reset: { $ref: "#/components/headers/X-RateLimit-Reset" }
        Retry-After: { $ref: "#/components/headers/Retry-After" }
      content:
        application/json:
          schema: { $ref: "#/components/schemas/ErrorResponse" }
          examples:
            rateLimit:
              value:
                status: 429
                code: RATE_LIMIT_EXCEEDED
                message: Too many requests. Retry after the reset time.
            quota:
              value:
                status: 429
                code: QUOTA_EXCEEDED
                message: Monthly API request quota exceeded for this organization. Upgrade to Creator or Team for a higher request cap.
                details:
                  quota: requests
                  used: 500000
                  limit: 500000
                  resets_at: "2026-07-01T00:00:00Z"
                  upgrade_url: "https://www.shortsync.app/settings?section=billing"
            uploadQuota:
              value:
                status: 429
                code: UPLOAD_QUOTA_EXCEEDED
                message: Monthly upload quota exceeded for this account. Upgrade to Creator or Team for unlimited posts.
                details:
                  quota: uploads
                  used: 5
                  limit: 5
                  remaining: 0
                  upgrade_url: "https://www.shortsync.app/settings?section=billing"

  schemas:
    CommentDmRuleInput:
      type: object
      properties:
        platform:
          type: string
          enum: [instagram, facebook]
          default: instagram
          description: |
            Set on create. `facebook`: the workspace's connected Facebook Page
            (reconnect it once for the `pages_manage_metadata` permission).
            Facebook rules start from post comments or Messenger DMs and skip
            the follow check; `post_id` is a Facebook post id (`pageid_postid`).
        triggers:
          type: array
          minItems: 1
          items: { type: string, enum: [comment, story_reply, dm_keyword, live_comment, story_mention] }
          description: |
            Everything that starts the rule, one or more, for example
            `[comment, story_reply]`. Use instead of `trigger`. Each person
            still gets the rule's DM once. `story_mention`: someone mentions
            the account in their story; it needs no keyword. Facebook rules:
            `comment` and `dm_keyword`.
        trigger:
          type: string
          enum: [comment, story_reply, dm_keyword, live_comment, story_mention]
          default: comment
          description: |
            One trigger, the shape from before `triggers` (ignored when
            `triggers` is set). What starts the rule. `comment`: a comment on a post (`post_id`
            picks one). `story_reply`: a reply to any of the account's
            stories. `dm_keyword`: a DM to the account that isn't part of
            another automation. `live_comment`: a comment during a Live,
            answered while it's on. Each person gets the rule's DM once.
            Public replies are for comment rules only.
        keywords:
          type: array
          maxItems: 20
          items: { type: string, maxLength: 50 }
          description: Whole words, any case. Emoji work too. Can be empty only when `story_mention` is the rule's only trigger.
        messages:
          type: array
          minItems: 1
          maxItems: 5
          items: { type: string }
          description: |
            Versions of the DM; each person gets one picked at random. Up to
            1,000 bytes each with placeholders filled in: `{first_name}` (first
            name on Facebook, @name on Instagram), `{username}` (the
            commenter as @name), `{keyword}` (the keyword they matched),
            `{link}` (the rule's link). In `ai` mode, the fallback sent when
            the AI can't write one or the month's AI DMs are used up.
        message:
          type: string
          description: |
            One DM text, the shape from before versions. Setting it replaces
            all versions. Include a line saying it's automated; some places,
            like California and Germany, require it.
        message_mode:
          type: string
          enum: [variants, ai]
          default: variants
          description: |
            `ai`: AI writes each DM from `ai_brief`, greets the person and
            answers their comment in their language, never adds links or
            claims you didn't give, and ends with an automated-message line.
            Counts toward the organization's monthly AI DMs.
        ai_brief:
          type: string
          nullable: true
          maxLength: 500
          description: What the DM should say. Required in `ai` mode.
        link:
          type: string
          nullable: true
          maxLength: 500
          description: Fills `{link}` and goes under every AI-written DM. `https://` is added when missing.
        public_reply_enabled:
          type: boolean
          description: Also post a short public reply under the comment.
        public_replies:
          type: array
          maxItems: 5
          items: { type: string, maxLength: 300 }
          description: Each comment gets one. `{username}` and `{keyword}` work here.
        track_clicks:
          type: boolean
          default: true
          description: |
            Send the link through a `https://www.shortsync.app/l/` short link
            so clicks are counted (`clicked_count`, `variant_stats`,
            `ai_stats`).
        delivery:
          type: string
          enum: [text, button, card]
          default: text
          description: |
            How the link is sent. `text`: inside the message. `button`: the
            message (up to 640 characters, `{link}` left out) with a link
            button. `card`: a card with `card_title`, `card_subtitle` and a
            link button (image cards are set up in ShortSync). Button and card
            need a `link`. If Instagram doesn't accept a button or card in a
            reply to a comment, the message goes out as text with the link.
        button_label:
          type: string
          nullable: true
          maxLength: 20
          description: Button text for `button` and `card`. Defaults to "Open link".
        card_title:
          type: string
          nullable: true
          maxLength: 80
          description: Required for `card`.
        card_subtitle:
          type: string
          nullable: true
          maxLength: 80
        gate:
          type: string
          enum: [none, follow, email, follow_email]
          default: none
          description: |
            A step before the link. `follow` checks they follow the account
            (after 3 tries the link goes out anyway). `email` asks for their
            email and saves it to the contacts (`GET /comment-dms/contacts`).
            With a step or `attachments`, the first DM ends with a button
            (`gate_button_label`); tapping it starts the next step, because
            Instagram allows one DM per comment until the person answers.
        gate_button_label: { type: string, nullable: true, maxLength: 20, description: 'Default "Send me the link".' }
        reply_word: { type: string, nullable: true, maxLength: 30, description: 'If Instagram refuses the button: "Reply <word> and I''ll send it". Default YES.' }
        follow_prompt: { type: string, nullable: true, maxLength: 640 }
        email_prompt: { type: string, nullable: true, maxLength: 640 }
        delivery_message: { type: string, nullable: true, maxLength: 640, description: One message sent with the link after the tap. Ignored when `delivery_messages` is set. }
        delivery_messages:
          type: array
          maxItems: 5
          items: { type: string, maxLength: 640 }
          description: |
            Versions of the message sent with the link after the tap; one is
            picked at random. `{username}`, `{first_name}`, `{keyword}` and
            `{link}` are filled in. Empty: "Here you go!".
        delivery_message_mode:
          type: string
          enum: [variants, ai]
          description: "`ai`: AI writes the message from `delivery_ai_brief`, with `delivery_messages` as the backup."
        delivery_ai_brief: { type: string, nullable: true, maxLength: 500, description: What the AI-written message with the link says. Required in `ai` mode. }
        question_text:
          type: string
          nullable: true
          maxLength: 640
          description: |
            A question asked after the follow and email steps, before the
            link, with `question_options` as tap buttons. They can also reply
            with an answer or its number; after two unclear replies the
            rule's link goes out. null removes it.
        question_options:
          type: array
          minItems: 2
          maxItems: 3
          items:
            type: object
            required: [label]
            properties:
              label: { type: string, maxLength: 20 }
              link: { type: string, nullable: true, description: "The link this answer sends. null: the rule's link." }
        followup_enabled:
          type: boolean
          description: |
            AI answers their replies for 24 hours after the link, from
            `ai_brief` (required). Stops when someone replies from the inbox,
            the person asks for a human, or after `followup_max` answers.
        followup_max: { type: integer, minimum: 1, maximum: 10, default: 3 }
        ai_faqs:
          type: array
          maxItems: 20
          description: |
            Questions and answers the AI follows closely when it answers
            replies (`followup_enabled`). Replaces the list.
          items:
            type: object
            required: [question, answer]
            properties:
              question: { type: string, maxLength: 200 }
              answer: { type: string, maxLength: 1000 }
        ai_source_urls:
          type: array
          maxItems: 3
          items: { type: string }
          description: |
            Web pages (for example a pricing or FAQ page) the AI answers
            replies from. ShortSync reads them when the rule is saved and
            again when the text is a day old. Replaces the list.
        post_ids:
          type: array
          nullable: true
          maxItems: 50
          items: { type: string }
          description: |
            Instagram post ids from `/comment-dms/posts`: the `comment`
            trigger only answers comments on these posts. Null or `[]` watches
            every post; left out keeps them (every post on create). Story
            replies, DMs and Live comments aren't limited by it.
        post_id:
          type: string
          nullable: true
          description: One post, the shape from before `post_ids` (ignored when `post_ids` is set). Null watches every post.
        enabled: { type: boolean, default: true }
    CommentDmRule:
      type: object
      required: [id, keywords, messages, message, message_mode, enabled, disclosure_missing]
      properties:
        id: { type: string, format: uuid }
        connection_id: { type: string, format: uuid }
        platform: { type: string, enum: [instagram, facebook] }
        triggers:
          type: array
          items: { type: string, enum: [comment, story_reply, dm_keyword, live_comment, story_mention] }
          description: Everything that starts the rule.
        media:
          type: array
          description: The posts its `comment` trigger is limited to. Empty means every post.
          items:
            type: object
            properties:
              id: { type: string }
              caption: { type: string, nullable: true }
              thumbnail_url: { type: string, nullable: true }
              permalink: { type: string, nullable: true }
        trigger:
          type: string
          enum: [comment, story_reply, dm_keyword, live_comment, story_mention]
          description: The first of `triggers`, for callers from before several.
        media_id:
          type: string
          nullable: true
          description: The first of `media`, for callers from before several. Null means every post.
        media_caption: { type: string, nullable: true }
        media_thumbnail_url: { type: string, nullable: true }
        media_permalink: { type: string, nullable: true }
        keywords:
          type: array
          items: { type: string }
        messages:
          type: array
          items: { type: string }
        message:
          type: string
          description: The first version, for callers from before versions.
        message_mode: { type: string, enum: [variants, ai] }
        ai_brief: { type: string, nullable: true }
        link: { type: string, nullable: true }
        public_reply_enabled: { type: boolean }
        public_replies:
          type: array
          items: { type: string }
        track_clicks: { type: boolean }
        delivery: { type: string, enum: [text, button, card] }
        button_label: { type: string, nullable: true }
        card_title: { type: string, nullable: true }
        card_subtitle: { type: string, nullable: true }
        card_image_url:
          type: string
          nullable: true
          description: The card image, a link that works for 24 hours.
        gate: { type: string, enum: [none, follow, email, follow_email] }
        gate_button_label: { type: string, nullable: true }
        reply_word: { type: string, nullable: true }
        follow_prompt: { type: string, nullable: true }
        email_prompt: { type: string, nullable: true }
        delivery_message: { type: string, nullable: true }
        delivery_messages:
          type: array
          items: { type: string }
        delivery_message_mode: { type: string, enum: [variants, ai] }
        delivery_ai_brief: { type: string, nullable: true }
        question_text: { type: string, nullable: true }
        question_options:
          type: array
          items:
            type: object
            properties:
              label: { type: string }
              link: { type: string, nullable: true }
        insights:
          type: object
          nullable: true
          description: The last 7 days of events and the rule's funnel.
          properties:
            seen_7d: { type: integer, description: Events the rule listened to (comments on its posts, DMs, story replies or mentions). }
            matched_7d: { type: integer, description: Of those, the ones with a keyword. }
            funnel:
              type: object
              nullable: true
              description: Rules with a tap step. First DMs, taps, follows, emails, answers, links sent and clicks.
              properties:
                started: { type: integer }
                tapped: { type: integer }
                followed: { type: integer }
                emailed: { type: integer }
                answered: { type: integer }
                delivered: { type: integer }
                clicked: { type: integer }
            delivery_stats:
              type: object
              description: Sent and clicked per version of the message with the link (`index` in `delivery_messages`), and for AI-written ones.
            answer_stats:
              type: array
              description: How many picked each answer (`index` in `question_options`) and clicked.
              items:
                type: object
                properties:
                  index: { type: integer }
                  count: { type: integer }
                  clicked: { type: integer }
        attachments:
          type: array
          description: Files sent after the link (added in ShortSync).
          items:
            type: object
            properties:
              type: { type: string, enum: [image, file] }
              name: { type: string }
        followup_enabled: { type: boolean }
        followup_max: { type: integer }
        contact_count: { type: integer, description: Emails this rule collected. }
        video_post_id:
          type: string
          format: uuid
          nullable: true
          description: Set when the rule was made with a post (`instagram.comment_dm`); it started when the post went live.
        enabled: { type: boolean }
        disclosure_missing:
          type: boolean
          description: True when the message doesn't say it's automated.
        last_error:
          type: string
          nullable: true
          description: The latest problem sending. Clears after the next DM goes out.
        last_error_at: { type: string, format: date-time, nullable: true }
        last_sent_at: { type: string, format: date-time, nullable: true }
        created_at: { type: string, format: date-time }
        sent_count: { type: integer }
        failed_count:
          type: integer
          description: Refused by Instagram, or not confirmed. Unconfirmed DMs are never sent again.
        queued_count: { type: integer }
        clicked_count:
          type: integer
          description: Sent DMs whose link was opened at least once (with `track_clicks`).
        variant_stats:
          type: array
          description: Per version of `messages`, in order.
          items:
            type: object
            properties:
              sent: { type: integer }
              clicked: { type: integer }
        ai_stats:
          type: object
          nullable: true
          description: AI-written DMs, in `ai` mode.
          properties:
            sent: { type: integer }
            clicked: { type: integer }
    PostingSlots:
      type: object
      properties:
        times: { type: array, items: { type: string }, example: ["09:00", "17:30"] }
        interval:
          type: object
          nullable: true
          properties:
            start_time: { type: string }
            end_time: { type: string }
            interval_minutes: { type: integer }
        timezone: { type: string, nullable: true }
        platform_times: { type: object, nullable: true, additionalProperties: { type: string } }
        effective_timezone: { type: string, example: Europe/Helsinki }
        next_slots: { type: array, items: { type: string, format: date-time } }
        move_posts_past_limits:
          type: boolean
          description: Whether scheduled posts move to the next free slot when they hit a daily limit. Workspace setting, on by default.
    Member:
      type: object
      required: [user_id, role, created_at]
      properties:
        user_id: { type: string, format: uuid }
        email: { type: string, nullable: true }
        full_name: { type: string, nullable: true }
        role: { type: string, enum: [owner, admin, member, client] }
        joined_at: { type: string, format: date-time, nullable: true }
        created_at: { type: string, format: date-time }
    Invitation:
      type: object
      required: [id, email, role, status, expires_at, created_at]
      properties:
        id: { type: string, format: uuid }
        email: { type: string }
        role: { type: string, enum: [owner, admin, member, client] }
        status: { type: string, enum: [pending] }
        expires_at: { type: string, format: date-time }
        created_at: { type: string, format: date-time }
        invited_by: { type: string, format: uuid, nullable: true }
    OpusClipProject:
      type: object
      properties:
        project_id: { type: string }
        org_id: { type: string }
        title: { type: string }
        thumbnail_url: { type: string, nullable: true }
        duration_ms: { type: integer, nullable: true, description: Source video length. }
        clip_count: { type: integer }
        stage: { type: string, description: "`COMPLETE` once the clips are ready." }
        created_at: { type: string, format: date-time }
    OpusClipClip:
      type: object
      properties:
        id: { type: string, description: '"<project_id>.<clip>", pass it in `clip_ids`.' }
        project_id: { type: string }
        title: { type: string }
        description: { type: string }
        hashtags: { type: string }
        duration_ms: { type: integer }
        thumbnail_url: { type: string, nullable: true }
        preview_url: { type: string, nullable: true, description: Playable mp4, expires after about a day. }
        caption: { type: string, description: What an import gets as its caption. }
    ImportSource:
      type: object
      properties:
        source: { type: string, example: opusclip }
        connected: { type: boolean }
        items: { type: string, description: 'What the items are: clip, video or design.' }
        has_containers: { type: boolean, description: Items sit in projects; list those first. }
        supports_query: { type: boolean }
        max_per_import: { type: integer }
        options:
          type: object
          additionalProperties:
            type: object
            properties:
              values: { type: array, items: { type: string } }
              default: { type: string }
              applies_to: { type: string, enum: [list, import] }
              description: { type: string }
        summary: { type: string }
    ImportContainer:
      type: object
      additionalProperties: true
      properties:
        id: { type: string, description: Pass as `container_id`. }
        title: { type: string }
        thumbnail_url: { type: string, nullable: true }
        created_at: { type: string, nullable: true }
        ready: { type: boolean, description: The project's clips exist. }
    ImportItem:
      type: object
      additionalProperties: true
      description: Shared fields; sources add a few of their own (e.g. view_count for twitch).
      properties:
        id: { type: string, description: Pass in `item_ids`. }
        title: { type: string }
        caption: { type: string, nullable: true, description: What an import gets; null when the source writes it at import. }
        duration_ms: { type: integer, nullable: true }
        thumbnail_url: { type: string, nullable: true }
        created_at: { type: string, nullable: true }
    ImportResults:
      type: object
      properties:
        source: { type: string }
        data:
          type: array
          items:
            type: object
            additionalProperties: true
            properties:
              item_id: { type: string }
              ok: { type: boolean }
              upload_id: { type: string, description: Pass to `POST /posts`. }
              filename: { type: string }
              size_bytes: { type: integer }
              caption: { type: string }
              title: { type: string, description: Use it as the YouTube title. }
              error: { type: string, description: Set when `ok` is false. }
        imported: { type: integer }
        failed: { type: integer }
        workspace_id: { type: string }
    ClipImportResults:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              clip_id: { type: string }
              ok: { type: boolean }
              upload_id: { type: string, description: Pass to `POST /posts`. }
              filename: { type: string }
              size_bytes: { type: integer }
              caption: { type: string }
              title: { type: string, description: Use it as the YouTube title. }
              error: { type: string, description: Set when `ok` is false. }
        imported: { type: integer }
        failed: { type: integer }
        workspace_id: { type: string }
    InboxPlatform:
      type: string
      enum:
        - instagram
        - facebook
        - youtube
        - threads
        - linkedin
        - bluesky
        - mastodon
        - telegram
        - google_business
      description: A platform the inbox reads from.

    InboxConnection:
      type: object
      required: [id, platform, has_comment_scope, has_messaging_scope, has_like_scope, needs_reconnect, has_mentions_scope]
      properties:
        id: { type: string, format: uuid, description: The connection id. }
        platform: { $ref: "#/components/schemas/InboxPlatform" }
        username: { type: string, nullable: true }
        avatar_url: { type: string, nullable: true }
        connection_status: { type: string, nullable: true, example: active }
        has_comment_scope:
          type: boolean
          description: The connection can read and reply to comments.
        has_messaging_scope:
          type: boolean
          description: The connection can also sync and reply to DMs (Instagram and Facebook).
        has_like_scope:
          type: boolean
          description: |
            The connection can like comments. Only ever true on Instagram,
            Facebook and LinkedIn Company Pages. Instagram needs the Facebook
            Login for Business upgrade (`instagram_manage_engagement`).
        needs_reconnect:
          type: boolean
          description: Sync and reply will fail until someone reconnects the account in ShortSync.
        has_mentions_scope:
          type: boolean
          description: |
            Threads: the connection has `threads_manage_mentions`, so the
            inbox shows @mentions of the account next to direct replies.
            Always true on other platforms.

    InboxConversation:
      type: object
      required: [id, workspace_id, platform, thread_kind, participant_id, unread_count, like_count, liked_by_us, is_spam, is_unseen, is_own_top_level_muted, platform_metadata]
      properties:
        id:
          type: string
          format: uuid
          description: Pass to the messages, reply, like and mark endpoints.
        workspace_id: { type: string, format: uuid }
        platform: { $ref: "#/components/schemas/InboxPlatform" }
        thread_kind:
          type: string
          enum: [dm, post_comments, video_comments]
          description: "`dm` is a DM thread. `post_comments` and `video_comments` are one top-level comment (or mention or review) with its replies."
        participant_id: { type: string }
        participant_username: { type: string, nullable: true }
        participant_avatar_url: { type: string, nullable: true }
        last_message_at: { type: string, format: date-time, nullable: true }
        last_message_preview: { type: string, nullable: true }
        last_inbound_at: { type: string, format: date-time, nullable: true }
        last_outbound_at: { type: string, format: date-time, nullable: true }
        last_seen_at:
          type: string
          format: date-time
          nullable: true
          description: When someone in the workspace last saw it (in the app or with mark-seen).
        unread_count: { type: integer }
        like_count: { type: integer }
        liked_by_us: { type: boolean }
        is_spam: { type: boolean }
        answered_status:
          type: string
          nullable: true
          enum: [answered, unanswered, none, null]
          description: "`unanswered` when the participant wrote after your last reply. `none` when there's nothing to answer, for example your own comment."
        is_unseen: { type: boolean }
        is_own_top_level_muted:
          type: boolean
          description: The thread is your own top-level comment with no replies.
        platform_metadata:
          type: object
          additionalProperties: true
          description: Platform ids. Comment threads carry `post_id` or `video_id`, which `POST /inbox/media/load-more` takes.
        external_conversation_id:
          type: string
          description: The platform's own id for the thread or top-level comment.

    InboxMessage:
      type: object
      required: [id, conversation_id, external_message_id, direction, sender_id, body, attachments, sent_at, liked_by_us, like_count, edited]
      properties:
        id: { type: string, format: uuid }
        conversation_id: { type: string, format: uuid }
        external_message_id: { type: string }
        direction:
          type: string
          enum: [inbound, outbound]
          description: "`inbound` was sent by the participant, `outbound` by you or the connected account."
        sender_id: { type: string }
        sender_username: { type: string, nullable: true }
        body: { type: string }
        attachments:
          type: array
          items: { type: object, additionalProperties: true }
        sent_at: { type: string, format: date-time }
        reply_to_external_id:
          type: string
          nullable: true
          description: The platform id of the message this one replies to.
        send_status:
          type: string
          nullable: true
          enum: [sending, sent, failed, null]
          description: Delivery state of outbound messages. Null on inbound ones.
        liked_by_us: { type: boolean }
        like_count: { type: integer }
        has_our_reply:
          type: boolean
          description: |
            On the messages endpoint only. True on an inbound message when an
            outbound message replies to it or came after it. Always true in a
            thread marked as spam.
        edited:
          type: boolean
          description: The sender edited this Instagram DM after sending it. `body` holds the edited text.
        story_link_url:
          type: string
          nullable: true
          description: On an Instagram DM replying to a story, the story's link sticker.

    InboxReplyAttachment:
      type: object
      required: [type]
      description: Exactly one of `url` and `attachment_id`.
      properties:
        type: { type: string, enum: [image, file] }
        url:
          type: string
          format: uri
          description: A public https URL.
        attachment_id:
          type: string
          description: A Meta attachment id. Images only.
        title:
          type: string
          maxLength: 200
          description: File name shown for a PDF.

    InboxSyncResult:
      type: object
      required: [platform, platform_connection_id, conversations_upserted, messages_upserted, messages_new, dms_new, comments_new, errors]
      properties:
        platform: { $ref: "#/components/schemas/InboxPlatform" }
        platform_connection_id: { type: string, format: uuid }
        conversations_upserted: { type: integer }
        messages_upserted:
          type: integer
          description: Messages saved, new and updated.
        messages_new:
          type: integer
          description: Messages that weren't in the inbox before.
        dms_new: { type: integer }
        comments_new: { type: integer }
        errors:
          type: array
          items:
            type: object
            required: [message]
            properties:
              conversation_id: { type: string }
              message: { type: string }

    InboxLikeInput:
      type: object
      required: [liked]
      properties:
        liked:
          type: boolean
          description: true to like, false to unlike.

    InboxLikeResult:
      type: object
      required: [data]
      properties:
        data:
          type: object
          required: [liked_by_us]
          properties:
            liked_by_us: { type: boolean }

    InboxSavedReplyInput:
      type: object
      properties:
        name:
          type: string
          maxLength: 50
          description: Unique within the workspace.
        content:
          type: string
          maxLength: 5000
          description: The reply text.

    InboxSavedReply:
      type: object
      required: [id, workspace_id, name, content, created_at, updated_at]
      properties:
        id: { type: string, format: uuid }
        workspace_id: { type: string, format: uuid }
        created_by:
          type: string
          format: uuid
          nullable: true
          description: Who created it. Null when that account has been deleted.
        name: { type: string }
        content: { type: string }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    ErrorResponse:
      type: object
      required: [status, code, message]
      properties:
        status:
          type: integer
          description: HTTP status code, echoed in the body for convenience.
        code:
          type: string
          description: Stable machine-readable error code (UPPER_SNAKE_CASE).
        message:
          type: string
          description: Human-readable explanation. May change between versions.
        details:
          description: Optional structured context. Shape depends on `code`.

    PaginatedEnvelope:
      type: object
      required: [data, pagination]
      properties:
        data:
          type: array
          items: { type: object }
        pagination:
          type: object
          required: [next_cursor]
          properties:
            next_cursor:
              type: [string, "null"]
              description: Pass into `cursor` on the next request. `null` when no more pages.

    Identity:
      type: object
      required: [kind, key_id, prefix, organization_id, scopes, plan, quota]
      properties:
        kind: { $ref: "#/components/schemas/KeyKind" }
        key_id: { type: string }
        prefix:
          type: string
          description: First chars of the key, including the `ss_*` prefix. Safe to display.
        organization_id: { type: string }
        workspace_id:
          type: [string, "null"]
          description: Present for `workspace` kind. `null` for `account`.
        workspace_allowlist:
          type: array
          items: { type: string }
          description: Present for `account` kind when scoped. Empty when unscoped (whole org).
        scopes:
          type: array
          items: { $ref: "#/components/schemas/Scope" }
        plan:
          type: string
          enum: [free, creator, team]
          description: "The organization's current plan tier. The monthly quota under `quota` scales with the plan; see your `quota.requests.limit` for the exact cap on this key."
        quota:
          $ref: "#/components/schemas/ApiQuotaSnapshot"

    ApiQuotaSnapshot:
      type: object
      required: [requests, resets_at]
      description: |
        Current calendar-month API request usage and cap for the
        organization. The cap comes from the plan tier (Creator: 50 000
        requests; Team: 500 000 requests) and counts every authenticated
        `/api/v1/*` call. There is no per-post or per-publish cap — paid
        plans get unlimited publishes. Counts reset at `resets_at` (first
        day of next UTC month).

        The cap is **per organization (subscription)**, shared across
        every API key the organization mints. Rotating a key or minting
        additional keys neither resets the counter nor multiplies the
        cap.
      properties:
        requests:
          $ref: "#/components/schemas/QuotaBucket"
        resets_at:
          type: string
          format: date-time

    QuotaBucket:
      type: object
      required: [used, limit, remaining]
      properties:
        used: { type: integer, minimum: 0 }
        limit: { type: integer, minimum: 0 }
        remaining: { type: integer, minimum: 0 }

    KeyKind:
      type: string
      enum: [workspace]
      description: |
        Always `workspace` for keys minted in v1 beta. Legacy account
        tokens may still authenticate on `/me` with `kind: "account"`
        but cannot reach any other endpoint.

    Scope:
      type: string
      enum:
        - uploads:write
        - posts:read
        - posts:write
        - connections:read
        - analytics:read
        - analytics:write
        - webhooks:read
        - webhooks:write
        - inbox:read
        - inbox:write

    WebhookEvent:
      type: string
      enum: [post.published, post.failed, post.scheduled, dm_contact.created]

    WebhookCreate:
      type: object
      required: [url, events]
      properties:
        url:
          type: string
          format: uri
          description: Public https:// URL.
        events:
          type: array
          minItems: 1
          items: { $ref: "#/components/schemas/WebhookEvent" }
        description:
          type: string
          maxLength: 200

    Webhook:
      type: object
      properties:
        id: { type: string, format: uuid }
        url: { type: string, format: uri }
        events:
          type: array
          items: { $ref: "#/components/schemas/WebhookEvent" }
        description: { type: string, nullable: true }
        active: { type: boolean }
        disabled_reason:
          type: string
          nullable: true
          description: Set when ShortSync turned the webhook off (20 failed deliveries in a row, or a 410 answer).
        last_delivery_at: { type: string, format: date-time, nullable: true }
        last_delivery_status: { type: integer, nullable: true }
        consecutive_failures: { type: integer }
        created_at: { type: string, format: date-time }
        secret:
          type: string
          description: Signing secret (`whsec_…`). Only returned by create and roll-secret.

    WebhookDelivery:
      type: object
      properties:
        id: { type: string, format: uuid }
        event_id: { type: string, nullable: true }
        event_type: { type: string }
        status: { type: string, enum: [pending, delivered, failed, retrying] }
        attempts: { type: integer }
        response_status: { type: integer, nullable: true }
        error: { type: string, nullable: true }
        created_at: { type: string, format: date-time }
        delivered_at: { type: string, format: date-time, nullable: true }

    RepurposingStopAction:
      type: string
      enum: [drafts, remove]
      default: drafts
      description: What happens to a scheduled workflow's upcoming posts when it's paused or deleted.

    RepurposingWorkflowSettings:
      type: object
      properties:
        name:
          type: string
          maxLength: 80
          nullable: true
          description: Optional name. Null or empty shows the default label for the kind.
        target_connection_ids:
          type: array
          items: { type: string, format: uuid }
          description: Connections to repost to, not the source. Pinterest needs `target_options.pinterest`, Reddit `target_options.reddit`.
        publish_mode:
          type: string
          enum: [immediate, draft]
          description: New-posts workflows. `immediate` publishes each repost right away; `draft` (default) saves it to the library.
        content_types:
          type: array
          items: { type: string, enum: [video, image, carousel] }
          description: Post types to repost. Default all three.
        caption_suffix:
          type: string
          maxLength: 500
          nullable: true
          description: Text added to every repost's caption.
        target_options:
          type: object
          properties:
            pinterest:
              type: object
              required: [board_id]
              properties:
                board_id: { type: string }
                board_name: { type: string, nullable: true }
            reddit:
              type: object
              required: [subreddit]
              properties:
                subreddit: { type: string, description: Without the r/ prefix. }
            discord:
              type: object
              properties:
                channel_ids: { type: array, items: { type: string } }
            google_business:
              type: object
              properties:
                location_ids: { type: array, items: { type: string } }
            caption_mode:
              type: string
              enum: [title_and_description, split, title]
              description: On YouTube, Pinterest, Reddit and Tumblr the title is the caption's first line. The description is the whole caption (title_and_description), the caption without its first line (split) or empty (title). Defaults to title when the member's saved upload setting is title only, else title_and_description. The older value description is still accepted and saved as title_and_description.
            settings:
              type: object
              description: |
                Per-platform settings, keyed by platform, in the same camelCase
                shape the dashboard stores (e.g. `{ "youtube": { "privacyStatus":
                "unlisted", "categoryId": "20" }, "tiktok": { "privacyLevel":
                "SELF_ONLY" } }`). Anything unset uses the member's saved upload
                settings. Per-post fields (titles, alt text, subtitles, polls)
                are ignored.
              additionalProperties: { type: object }
        enabled: { type: boolean, description: false pauses the workflow. }
        schedule_slots:
          type: object
          description: Scheduled workflows. Keys "0" (Sunday) to "6" (Saturday); values are HH:mm times, up to 5 a day.
          additionalProperties:
            type: array
            items: { type: string, pattern: "^\\d{2}:\\d{2}$" }
          example: { "1": ["10:00"], "3": ["10:00", "16:00"] }
        timezone: { type: string, description: "Scheduled workflows. IANA zone, e.g. Europe/Helsinki." }
        include_from: { type: string, format: date-time, nullable: true, description: Scheduled workflows. Only source posts published from this date. }
        include_until: { type: string, format: date-time, nullable: true, description: Scheduled workflows. Only source posts published until this date. }
        publish_order: { type: string, enum: [newest, oldest, most_viewed], description: Scheduled workflows. Default newest. most_viewed is Twitch only. }

    RepurposingWorkflow:
      allOf:
        - type: object
          properties:
            id: { type: string, format: uuid }
            workspace_id: { type: string, format: uuid }
            kind: { type: string, enum: [new_posts, existing] }
            status: { type: string, enum: [running, paused, finished] }
            source_type: { type: string, enum: [platform_connection, twitch] }
            source_connection_id:
              type: string
              format: uuid
              nullable: true
              description: Null for Twitch workflows.
            source_account:
              type: object
              nullable: true
              description: Twitch workflows only; the channel they repost from.
              properties:
                id: { type: string }
                name: { type: string, nullable: true }
            queue:
              type: object
              nullable: true
              description: Scheduled workflows only.
              properties:
                published_count: { type: integer }
                scheduled_count: { type: integer }
                waiting_count: { type: integer, description: Matching source posts not scheduled yet. }
            last_synced_at: { type: string, format: date-time, nullable: true }
            last_error: { type: string, nullable: true }
            finished_at: { type: string, format: date-time, nullable: true }
            created_at: { type: string, format: date-time }
            updated_at: { type: string, format: date-time }
        - $ref: "#/components/schemas/RepurposingWorkflowSettings"

    RepurposingWorkflowPost:
      type: object
      properties:
        id: { type: string, format: uuid, description: Use as post_id to cancel the repost. }
        workflow_id: { type: string, format: uuid }
        status: { type: string, enum: [processing, scheduled, posted, drafted, skipped, failed] }
        source:
          type: object
          properties:
            platform: { type: string }
            post_id: { type: string }
            permalink: { type: string, nullable: true }
            content_type: { type: string, nullable: true }
        caption: { type: string, nullable: true }
        upload_id: { type: string, format: uuid, nullable: true, description: The repost in the library. }
        scheduled_for: { type: string, format: date-time, nullable: true }
        posts:
          type: array
          items:
            type: object
            properties:
              id: { type: string, format: uuid, description: Post id for the Posts endpoints. }
              platform: { type: string }
              status: { type: string }
              url: { type: string, nullable: true }
              scheduled_for: { type: string, format: date-time, nullable: true }
              published_at: { type: string, format: date-time, nullable: true }
        error: { type: string, nullable: true, description: Why it was skipped or failed. }
        created_at: { type: string, format: date-time }

    UploadCreate:
      type: object
      description: |
        `POST /uploads` accepts an empty body or an optional `filename` hint.
        When provided, `filename` is baked into the presigned URL as an
        `x-amz-meta-filename` header that the PUT must echo, and surfaces
        on the final `Upload.filename` field.
      properties:
        filename:
          type: string
          maxLength: 255
          description: |
            Optional. Original filename for display only. ShortSync derives
            container/codec from the PUT's `Content-Type`; the filename
            does not affect validation. With `source_url`, pass a filename
            with the right extension when the link has none (Google Drive
            links), since it's used to tell the media type.
        source_url:
          type: string
          format: uri
          description: |
            Optional. A public https:// direct-download link to a video or
            image. ShortSync downloads it and returns a ready upload, so
            there's no PUT step. The server must send Content-Length; links
            to private networks are refused. Same size caps as other
            uploads. Send an `Idempotency-Key` so a retry doesn't import the
            file twice.

    UploadFromUrl:
      type: object
      required: [upload_id, status, filename, content_type, size_bytes, source_url, workspace_id]
      properties:
        upload_id: { type: string }
        status:
          type: string
          enum: [ready]
        filename: { type: string }
        content_type: { type: string, description: MIME type, e.g. video/mp4. }
        size_bytes: { type: integer }
        source_url: { type: string, format: uri, description: The URL after redirects. }
        workspace_id: { type: string }

    UploadTicket:
      type: object
      required: [upload_id, presigned_url, method, expires_at, workspace_id]
      properties:
        upload_id: { type: string }
        presigned_url: { type: string, format: uri }
        method:
          type: string
          enum: [PUT]
        expires_at: { type: string, format: date-time }
        workspace_id: { type: string }
        required_headers:
          type: object
          additionalProperties: { type: string }
          description: |
            Only present when `filename` was supplied to `POST /uploads`.
            The PUT to `presigned_url` MUST include every header in this
            map verbatim (currently `x-amz-meta-filename`), otherwise S3
            rejects the upload with a signature mismatch.

    Upload:
      type: object
      required:
        [
          id,
          status,
          filename,
          content_type,
          size_bytes,
          workspace_id,
          created_at,
        ]
      properties:
        id: { type: string }
        status:
          type: string
          enum: [reserved, ready]
          description: |
            - `reserved` - ticket issued, bytes not yet finalized
            - `ready` - bytes finalized, usable as a post source

            In v1 the server skips the post-upload media probe, so transitional
            `uploaded` / `failed` states are reserved for future use.
        filename:
          type: string
          description: |
            Original filename if supplied to `POST /uploads`; otherwise
            derived from the S3 object key (typically the literal
            `"upload"` for empty-body reservations).
        content_type:
          type: string
          description: |
            Canonical MIME of the uploaded bytes (e.g., `video/mp4`,
            `image/jpeg`), read from the `Content-Type` the client set on
            the PUT to the presigned URL and validated against the
            allow-list at finalize.
        size_bytes: { type: integer }
        workspace_id: { type: string }
        carousel_items:
          type: array
          description: Carousels only. Their images and videos, in order.
          items:
            type: object
            required: [upload_id, filename, content_kind, position]
            properties:
              upload_id:
                type: [string, "null"]
                description: The item's own upload id.
              filename:
                type: [string, "null"]
                description: The item's original filename.
              content_kind:
                type: [string, "null"]
                enum: [video, image, null]
              position:
                type: integer
                description: 0-based place in the carousel.
        media:
          $ref: "#/components/schemas/UploadMedia"
        error:
          type: [object, "null"]
          properties:
            code: { type: string }
            message: { type: string }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    UploadMedia:
      type: object
      description: |
        Probed properties of the uploaded file. Populated for `video`
        uploads via server-side ffprobe at finalize time; fields fall
        back to `null` when a probe field can't be read. Images currently
        report `content_kind: "image"` with all other fields `null`.
      properties:
        content_kind:
          type: string
          enum: [video, image, text, carousel]
        duration_seconds: { type: [number, "null"] }
        width: { type: [integer, "null"] }
        height: { type: [integer, "null"] }
        aspect_ratio: { type: [number, "null"] }
        fps: { type: [number, "null"] }
        bitrate_kbps: { type: [integer, "null"] }
        video_codec: { type: [string, "null"] }
        audio_codec: { type: [string, "null"] }

    Connection:
      type: object
      required: [id, workspace_id, platform, status, connected_at]
      properties:
        id: { type: string }
        workspace_id: { type: string }
        platform: { $ref: "#/components/schemas/Platform" }
        display_name:
          type: [string, "null"]
          description: Username or page name from the upstream platform.
        status: { $ref: "#/components/schemas/ConnectionStatus" }
        scopes:
          type: array
          items: { type: string }
          description: OAuth scopes granted by the user.
        connected_at: { type: string, format: date-time }
        reconnect_url:
          type: string
          format: uri
          description: |
            Only in `GET /connections`, on connections the user must sign in
            to again (`token_expired`, `refresh_failed`, `needs_reconnect`).
            A connect link to show or send to the user.

    ConnectLink:
      type: object
      required: [url, platform, action, connection, steps]
      properties:
        url:
          type: string
          format: uri
          description: The link to show or send to the user.
          example: https://www.shortsync.app/connect/tiktok?workspace_id=bbdeeb40-...&via=api
        platform: { $ref: "#/components/schemas/Platform" }
        action:
          type: string
          enum: [connect, reconnect]
          description: "`reconnect` when the workspace already has this platform."
        connection:
          type: [object, "null"]
          description: The existing connection on a reconnect.
          properties:
            id: { type: string }
            username: { type: [string, "null"] }
            status: { type: [string, "null"] }
        steps:
          type: string
          description: What the user will see, in plain words.

    ConnectionStatus:
      type: string
      enum:
        - active
        - token_expired
        - refresh_failed
        - needs_reconnect
        - rate_limited

    Platform:
      type: string
      enum:
        - instagram
        - tiktok
        - youtube
        - facebook
        - snapchat
        - pinterest
        - threads
        - twitter
        - bluesky
        - linkedin
        - reddit
        - telegram
        - mastodon
        - discord
        - tumblr
        - pixelfed
        - google_business

    PublishMode:
      type: string
      enum: [immediate, scheduled, draft]

    PostStatus:
      type: string
      enum:
        - processing
        - ready
        - scheduled
        - published
        - failed
        - deleted
        - skipped_inactive_subscription
        - subscription_hold

    PostCreate:
      type: object
      required: [publish_mode, targets]
      properties:
        upload_id:
          type: string
          description: |
            ID returned from `POST /uploads`. Leave it out for a text-only
            post: the `caption` is the post. Platforms that need media
            (TikTok, YouTube, Instagram, Pinterest, Snapchat) can't take
            text-only posts.
        publish_mode: { $ref: "#/components/schemas/PublishMode" }
        scheduled_for:
          type: string
          format: date-time
          description: Required when `publish_mode=scheduled` (unless every target specifies its own `scheduled_for`).
        notify_on_success:
          type: boolean
          default: false
          description: Send the org owner an email when publishing succeeds.
        caption:
          type: string
          description: |
            Default caption applied to every non-YouTube target. Per-target
            `caption` overrides it. YouTube targets ignore this and read
            `target.title` + `target.description` instead.
        first_comment:
          type: string
          description: |
            Default first comment applied to every target that supports
            first comments: YouTube, Instagram, Facebook, Threads, Bluesky,
            X, LinkedIn, Mastodon, Discord, Pixelfed and Reddit.
            Per-target `first_comment` overrides it.
        first_comment_delay_minutes:
          type: integer
          minimum: 0
          maximum: 10080
          default: 0
          description: |
            Minutes after the post goes live to post the first comment.
            `0` posts it right away. Up to 10080 (7 days). Applies to
            every target except Reddit, whose first comment is always
            posted with the post.
        follow_up_comments:
          type: array
          maxItems: 4
          description: |
            Up to 4 more comments after the first comment (5 per post in
            total), posted on the same platforms as the first comment and
            shared by every target. Not posted on X or Reddit, which only
            get the first comment. On Threads, Bluesky, Mastodon and Pixelfed each
            one replies to the previous comment, so they read as a thread.
          items:
            $ref: "#/components/schemas/FollowUpComment"
        alt_text:
          type: string
          description: |
            Alt text for every target whose platform takes it (Instagram,
            Pinterest, Bluesky, Mastodon, LinkedIn, X, Threads, Tumblr),
            cut to each platform's limit. On carousels it's the first
            image's text, which Pinterest uses. A target's own
            `platform_options.alt_text` / `alt_texts` wins.
        alt_texts:
          type: object
          additionalProperties: { type: string }
          description: |
            Carousels: alt text per image, keyed by the image's upload id,
            for every target whose platform takes alt text per image.
        targets:
          type: array
          minItems: 1
          maxItems: 10
          items: { $ref: "#/components/schemas/PostTarget" }
        custom_thumbnail_url:
          type: string
          description: |
            Public `https://` URL to a cover image (jpeg, png, webp, or
            gif, max 20 MB). ShortSync downloads and stores it. YouTube,
            Instagram Reels, Facebook Reels and Pinterest use it as the
            cover. Send an empty string to clear. Mutually exclusive with
            `thumbnail_timestamp_ms` and `custom_thumbnail_upload_id`.
        thumbnail_timestamp_ms:
          type: integer
          minimum: 0
          description: |
            Extract a frame from the video at this timestamp
            (milliseconds) and use it as the cover. Video-only.
            Mutually exclusive with `custom_thumbnail_url` and
            `custom_thumbnail_upload_id`.
        custom_thumbnail_upload_id:
          type: string
          description: |
            `upload_id` from `POST /uploads` whose bytes are an image.
            ShortSync copies the image into the post's thumbnail slot
            and then deletes the source upload. Mutually exclusive with
            `custom_thumbnail_url` and `thumbnail_timestamp_ms`.
        recurrence:
          type: object
          description: |
            Repeat the post. Needs `publish_mode=scheduled` and a top-level
            `scheduled_for`, which is the first occurrence. Every scheduled
            target is repeated at the same interval, up to 12 occurrences in
            all, and the posts share a series. Each occurrence uses one
            upload credit on plans with a monthly limit. The response
            includes a post for every occurrence.
          required: [interval, unit, end_type]
          properties:
            interval:
              type: integer
              minimum: 1
              maximum: 12
              description: Repeat every `interval` units.
            unit:
              type: string
              enum: [day, week, month]
            end_type:
              type: string
              enum: [count, date]
              description: Stop after `count` occurrences, or on `end_date`.
            count:
              type: integer
              minimum: 2
              maximum: 12
              description: Total occurrences, including the first. Required when `end_type=count`.
            end_date:
              type: string
              format: date
              description: Last day an occurrence may fall on (`YYYY-MM-DD`, inclusive). Required when `end_type=date`.

    PostTarget:
      type: object
      required: [connection_id]
      properties:
        connection_id: { type: string }
        caption:
          type: string
          description: |
            Per-target caption. Falls back to the top-level `caption`.
            Ignored for YouTube targets — YouTube uses `title` and
            `description`.
        title:
          type: string
          description: |
            Sets the post title, used by YouTube, Pinterest, Tumblr (where it's an optional heading) and Reddit (where it's the required post title, max 300 characters).
        description:
          type: string
          description: |
            Sets the long-form description, used by YouTube, Pinterest, Tumblr (where it's the post text) and Reddit (where it's the post body).
        first_comment: { type: string }
        first_comment_enabled:
          type: boolean
          description: |
            Set `false` to skip the first comment on this target even when a
            top-level `first_comment` is set. Omit to use the user's saved
            default (on, unless turned off for this platform in the
            dashboard).
        scheduled_for:
          type: string
          format: date-time
          description: Per-target schedule override. Falls back to top-level `scheduled_for`.
        platform_options:
          $ref: "#/components/schemas/PlatformOptions"

    PostReplaceMedia:
      type: object
      required: [upload_id]
      properties:
        upload_id:
          type: string
          description: Id of a finished upload (from `POST /uploads`) in this workspace. Text posts and carousels can't be swapped in.
        apply_to_batch:
          type: boolean
          default: false
          description: Also swap the other posts in this post's batch (same media, same status, same scheduled time).

    PostUpdate:
      type: object
      description: |
        Patch a post. All fields are optional. Send only what you want to
        change. Omitted fields keep their current value. To clear a text
        field, send it explicitly as an empty string.
      properties:
        publish_mode: { $ref: "#/components/schemas/PublishMode" }
        scheduled_for: { type: string, format: date-time }
        caption:
          type: string
          description: |
            New caption. Applies to this post's platform. Ignored if the
            post is on YouTube (YouTube reads `title` and `description`
            instead).
        title:
          type: string
          description: |
            New title (YouTube, Pinterest, Tumblr, Reddit).
        description:
          type: string
          description: |
            New long-form description (YouTube, Pinterest, Tumblr, Reddit).
        first_comment:
          type: string
          description: |
            New first comment. Ignored on platforms that don't support
            first comments.
        first_comment_enabled:
          type: boolean
          description: |
            `false` skips the first comment on this post's platform;
            `true` turns it back on.
        first_comment_delay_minutes:
          type: integer
          minimum: 0
          maximum: 10080
          description: |
            Minutes after the post goes live to post the first comment;
            `0` = right away. Shared by every post of the upload.
        follow_up_comments:
          type: array
          maxItems: 4
          description: |
            Replaces the follow-up comments of every post of the upload.
            `[]` removes them.
          items:
            $ref: "#/components/schemas/FollowUpComment"
        platform_options:
          $ref: "#/components/schemas/PlatformOptions"
        custom_thumbnail_url:
          type: string
          description: |
            Public `https://` URL to a cover/thumbnail image (jpeg, png,
            webp, or gif, max 20 MB). ShortSync downloads the image,
            stores it in the workspace's bucket, and attaches it to the
            post's video settings so every unpublished post on the same
            upload uses it at publish time (YouTube, Instagram Reels,
            Facebook Reels and Pinterest use it as the cover). Send an
            empty string to remove the current custom thumbnail. SSRF guards: `https`
            only, public IPs. Mutually exclusive with
            `thumbnail_timestamp_ms` and `custom_thumbnail_upload_id`.
        thumbnail_timestamp_ms:
          type: integer
          minimum: 0
          description: |
            Extract a frame from the post's linked video at this
            timestamp (milliseconds from the start) and store it as the
            video's "Thumbnail from Timeline" (`generated_thumbnail_url`),
            matching what the dashboard scrubber writes. Video-only:
            rejects text posts, image uploads, and carousel parents.
            Must be within the video's duration.

            Publish-time behavior: this does NOT overwrite a
            `custom_thumbnail_url` the user already set. Platforms that
            read `custom_thumbnail_url || generated_thumbnail_url`
            (YouTube, Facebook Reels, Pinterest, and others) fall back to this timeline
            frame when no custom cover is set. Instagram reads only the
            custom column, so a timeline frame alone will not affect the
            Instagram cover — pass `custom_thumbnail_url` or
            `custom_thumbnail_upload_id` for that. To override an
            existing custom cover with the timeline frame, first clear
            the custom by sending `custom_thumbnail_url: ""`, then set
            the timestamp.

            Mutually exclusive with `custom_thumbnail_url` and
            `custom_thumbnail_upload_id`.
        custom_thumbnail_upload_id:
          type: string
          description: |
            `upload_id` returned by `POST /uploads` for an image file
            in the same workspace. ShortSync finalizes the upload if
            needed, copies the bytes into the post's thumbnail slot,
            and then deletes the source upload so it does not linger
            as an unattached draft. The thumbnail is stored
            independently — deleting the source does not affect the
            cover. Use this instead of `custom_thumbnail_url` when
            the image is already uploaded, to avoid a public re-host
            round-trip. Mutually exclusive with `custom_thumbnail_url`
            and `thumbnail_timestamp_ms`.

    Post:
      type: object
      required:
        [
          id,
          workspace_id,
          platform,
          connection_id,
          status,
          publish_mode,
          created_at,
        ]
      properties:
        id: { type: string }
        workspace_id: { type: string }
        upload_id:
          type: [string, "null"]
        platform: { $ref: "#/components/schemas/Platform" }
        connection_id: { type: string }
        status: { $ref: "#/components/schemas/PostStatus" }
        publish_mode: { $ref: "#/components/schemas/PublishMode" }
        scheduled_for: { type: [string, "null"], format: date-time }
        published_at: { type: [string, "null"], format: date-time }
        platform_url:
          type: [string, "null"]
          format: uri
          description: Public URL of the published post, when available.
        caption: { type: [string, "null"] }
        title: { type: [string, "null"] }
        description: { type: [string, "null"] }
        first_comment: { type: [string, "null"] }
        first_comment_delay_minutes:
          type: integer
          description: Minutes after the post goes live; `0` = right away.
        follow_up_comments:
          type: array
          items:
            $ref: "#/components/schemas/FollowUpComment"
        platform_options:
          $ref: "#/components/schemas/PlatformOptions"
        error:
          type: [object, "null"]
          properties:
            code: { type: string }
            message: { type: string }
            details: {}
        duplicate_of:
          type: [string, "null"]
          description: |
            Set when this post was stopped as a copy of another post: that
            post's id. `status` stays `failed` because it didn't publish, and
            `error.code` is `ALREADY_PUBLISHED`, but it needs no action. Don't
            retry it.
        moved:
          type: [object, "null"]
          description: |
            Set while the post sits at the slot a daily limit moved it to.
            `scheduled_for` is the new time. Goes back to `null` if the post is
            rescheduled by hand.
          properties:
            original_scheduled_for: { type: string, format: date-time }
            moved_at: { type: string, format: date-time }
            reason: { type: string, enum: [daily_limit] }
            move_count:
              type: integer
              description: How many times the post has moved, 1 or more.
        skipped:
          type: [object, "null"]
          description: |
            Set when a recurring occurrence was skipped because a daily limit
            stayed full until its next repeat. `status` stays `failed` with
            error code `LIMIT_SKIPPED`, but it needs no action and the series
            carries on.
          properties:
            reason: { type: string, enum: [daily_limit] }
            skipped_at: { type: string, format: date-time }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    FollowUpComment:
      type: object
      required: [text]
      properties:
        text:
          type: string
          description: The comment text. Same platform limits as the first comment.
        delay_minutes:
          type: integer
          minimum: 0
          maximum: 10080
          default: 0
          description: |
            Minutes after the post goes live. `0` = right after the post
            (about a minute later, once the first comment is up).
        skip_platforms:
          type: array
          items: { type: string }
          description: Platforms that skip this comment, e.g. `["twitter"]`.

    PlatformOptions:
      type: object
      description: |
        Per-platform overrides. Keys are platform identifiers; values are
        platform-specific objects. Only the keys matching the target's platform
        are read.
      properties:
        tiktok: { $ref: "#/components/schemas/TikTokOptions" }
        youtube: { $ref: "#/components/schemas/YouTubeOptions" }
        instagram: { $ref: "#/components/schemas/InstagramOptions" }
        facebook: { $ref: "#/components/schemas/FacebookOptions" }
        twitter: { $ref: "#/components/schemas/TwitterOptions" }
        threads: { $ref: "#/components/schemas/ThreadsOptions" }
        bluesky: { $ref: "#/components/schemas/BlueskyOptions" }
        snapchat: { $ref: "#/components/schemas/SnapchatOptions" }
        pinterest: { $ref: "#/components/schemas/PinterestOptions" }
        linkedin: { $ref: "#/components/schemas/LinkedInOptions" }
        telegram: { $ref: "#/components/schemas/TelegramOptions" }
        mastodon: { $ref: "#/components/schemas/MastodonOptions" }
        discord: { $ref: "#/components/schemas/DiscordOptions" }
        tumblr: { $ref: "#/components/schemas/TumblrOptions" }
        reddit: { $ref: "#/components/schemas/RedditOptions" }
        pixelfed: { $ref: "#/components/schemas/PixelfedOptions" }
        google_business: { $ref: "#/components/schemas/GoogleBusinessOptions" }

    TikTokOptions:
      type: object
      properties:
        post_mode:
          type: string
          enum: [direct, draft]
        privacy_level:
          type: string
          description: TikTok privacy level (e.g. `PUBLIC_TO_EVERYONE`).
        disable_comment: { type: boolean }
        disable_duet: { type: boolean }
        disable_stitch: { type: boolean }
        commercial_content_disclosure:
          type: boolean
          description: |
            Turns on TikTok's commercial content disclosure. Must be true
            for `is_branded_content` and `is_your_brand` to take effect.
        is_branded_content: { type: boolean }
        is_your_brand: { type: boolean }
        is_aigc: { type: boolean }
        auto_add_music:
          type: boolean
          description: |
            Photo/carousel posts only. When true, TikTok auto-picks and
            attaches background music. Ignored for video uploads.

    YouTubeOptions:
      type: object
      properties:
        privacy_status:
          type: string
          enum: [public, unlisted, private]
          description: |
            Defaults to the workspace's saved YouTube visibility, else
            `public` (same as the dashboard).
        made_for_kids:
          type: boolean
          description: |
            Required when the video is primarily directed at children.
            Setting to `true` disables comments, personalized ads, and
            forces `notify_subscribers` to false (YouTube doesn't allow
            subscriber notifications on kid-directed content).
        notify_subscribers: { type: boolean }
        category_id: { type: string }
        default_language: { type: string }
        tags:
          type: array
          items: { type: string }
        playlist_ids:
          type: array
          items: { type: string }
        upload_early_for_review:
          type: boolean
          description: Upload as private now and flip to public at `scheduled_for`.
        contains_synthetic_media:
          type: boolean
          description: |
            YouTube's "Altered content / AI use" disclosure. Enable when
            the video contains synthetic, altered, or AI-generated
            content that could be mistaken for a real place, person, or
            event. Maps to `status.containsSyntheticMedia`.
        recording_date:
          type: string
          format: date
          description: |
            Date the video was recorded, as `YYYY-MM-DD`. Surfaces in
            YouTube Studio under "Recording date and location". Maps to
            `recordingDetails.recordingDate` (pinned to midnight UTC).
        has_paid_product_placement:
          type: boolean
          description: |
            YouTube's paid promotion disclosure. Enable when the video
            contains paid product placement or sponsorship. YouTube
            shows an "Includes paid promotion" label to viewers. Maps
            to `paidProductPlacementDetails.hasPaidProductPlacement`.
        brand_partner:
          type: string
          description: |
            The brand on a paid-promotion video: its YouTube channel
            handle (`@brand`) or channel ID (`UC...`). Only used when
            `has_paid_product_placement` is true. Set after upload with
            `videos.brandPartner`; a channel that can't link brand
            partners still gets the video posted without it.

    InstagramOptions:
      type: object
      properties:
        share_to_feed:
          type: boolean
          description: |
            Reel also appears in the main feed. Mutually exclusive with
            `story_only`.
        share_to_story:
          type: boolean
          description: |
            Cross-post a Story alongside the Reel, single image or
            carousel. A carousel goes to Stories as one frame per slide,
            in order; video slides over 60 seconds are left out.
            Mutually exclusive with `story_only`.
        story_only:
          type: boolean
          description: |
            Publish only as a Story (no Reel or feed post). Works for
            single videos up to 60 seconds, single images and carousels
            (one Story frame per slide). Mutually exclusive with
            `share_to_feed` and `share_to_story`.
        trial_reel: { type: boolean }
        trial_graduation_strategy:
          type: string
          enum: [MANUAL, SS_PERFORMANCE]
        regular_reel_after_days:
          type: integer
          minimum: 1
          maximum: 30
          description: >-
            With trial_reel, also post the video as a regular Reel this many
            days after the trial, at the same time. Scheduled once the trial
            is published, as its own Instagram post.
        audio_name: { type: string }
        collaborators:
          type: array
          items: { type: string }
        user_tags:
          type: array
          items: { type: string }
          description: >-
            Usernames to tag. On carousels the tags go on the first image
            slide; Instagram doesn't allow tags on the carousel itself or
            on video slides.
        location_id:
          type: string
          description: Facebook Page ID of the location to tag.
        is_paid_partnership:
          type: boolean
          description: Shows the "Paid partnership" label.
        brand_partners:
          type: array
          maxItems: 2
          items: { type: string }
          description: |
            Instagram usernames of up to 2 brands on a paid partnership
            post (needs `is_paid_partnership`). Requires Facebook Login for
            Instagram on the workspace; brands that can't be found are
            skipped.
        product_tags:
          type: array
          items:
            type: object
            required: [product_id]
            properties:
              product_id:
                type: string
                description: Product id from the account's Instagram Shop catalog.
              x:
                type: number
                minimum: 0
                maximum: 1
                description: Horizontal position on an image (0 left, 1 right).
              y:
                type: number
                minimum: 0
                maximum: 1
                description: Vertical position on an image (0 top, 1 bottom).
          description: |
            Products to tag on a single image or Reel (Reels ignore x/y).
            Business accounts with an approved Instagram Shop only;
            requires Facebook Login for Instagram. Not supported on
            carousels or Stories. Beta.
        poll:
          type: object
          required: [options]
          description: |
            Poll on a feed post, carousel or Reel, with the caption as its
            question. Not on Stories, and not together with comment_prompt.
            Requires Facebook Login for Instagram, or the post fails. Beta.
          properties:
            options:
              type: array
              minItems: 2
              maxItems: 4
              items:
                type: string
                minLength: 1
                maxLength: 25
            extended:
              type: boolean
              description: Leave the poll open instead of closing it after 3 days.
        comment_prompt:
          type: boolean
          description: |
            Turns the caption into a prompt that people answer in the
            comments. Feed posts, carousels and Reels, not Stories. Requires
            Facebook Login for Instagram, or the post fails. Beta.
        story_caption:
          type: boolean
          description: |
            Shows the caption on the Story. A carousel shows it on the first
            frame only. Beta.
        is_ai_generated:
          type: boolean
          description: Adds Instagram's "AI content" label to the post.
        comment_dm:
          type: object
          nullable: true
          description: |
            DM automation for this post: when someone comments one of the
            keywords, they get a DM. Checked when the post is saved and
            started when it goes live (feed posts, carousels and Reels, not
            Stories). Needs the DM automation add-on on Creator, or Team.
            Same fields as a comment DM rule (`keywords`, `messages`,
            `message_mode`, `ai_brief`, `link`, `public_reply_enabled`,
            `public_replies`, `track_clicks`, `delivery`, `button_label`,
            `card_title`, `card_subtitle`, `gate` and the step fields,
            `followup_enabled`, `followup_max`), plus `enabled`. Null removes it.
          required: [keywords]
          properties:
            enabled: { type: boolean, default: true }
            track_clicks:
              type: boolean
              default: true
              description: |
                Send the link through a `https://www.shortsync.app/l/` short link
                so clicks are counted (`clicked_count`, `variant_stats`,
                `ai_stats`).
            delivery:
              type: string
              enum: [text, button, card]
              default: text
              description: |
                How the link is sent. `text`: inside the message. `button`: the
                message (up to 640 characters, `{link}` left out) with a link
                button. `card`: a card with `card_title`, `card_subtitle` and a
                link button (image cards are set up in ShortSync). Button and card
                need a `link`. If Instagram doesn't accept a button or card in a
                reply to a comment, the message goes out as text with the link.
            button_label:
              type: string
              nullable: true
              maxLength: 20
              description: Button text for `button` and `card`. Defaults to "Open link".
            card_title:
              type: string
              nullable: true
              maxLength: 80
              description: Required for `card`.
            card_subtitle:
              type: string
              nullable: true
              maxLength: 80
            keywords:
              type: array
              maxItems: 20
              items: { type: string, maxLength: 50 }
            messages:
              type: array
              minItems: 1
              maxItems: 5
              items: { type: string }
            message_mode: { type: string, enum: [variants, ai] }
            ai_brief: { type: string, nullable: true, maxLength: 500 }
            link: { type: string, nullable: true, maxLength: 500 }
            public_reply_enabled: { type: boolean }
            public_replies:
              type: array
              maxItems: 5
              items: { type: string, maxLength: 300 }
        alt_text:
          type: string
          maxLength: 1000
          description: |
            Alt text for a single image post, read aloud by screen readers.
            Ignored for Reels, Stories and carousels (use `alt_texts`).
        alt_texts:
          type: object
          additionalProperties:
            type: string
            maxLength: 1000
          description: |
            Alt text for the images in a carousel, keyed by each image's
            upload id. Videos in a carousel can't have alt text.

    FacebookOptions:
      type: object
      properties:
        share_to_story:
          type: boolean
          description: |
            Also post as a Story alongside the Reel or photo. Mutually
            exclusive with `story_only`. Not for carousels or text posts.
        story_only:
          type: boolean
          description: |
            Publish only as a Story (no Reel or feed post). Works for
            single videos up to 60 seconds and single photos. Mutually
            exclusive with `share_to_story`.
        is_ai_generated:
          type: boolean
          description: |
            Adds Facebook's "AI info" label to the Reel, photo or carousel.
            Not applied to Stories or text posts.
        location_id:
          type: string
          description: |
            Reels only. Facebook Page ID of a place with an address, shown
            as the Reel's location. If Facebook doesn't accept it, the Reel
            is posted without a location. Ignored for photos, carousels,
            text posts and Stories. Beta.
        collaborators:
          type: array
          maxItems: 10
          items: { type: string }
          description: |
            Reels only. Facebook Page IDs (or Page links that include the
            ID) to invite as collaborators after the Reel is published. The
            Reel appears on a Page once it accepts. Facebook allows 10
            invites per Page per 24 hours; an invite that fails doesn't fail
            the post. Ignored for photos, carousels, text posts and Stories.

    TwitterOptions:
      type: object
      properties:
        alt_text:
          type: string
          maxLength: 1000
          description: "Alt text for a single image. If X refuses it, the post goes out without it."
        alt_texts:
          type: object
          additionalProperties: { type: string, maxLength: 1000 }
          description: "Multi-image posts, alt text per image keyed by the image's upload id."
        paid_partnership:
          type: boolean
          description: "X labels the post as a paid promotion (`paid_partnership`). If X refuses the field, the post goes out without it."
        reply_settings:
          type: string
          enum: [everyone, following, mentionedUsers, subscribers, verified]
        community_id: { type: string }
        text_only: { type: boolean }
        for_super_followers_only: { type: boolean }
        poll:
          type: object
          nullable: true
          description: |
            Text posts only (create the post without `upload_id`). The
            caption is the question. X doesn't allow editing a poll once
            it's posted.
          required: [options]
          properties:
            options:
              type: array
              minItems: 2
              maxItems: 4
              items: { type: string, maxLength: 25 }
            duration_minutes:
              type: integer
              minimum: 5
              maximum: 10080
              default: 1440

    ThreadsOptions:
      type: object
      properties:
        alt_text:
          type: string
          maxLength: 1000
          description: "Alt text for a single image or video."
        alt_texts:
          type: object
          additionalProperties: { type: string, maxLength: 1000 }
          description: "Carousels, alt text per item keyed by the item's upload id."
        topic_tag:
          type: string
          maxLength: 50
          description: "One topic tag for the post (`topic_tag`); a Threads community's exact name, like Book Threads, posts into that community. Periods and \"&\" are removed."
        reply_control:
          type: string
          enum: [everyone, accounts_you_follow, mentioned_only, followers_only]
          description: "Who can reply to the post."
        text_only: { type: boolean }
        poll:
          type: object
          nullable: true
          description: |
            Text posts only (create the post without `upload_id`). The
            caption is the question. Threads keeps the poll open for 24
            hours.
          required: [options]
          properties:
            options:
              type: array
              minItems: 2
              maxItems: 4
              items: { type: string, maxLength: 25 }
        is_ai_generated:
          type: boolean
          description: |
            Adds Threads' "AI content" label to the post. Works on text, image,
            video and carousel posts.

    BlueskyOptions:
      type: object
      properties:
        alt_text:
          type: string
          maxLength: 2000
          description: "Alt text for a single image or video. Images without it use the caption."
        alt_texts:
          type: object
          additionalProperties: { type: string }
          description: "Carousels, alt text per image keyed by the image's upload id."
        langs:
          type: array
          items: { type: string }
        text_only: { type: boolean }

    LinkedInOptions:
      type: object
      properties:
        alt_text:
          type: string
          maxLength: 4086
          description: "Alt text for a single image. Without it, the post's title is used."
        alt_texts:
          type: object
          additionalProperties: { type: string, maxLength: 4086 }
          description: "Multi-image posts, alt text per image keyed by the image's upload id."
        link_preview:
          type: boolean
          description: "Text posts only, without a poll or document. Adds a link card (title, description, image) for the first link in the post text. Posted as plain text if the page can't be read."
        visibility:
          type: string
          enum: [PUBLIC, CONNECTIONS, LOGGED_IN]
          default: PUBLIC
          description: |
            Who can see the post. Company Page authors always post as
            `PUBLIC`; LinkedIn doesn't support the other values for Pages.
        poll:
          type: object
          nullable: true
          description: |
            Text posts only (create the post without `upload_id`). Posts a
            single-choice LinkedIn poll with the caption above it. Can't be
            combined with `document`. LinkedIn doesn't allow editing a poll
            once it's posted. The duration counts from publish time.
          required: [question, options]
          properties:
            question:
              type: string
              maxLength: 140
            options:
              type: array
              minItems: 2
              maxItems: 4
              items:
                type: string
                maxLength: 30
            duration:
              type: string
              enum: [ONE_DAY, THREE_DAYS, SEVEN_DAYS, FOURTEEN_DAYS]
              default: SEVEN_DAYS
        document:
          type: object
          nullable: true
          description: |
            Text posts only (create the post without `upload_id`). Attaches a
            document that LinkedIn shows as a swipeable carousel. PDF, PPT,
            PPTX, DOC or DOCX, up to 100 MB and 300 pages. Fetched from `url`
            at publish time. Can't be combined with `poll`.
          required: [url]
          properties:
            url:
              type: string
              format: uri
              description: Public https URL ending in .pdf, .ppt, .pptx, .doc or .docx.
            title:
              type: string
              maxLength: 200
              description: Name shown on the document. Defaults to the file name.

    TelegramOptions:
      type: object
      properties:
        has_spoiler:
          type: boolean
          description: "Blur the photo or video until people tap it."
        silent:
          type: boolean
          description: "Send without a notification sound."
        poll_close_minutes:
          type: integer
          minimum: 1
          maximum: 43800
          description: "Text posts with a poll, close the poll after this many minutes (Telegram allows about 30 days). Omitted, the poll stays open."
        text_only:
          type: boolean
          description: |
            Send a text-only message (no media). The upload's bytes are
            skipped. Ignored for image uploads.
        poll:
          type: object
          nullable: true
          description: |
            Text posts only (create the post without `upload_id`). Sent
            as an anonymous poll. When the caption is the same as the
            question, only the poll is sent; otherwise the caption goes out
            first and the poll right after it. It stays open until `poll_close_minutes` runs out or it's
            closed in Telegram. If the poll fails, the caption is still
            published and the error is on the post.
          required: [question, options]
          properties:
            question: { type: string, maxLength: 300 }
            options:
              type: array
              minItems: 2
              maxItems: 10
              items: { type: string, maxLength: 100 }
            multiple:
              type: boolean
              default: false
              description: Let people pick more than one option.

    MastodonOptions:
      type: object
      properties:
        alt_text:
          type: string
          maxLength: 1500
          description: "Media description for a single image or video."
        alt_texts:
          type: object
          additionalProperties: { type: string }
          description: "Carousels, alt text per image keyed by the image's upload id."
        spoiler_text:
          type: string
          maxLength: 100
          description: "Content warning; the post text stays hidden behind it and media is blurred. Counts toward the 500-character limit."
        sensitive:
          type: boolean
          description: "Blur the media without a text warning."
        quote_policy:
          type: string
          enum: [public, followers, nobody]
          description: "Who can quote the post (Mastodon 4.5 and newer; older servers ignore it)."
        visibility:
          type: string
          enum: [public, unlisted, private]
          default: public
          description: |
            `public` appears on public timelines, `unlisted` is federated
            but hidden from public timelines, `private` is followers-only.
        language:
          type: string
          description: BCP-47 language code (e.g. `en`, `fi`).
        text_only:
          type: boolean
          description: Publish a text-only post (no media).
        poll:
          type: object
          nullable: true
          description: |
            Text posts only (create the post without `upload_id`). The
            caption is the question.
          required: [options]
          properties:
            options:
              type: array
              minItems: 2
              maxItems: 4
              items: { type: string, maxLength: 50 }
            duration_minutes:
              type: integer
              minimum: 5
              maximum: 10080
              default: 1440
            multiple:
              type: boolean
              default: false
              description: Let people pick more than one option.

    DiscordChannel:
      type: object
      description: A Discord channel connected to the workspace. Never includes the webhook URL.
      required: [id, label, channel_id, is_default, is_forum, status, source, created_at]
      properties:
        id:
          type: string
          format: uuid
          description: Pass in `platform_options.discord.channel_ids`.
        label: { type: string, description: Display name shown in ShortSync. }
        guild_id: { type: string, nullable: true, description: Discord server id. }
        guild_name: { type: string, nullable: true }
        channel_id: { type: string, description: Discord's channel id. }
        is_default:
          type: boolean
          description: Posts without `channel_ids` go to every default channel.
        is_forum:
          type: boolean
          description: |
            Forum channel; each post needs a `thread_name` (falls back to
            the caption's first line). Learned on the first publish.
        status:
          type: string
          enum: [active, needs_reconnect]
          description: "`needs_reconnect` means Discord no longer accepts the webhook."
        source:
          type: string
          enum: [paste, oauth]
          description: Connected by pasting a webhook URL or through Discord sign-in.
        created_at: { type: string, format: date-time }

    DiscordOptions:
      type: object
      description: |
        A workspace can connect several Discord channels (one webhook
        each). A post goes to the channels in `channel_ids`, or to every
        channel with `is_default: true` when it's omitted. Caption max
        2000 characters, up to 10 attachments and 10 MB per post. No custom
        thumbnail. `first_comment` (max 2000 characters) is posted as a
        separate message right after the post in text channels (webhooks
        can't reply there) and as the first reply inside the new post in
        forum channels. It never sends its own notification, and a failed
        comment never fails the post.
        Saved per-user defaults for `silent`, `mention` and `username`
        apply when you leave them out.
      properties:
        channel_ids:
          type: array
          items:
            type: string
            format: uuid
          description: |
            Channels to post to, by `id` from
            `GET /api/v1/discord/channels`. Omit to use the workspace's
            default channels. Ids that are no longer connected are skipped;
            if none are left the publish fails with
            `DISCORD_CHANNELS_NOT_FOUND`.
        silent:
          type: boolean
          default: false
          description: Send without push or desktop notifications.
        mention:
          type: string
          enum: [none, here, everyone]
          default: none
          description: Ping to add to the message (`@here` or `@everyone`).
        thread_name:
          type: string
          maxLength: 100
          description: |
            Forum post title. Forum channels require one; when omitted,
            the first line of the caption is used. Ignored by regular
            text channels.
        username:
          type: string
          maxLength: 80
          description: |
            Overrides the webhook's display name for this post. Discord
            rejects names containing "discord", so they're refused with
            `INVALID_PLATFORM_OPTIONS`.
        text_only:
          type: boolean
          description: |
            Send only the caption as a plain message (no media). Applies to
            video uploads; ignored for image and carousel uploads.
        poll:
          type: object
          nullable: true
          description: |
            Text posts only (create the post without `upload_id`). Attached
            to the message in every selected channel.
          required: [question, options]
          properties:
            question: { type: string, maxLength: 300 }
            options:
              type: array
              minItems: 2
              maxItems: 10
              items: { type: string, maxLength: 55 }
            duration_minutes:
              type: integer
              minimum: 60
              maximum: 46080
              default: 1440
              description: Whole hours only (multiples of 60), up to 32 days.
            multiple:
              type: boolean
              default: false
              description: Let people pick more than one option.

    TumblrOptions:
      type: object
      description: |
        Tumblr is in beta. One Tumblr login can own several blogs; a post
        goes to the blog in `blog_name`, or to the account's primary blog
        when it's omitted. The post text is the post's `description` (up to
        5,000 characters, split into paragraphs); when no description is
        set, the caption is used instead. A per-target `caption` on the
        Tumblr target wins over both. Video posts take one video (up to
        500 MB and 10 minutes); photo posts take up to 10 images (no video
        mix); text posts need post text or a `title`. No custom thumbnail
        and no first comment. Tumblr limits each account
        to 250 posts and 20 videos (60 minutes of video) per day.
      properties:
        alt_text:
          type: string
          maxLength: 1000
          description: "Alt text for a single image."
        alt_texts:
          type: object
          additionalProperties: { type: string, maxLength: 1000 }
          description: "Photo posts with several images, alt text per image keyed by the image's upload id."
        blog_name:
          type: string
          description: |
            Short name of the blog to post to (e.g. `myblog` for
            myblog.tumblr.com), one of the connection's blogs. Omit to use
            the primary blog. A blog that's no longer on the connected
            account fails the publish with `TUMBLR_BLOG_NOT_FOUND`.
        tags:
          type: array
          maxItems: 30
          items:
            type: string
          description: |
            Tags without the leading "#". Commas aren't allowed inside a
            tag. Duplicates are dropped.
        title:
          type: string
          maxLength: 4096
          description: |
            Optional heading shown above the post text. Overrides the
            post's shared `title`.
        text_only:
          type: boolean
          default: false
          description: |
            Post only the title and post text as a text post (no media).
            Applies to video uploads; ignored for image and carousel
            uploads.

    RedditOptions:
      type: object
      description: |
        Reddit accounts connect through OAuth via bundle.social, so Reddit's
        consent screen shows "bundlesocial". A post goes to one subreddit
        (or your own profile) and can be a video, an image or a text (self)
        post. Carousels aren't supported. The post title is `title` here,
        falling back to the post's shared `title`; one is required (max 300
        characters). The post body is the post's `description` (up to
        30,000 characters). The target's `first_comment` (or the top-level
        one) is posted with the post, up to 10,000 characters; it always
        goes out right away, whatever `first_comment_delay_minutes` says,
        and follow-up comments aren't posted on Reddit. No custom
        thumbnail, no analytics, and posts can't be deleted from ShortSync
        (`PLATFORM_DELETE_UNSUPPORTED`). Each workspace can publish up to
        10 Reddit posts per day. Some subreddits hold posts from new or
        low-karma accounts for moderator approval. Saved workspace defaults
        for `subreddit` and `nsfw` apply when you leave them out.
      properties:
        first_comment_text:
          type: string
          maxLength: 10000
          deprecated: true
          description: "Deprecated: use the target's `first_comment`. Still used when no `first_comment` is set."
        subreddit:
          type: string
          description: |
            Required. Subreddit to post to, as a bare name (`AskReddit`) or
            with the prefix (`r/AskReddit`). To post to your own profile,
            use `u_username` or `u/username`. A bare name is always a
            subreddit: `jane` posts to r/jane, not to u/jane.
        title:
          type: string
          maxLength: 300
          description: |
            Post title. Overrides the post's shared `title`. A post with no
            title fails with `MISSING_TITLE`.
        nsfw:
          type: boolean
          default: false
          description: Marks the post as Not Safe For Work.
        flair_id:
          type: string
          description: |
            Post flair id from the subreddit's flair list. Some subreddits
            require a flair and reject posts without one.

    PixelfedOptions:
      type: object
      description: |
        Pixelfed is in beta. It's a federated, Mastodon-compatible photo
        network; each connection is one account on one server (instance).
        Every post needs media (video, image or carousel); there are no
        text-only posts. Carousels can mix photos and videos, up to 20
        items, but the connected server's own album cap (often 4) is
        checked at publish. Caption max 500 characters (some servers allow
        more). Photos and videos share one file-size cap set by the server
        (default about 15 MB); oversized videos are compressed, oversized
        images fail. Video is off by default on Pixelfed servers, so
        posting video to a photo-only server fails with a clear error.
        `first_comment` (max 500 characters) is posted as a reply under
        the post. No custom thumbnail. Saved workspace defaults for
        `visibility` and `sensitive` apply when you leave them out.
      properties:
        visibility:
          type: string
          enum: [public, unlisted, private]
          default: public
          description: |
            `public` shows the post on public timelines, `unlisted` hides
            it from them, `private` shows it to followers only.
        sensitive:
          type: boolean
          default: false
          description: Blurs the media behind a warning.
        spoiler_text:
          type: string
          maxLength: 140
          description: |
            Content-warning text shown over the post. Only used when
            `sensitive` is true.

    GoogleBusinessLocation:
      type: object
      description: A Business Profile location managed by the workspace's Google connection.
      required: [id, account_id, title, can_post, is_default]
      properties:
        id:
          type: string
          description: Pass in `platform_options.google_business.location_ids`.
        account_id:
          type: string
          description: Google account (or location group) the location belongs to.
        account_name: { type: string, nullable: true }
        title: { type: string, description: Business name. }
        address:
          type: string
          nullable: true
          description: One-line address; null for service-area businesses without one.
        maps_url: { type: string, nullable: true, description: Google Maps link. }
        can_post:
          type: boolean
          description: |
            False when Google doesn't let this login post to the location
            yet (unverified, suspended or pending). Posts to it fail.
        is_default:
          type: boolean
          description: Posts without `location_ids` go to every default location.

    GoogleBusinessOptions:
      type: object
      description: |
        One Google login can manage
        several business locations; a post goes to the locations in
        `location_ids`, or to every location with `is_default: true` when
        it's omitted (the first postable location if none is marked), and
        is published as an update on each. Caption (required) max 1500
        characters. One photo (JPG or PNG, 10 KB to 5 MB) or text only: no
        video, no carousel, no custom thumbnail, no first comment.
        Saved per-user defaults for `cta_type` and `cta_url` apply when
        you leave them out.
      properties:
        post_type:
          type: string
          enum: [STANDARD, EVENT, OFFER]
          description: "EVENT and OFFER need `event`; OFFER also needs at least one `offer` field and can't have a button (cta_type is ignored)."
        event:
          type: object
          properties:
            title: { type: string, maxLength: 58 }
            start_date: { type: string, format: date }
            end_date: { type: string, format: date, description: Defaults to start_date. }
        offer:
          type: object
          properties:
            coupon_code: { type: string, maxLength: 58 }
            redeem_url: { type: string, format: uri }
            terms: { type: string, maxLength: 1500 }
        location_ids:
          type: array
          items:
            type: string
          description: |
            Locations to post to, by `id` from
            `GET /api/v1/google-business/locations`. Omit to use the
            default locations. An id that's no longer on the connected
            account fails the publish with
            `GOOGLE_BUSINESS_LOCATION_NOT_FOUND`.
        cta_type:
          type: string
          nullable: true
          enum: [BOOK, ORDER, SHOP, LEARN_MORE, SIGN_UP, CALL]
          description: |
            Optional button on the post. `CALL` dials the profile's phone
            number and takes no URL; every other type needs `cta_url`.
            `null` removes the button.
        cta_url:
          type: string
          format: uri
          nullable: true
          description: |
            The button's link (http or https). Required with every
            `cta_type` except `CALL`.
        text_only:
          type: boolean
          default: false
          description: |
            Post only the caption (no media). Google Business Profile
            can't post video, so a video upload needs this. Ignored for
            image uploads.

    SnapchatOptions:
      type: object
      properties:
        formats:
          type: array
          minItems: 1
          items:
            type: string
            enum: [spotlight, story]
          description: |
            Which Snapchat surfaces to publish to. `spotlight` ships to
            the Spotlight discovery feed; `story` is a 24-hour broadcast
            to your followers. Pass both to publish to both at once.
            Defaults to `["spotlight"]`. Hashtags aren't a separate field
            on Snapchat — include them inline in the caption. Snapchat
            rejects Spotlight captions over 160 characters with
            `SNAPCHAT_DESCRIPTION_TOO_LONG`. Story doesn't use the
            caption at all.
        skip_save_to_profile:
          type: boolean
          default: false
          description: |
            Spotlight-only. When `true`, ask Snapchat not to save the
            Spotlight to your Public Profile grid; the video still ships
            to the Spotlight discovery feed. Ignored when `formats`
            doesn't include `spotlight`.

    PinterestOptions:
      type: object
      required: [board_id]
      properties:
        is_ai_generated:
          type: boolean
          description: "Adds Pinterest's AI disclosure (`ai_disclosures: AI_MODIFIED`). On image and video Pins, if Pinterest refuses it, the Pin goes out without it."
        board_section_id:
          type: string
          description: "Section of the board to put the Pin in. Get ids from `GET /platforms/pinterest/boards/{board_id}/sections`."
        board_section_name:
          type: string
          description: "Optional display name of the section, shown in the dashboard."
        board_id:
          type: string
          description: |
            Destination Pinterest board ID. Required unless the workspace
            has set a default board (`video_preferences.pinterest_board_id`),
            in which case the default is used when omitted. Fetch board
            IDs via `GET /api/v1/platforms/pinterest/boards`.
        link:
          type: string
          format: uri
          description: |
            Outbound destination URL for the pin. When set, tapping the
            pin on Pinterest opens this URL. Optional.
        alt_text:
          type: string
          maxLength: 500
          description: |
            Accessibility alt text for the pin image or video cover.
            Pinterest caps this at 500 characters; longer values are
            truncated server-side.
        title:
          type: string
          maxLength: 100
          description: |
            Override for the pin title. When omitted, falls back to the
            workspace title, then to a truncated slice of the caption.
            Pinterest caps titles at 100 characters. The pin's description
            comes from the top-level `caption` on the post (or the
            `platform_captions.pinterest` override).

    # ---------------------------------------------------------------------
    # Analytics
    # ---------------------------------------------------------------------

    InstagramCompareAccount:
      description: One account in an Instagram comparison. `ok` is false when Instagram can't show the account.
      oneOf:
        - type: object
          required: [ok, account]
          properties:
            ok: { type: boolean, enum: [true] }
            account:
              type: object
              properties:
                username: { type: string }
                name: { type: string, nullable: true }
                profile_picture_url: { type: string, nullable: true }
                followers_count: { type: integer, nullable: true }
                media_count: { type: integer, nullable: true }
                recent:
                  type: object
                  description: Over the account's most recent posts (up to 12).
                  properties:
                    posts: { type: integer }
                    avg_likes: { type: integer, nullable: true }
                    avg_comments: { type: integer, nullable: true }
                    avg_reel_views: { type: integer, nullable: true, description: Reels only. }
                    engagement_rate: { type: number, nullable: true, description: "(avg likes + avg comments) / followers, in percent." }
                    posts_per_week: { type: number, nullable: true }
        - type: object
          required: [ok, username, error]
          properties:
            ok: { type: boolean, enum: [false] }
            username: { type: string }
            error: { type: string }

    AnalyticsSummary:
      type: object
      required: [workspace_id, window, last_synced_at, per_platform]
      properties:
        workspace_id: { type: string, format: uuid }
        window:
          type: object
          required: [from, to]
          properties:
            from:
              type: [string, "null"]
              format: date-time
              description: Echo of the request's `from` param (`null` when omitted).
            to:
              type: [string, "null"]
              format: date-time
              description: Echo of the request's `to` param (`null` when omitted).
        last_synced_at:
          type: [string, "null"]
          format: date-time
          description: |
            Newest `fetched_at` across every row that fed this summary.
            `null` when the workspace has no synced data yet.
        per_platform:
          type: array
          items: { $ref: "#/components/schemas/AnalyticsPlatformSummary" }

    AnalyticsPlatformSummary:
      type: object
      required:
        [
          platform,
          likes,
          comments,
          shares,
          saves,
          engagement_rate,
          posts_tracked,
        ]
      properties:
        platform: { $ref: "#/components/schemas/Platform" }
        views: { type: [integer, "null"] }
        likes: { type: integer }
        comments: { type: integer }
        shares: { type: integer }
        saves: { type: integer }
        engagement_rate:
          type: number
          format: float
          description: |
            Percentage engagement rate derived by ShortSync as
            (likes + comments) / views * 100. This is not a metric returned
            directly by any platform API; it is generated independently by
            ShortSync from the underlying public stats.
        watch_time_seconds: { type: [integer, "null"] }
        posts_tracked: { type: integer }

    YouTubeAudienceSlice:
      type: object
      properties:
        key: { type: string, description: "YouTube's raw value, e.g. age18-24, FI, MOBILE, SHORTS." }
        label: { type: string }
        share: { type: number, description: Percent of viewers or views. }
        views: { type: integer, description: Views, where YouTube reports them. }

    PostAnalytics:
      type: object
      required:
        [
          post_id,
          platform,
          platform_post_id,
          connection_id,
          published_at,
          permalink,
          metrics,
          fetch_status,
          fetched_at,
        ]
      properties:
        post_id:
          type: string
          format: uuid
          description: UUID of the post row. Matches the id returned by `POST /posts`.
        platform: { $ref: "#/components/schemas/Platform" }
        platform_post_id:
          type: [string, "null"]
          description: The upstream platform's id for the post (e.g. TikTok's video_id, YouTube's videoId).
        connection_id:
          type: [string, "null"]
        published_at:
          type: [string, "null"]
          format: date-time
        permalink:
          type: [string, "null"]
          description: Best-effort URL to the post on the source platform. `null` when we can't construct one.
        title:
          type: [string, "null"]
        caption:
          type: [string, "null"]
        thumbnail_url:
          type: [string, "null"]
        metrics: { $ref: "#/components/schemas/PostAnalyticsMetrics" }
        fetch_status:
          type: string
          description: |
            `success` when the row has any live data; `failed` when the
            last sync couldn't get anything for it (post deleted on the
            platform, connection revoked, etc.).
        fetched_at:
          type: [string, "null"]
          format: date-time

    PostAnalyticsMetrics:
      type: object
      description: |
        Every numeric field uses `null` (not `0`) to mean "unknown /
        scope missing / not applicable" and `0` to mean "genuinely zero".
        Don't coalesce `null` to `0` in aggregations you display.
      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"] }
        watch_time_seconds: { type: [integer, "null"] }
        avg_watch_time_seconds: { type: [integer, "null"] }
        engagement_rate:
          type: [number, "null"]
          format: float
          description: |
            Percentage engagement rate derived by ShortSync as
            (likes + comments) / views * 100. This is not a metric returned
            directly by any platform API; it is generated independently by
            ShortSync from the underlying public stats.
        reposts:
          type: [integer, "null"]
          description: |
            Reposts, for platforms that report them separately (Instagram,
            Threads, Bluesky). On Threads and Bluesky these are also counted
            in `shares`. Instagram only reports them through Facebook Login.
        reels_skip_rate:
          type: [number, "null"]
          format: float
          description: |
            Instagram Reels only. Percentage of views that skipped the Reel
            in the first 3 seconds, as estimated by Instagram.
        link_clicks:
          type: [integer, "null"]
          description: |
            Instagram Stories only. Taps on links in the Story, such as a
            link sticker. Read while the Story is live (24 hours) and needs
            the workspace's Facebook Login for the account.
        engaged_views:
          type: [integer, "null"]
          description: YouTube only. Views counted as engaged.
        engaged_engagement_rate:
          type: [number, "null"]
          format: float
          description: YouTube only. Likes + comments + shares per engaged view, in percent.
        thumbnail_impressions:
          type: [integer, "null"]
          description: |
            YouTube only. Times YouTube showed the thumbnail, from the
            YouTube Reporting API, since `thumbnail_impressions_since`.
            Arrives about 2 days late.
        thumbnail_ctr:
          type: [number, "null"]
          format: float
          description: YouTube only. Impressions click-through rate, in percent.
        thumbnail_impressions_since:
          type: [string, "null"]
          format: date
          description: YouTube only. First day the impressions total covers.
        traffic_sources:
          type: [object, "null"]
          additionalProperties: { type: integer }
          description: |
            YouTube only. Views per YouTube traffic source, keyed by
            YouTube's raw names (e.g. SHORTS, YT_SEARCH, RELATED_VIDEO).

    AnalyticsSyncCreate:
      type: object
      description: |
        Optional body for `POST /analytics/sync`. Send `{}` to sync every
        supported connected platform.
      properties:
        platform:
          $ref: "#/components/schemas/Platform"

    AnalyticsSyncJobAccepted:
      type: object
      required: [job_id, status, status_url, estimated_seconds, requested_at]
      properties:
        job_id: { type: string, format: uuid }
        status:
          type: string
          enum: [queued]
          description: Always `queued` on the 202 response; poll `status_url` for later transitions.
        status_url:
          type: string
          format: uri
          description: Absolute URL of `GET /analytics/sync/{job_id}` for polling.
        estimated_seconds:
          type: integer
          description: Rough upper bound on how long the sync may take. Real durations range from ~15s to ~5 min.
        requested_at:
          type: string
          format: date-time

    AnalyticsSyncJob:
      type: object
      required:
        [
          job_id,
          status,
          platform,
          requested_at,
          started_at,
          completed_at,
          progress,
          per_platform,
          error,
        ]
      properties:
        job_id: { type: string, format: uuid }
        status:
          type: string
          enum: [queued, running, completed, failed, canceled]
        platform:
          type: [string, "null"]
          description: The narrower filter from the POST body, or `null` when the sync ran across every platform.
        requested_at: { type: string, format: date-time }
        started_at: { type: [string, "null"], format: date-time }
        completed_at: { type: [string, "null"], format: date-time }
        progress:
          type: object
          required: [posts_synced, posts_total]
          properties:
            posts_synced:
              type: integer
              description: Running total across every platform in the sync.
            posts_total:
              type: integer
              description: Best-known denominator. May grow mid-sync if video discovery finds new posts.
        per_platform:
          type: array
          items: { $ref: "#/components/schemas/AnalyticsSyncJobPlatformResult" }
        error:
          type: [string, "null"]
          description: Human-readable summary of any per-platform errors. Non-null when at least one platform reported an error.

    AnalyticsSyncJobPlatformResult:
      type: object
      required: [platform, posts_synced, total_posts, has_more, next_offset]
      properties:
        platform: { $ref: "#/components/schemas/Platform" }
        posts_synced: { type: integer }
        total_posts: { type: integer }
        has_more:
          type: boolean
          description: True when the platform still has posts beyond this batch. Trigger another sync after this one completes to page further.
        next_offset:
          type: integer
        error:
          type: [string, "null"]
