{
  "openapi": "3.0.3",
  "info": {
    "title": "PostWire API",
    "version": "1.0.0",
    "description": "Publish one idea natively to every social network GET /api/platforms lists as available. Get told when each network publishes or fails: webhooks (/api/webhooks, https://postwire.io/docs/webhooks/). A post is counted PER NETWORK: one idea sent to three networks spends three of the monthly allowance, not one. Publishing endpoints return `posted` (how many networks actually went out) alongside a per-network `results` array; one network failing never fails the others or the request. On the Free plan each post goes out to 2 networks: every other network in the request comes back with ok false, held true and code networks_per_post (its version is written and not sent), named in held_networks with an upgrade link — never silently dropped. Free also keeps 3 scheduled posts at a time: one more is saved as held (202, code queue_limit) and goes out once the plan is upgraded. Approvals & guardrails (https://postwire.io/docs/approvals/): a brand can make posts wait for a person (by source, network, links, prices or words), API keys and AI apps can have a monthly cap, allowed networks and brands, and every account has an activity log with CSV export. Teams (https://postwire.io/docs/teams/): invite people by email with a role (owner, admin, editor, contributor, approver, viewer) and optionally only some brands; a key acts with the role of the member who created it, and every route checks it (403 role_forbidden, brand_restricted, seat_read_only).",
    "contact": {
      "url": "https://postwire.io/support.html"
    }
  },
  "servers": [
    {
      "url": "https://postwire.io"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/platforms": {
      "get": {
        "summary": "List supported platforms",
        "security": [],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/plans": {
      "get": {
        "summary": "List plans and limits",
        "security": [],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "description": "Each plan: { name, price, brands, limit (posts a month, -1 = unlimited), genDay (AI drafts a day), networksPerPost (-1 = every network in each post), maxQueued (scheduled posts at a time, -1 = unlimited) }."
      }
    },
    "/api/signup": {
      "post": {
        "summary": "Create an account (the API key is emailed as a confirmation link, not returned here)",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account created; pending_verification=true, emailed=true|false"
          }
        },
        "description": "Signup never returns credentials. We create the account and email a one-time confirmation link; opening it proves you control the mailbox and issues your API key. This prevents anyone from registering an address they do not own and receiving a working key."
      }
    },
    "/api/me": {
      "get": {
        "summary": "Account info, usage and connections",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing/invalid API key"
          }
        },
        "description": "limits carries posts_this_month, brands, ai_drafts_today, networks_per_post { limit } and scheduled_queue { used, limit, held, left } (null = no limit). A free account created before the 2-Oct-2026 limits also gets grandfathered { until, note } (it keeps the earlier limits until 2026-11-01). Free accounts get insights_teaser: how many What works patterns are ready and how strong each is, without the answer. With teams: `workspace` (id, name, plan, seats, members) and `member` (who is calling: email, role, effective_role, read_only, brand_ids, and `can`: which actions this role may take). The no-card Pro trial (when it is on): `trial` { kind: \"reverse\", plan, plan_name, until, ends_at, started_at, days_left, active, no_card } while it runs (a card trial is `trial` with kind \"card\"), `trial_ended` once it is over, `trial_line` (one sentence, no link), and for a free account that can still have it `reverse_trial_offer` { kind, plan, name, days, no_card, starts: \"now\" | \"first_post\", unlocks, extras, note } instead of `trial_offer`. A free account that looks like a business (3+ networks, 2+ brands, or a team seat wall) gets `bizcard` { show, dismissed, reasons, networks, brands, title, lead, benefits: [{ key: \"approvals\" | \"team\", title, text }], action: { kind: \"trial\", label, days, note } | { kind: \"checkout\", plan, label, url, secondary?: { plan, label, url }, note } }: approvals and team with the plans' real limits, and the no-card trial (POST /api/trial/start with from \"bizcard\") or Starter's signed checkout link. `show` is false once it was dismissed."
      }
    },
    "/api/connect": {
      "post": {
        "summary": "Connect a credential-based platform (telegram, bluesky, mastodon, discord, wordpress, devto, hashnode, slack, nostr)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "platform",
                  "credentials"
                ],
                "properties": {
                  "platform": {
                    "type": "string",
                    "enum": [
                      "telegram",
                      "bluesky",
                      "mastodon",
                      "discord",
                      "wordpress",
                      "devto",
                      "hashnode",
                      "slack",
                      "nostr"
                    ]
                  },
                  "credentials": {
                    "type": "object",
                    "description": "telegram { bot_token, chat_id } · bluesky { handle, app_password } · mastodon { instance_url, access_token } · discord { webhook_url } · wordpress { site_url, username, app_password, default_status? (publish|draft) } · devto { api_key, default_status? } · hashnode { token, publication? (the blog's address or id; default: the first blog), default_status? } · slack { webhook_url (https://hooks.slack.com/services/…) } · nostr { nsec, relays? (wss:// list or comma-separated; default: public relays) }. Checked with the network before they are saved; a refusal comes back as code invalid_credentials with what to fix."
                  },
                  "dry_run": {
                    "type": "boolean",
                    "description": "true: only test the credentials with the network (the dashboard's Test connection); nothing is saved. Answers { ok, tested: true, connected: false } or the same invalid_credentials error a connect would."
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Connected"
          }
        }
      }
    },
    "/api/oauth/{platform}/url": {
      "post": {
        "summary": "Get an OAuth authorize URL for an OAuth platform (tiktok, youtube, linkedin, facebook, instagram)",
        "parameters": [
          {
            "name": "platform",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ url }"
          }
        }
      }
    },
    "/api/post": {
      "post": {
        "summary": "Post (or cross-post) to one or more platforms",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PostRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One result per network. Check `posted` and each `results[].ok`. Each result carries account { platform, handle, display_name, brand_id, brand, label } and published_to names every account reached. With the same network in more than one brand and no brand_id: 409 ambiguous_brand, nothing published. On a plan with a networks-per-post limit (Free: 2) the first networks that pass their checks are published and the others come back held (code networks_per_post), listed in held_networks with held_message and an upgrade link: a partial publish is a 200 that says what it held back.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishResponse"
                }
              }
            }
          },
          "202": {
            "description": "202 = held for approval (the brand's approval rules or a limit on this key): nothing was published. { ok: true, posted: 0, status: \"pending_approval\", id (the post's PostWire id, for GET /api/post/status), approval_id, approval: { reasons, notified: [{ to (masked), role, via, sent }], review_url (the dashboard; sign-in needed), who_can_approve, publishes }, results: [{ platform, ok: false, status: \"pending_approval\", code: \"pending_approval\", account }], message_for_user }. Only a person approves it: the emailed link or a signed-in dashboard session, never an API key or an AI connector."
          },
          "400": {
            "description": "Bad request. bad_x_thread: an X thread (per_platform.x.thread) or reply (options.x.reply) post is empty, not text or over 280 characters as X counts them, or the thread has more than 25 posts — nothing was published to any network. bad_thread: a Bluesky or Mastodon thread (per_platform.<network>.thread) has a post that is empty, not text or over the network's limit, more than 10 posts in all (thread: true included), or a first_comment over the limit — nothing was published to any network.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "403": {
            "description": "Email not verified, or the key is read-only. 403 also: key_network_not_allowed, key_brand_not_allowed, key_monthly_cap_reached (limits set on this API key or AI app; nothing was published), plan_feature. 503 governance_unavailable: the approval rules could not be checked, nothing was published."
          }
        }
      }
    },
    "/api/post/status": {
      "get": {
        "summary": "Check the status of a created post",
        "parameters": [
          {
            "name": "platform",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The network. Can be omitted when id is PostWire's id for a waiting or scheduled post."
          },
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ platform, id, status }"
          }
        },
        "description": "With platform and the network's post id: that post's status and link. With the id PostWire returned for a post that waits for approval or is scheduled (a uuid; platform can be omitted): status pending_approval (with the approval: who was asked, review_url), rejected (with the reason and who decided), scheduled (approved_by when it was approved), or the post's status and each network's result once it went out."
      }
    },
    "/api/connect-link": {
      "post": {
        "summary": "Generate a hosted connect link for an end-user (multi-tenant)",
        "responses": {
          "200": {
            "description": "{ url, token, expires_in }"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "platform": {
                    "type": "string",
                    "enum": [
                      "tiktok",
                      "instagram",
                      "youtube",
                      "linkedin",
                      "facebook",
                      "bluesky",
                      "mastodon",
                      "telegram",
                      "discord",
                      "wordpress",
                      "devto",
                      "hashnode",
                      "slack",
                      "nostr",
                      "x"
                    ],
                    "description": "Offer only this network; without it the page offers every network."
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "The brand the connection is saved into."
                  },
                  "ig_username": {
                    "type": "string",
                    "description": "Instagram: the @handle to connect, when the person's Pages have several."
                  }
                }
              }
            }
          }
        },
        "description": "A hosted page (valid 1 hour) where your client connects their own account, without a PostWire login: send them the url. The connection lands in brand_id."
      }
    },
    "/api/billing/checkout": {
      "post": {
        "summary": "Start a Stripe checkout for a paid plan",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "plan"
                ],
                "properties": {
                  "plan": {
                    "type": "string",
                    "enum": [
                      "starter",
                      "pro",
                      "agency",
                      "scale"
                    ]
                  },
                  "interval": {
                    "type": "string",
                    "enum": [
                      "month",
                      "year"
                    ],
                    "description": "Billing period: month (default) or year (20% off, billed once a year). A running subscription is switched, prorated."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ url }"
          }
        }
      }
    },
    "/api/keys": {
      "get": {
        "summary": "List your API keys (prefixes only — the secret is never returned)",
        "responses": {
          "200": {
            "description": "keys[]"
          }
        }
      },
      "post": {
        "summary": "Create a new API key, optionally with an expiry",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "expires_in_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 3650
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "api_key shown once"
          }
        }
      }
    },
    "/api/keys/{id}": {
      "delete": {
        "summary": "Revoke an API key immediately",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "revoked"
          },
          "404": {
            "description": "not found or already revoked"
          }
        }
      }
    },
    "/api/webhooks": {
      "get": {
        "summary": "List your webhook endpoints (the signing secret is never returned)",
        "description": "PostWire calls your endpoints when a post goes out or fails on a network, when a connection must be signed in again, and (only for an endpoint that asks for them) when a post is held for approval and when someone decides. Every plan, with an endpoint limit per plan: Free 2, Starter 5, Pro 10, Agency 25, Scale 50 (max in the response is yours). Events and signature: https://postwire.io/docs/webhooks/ (payload schema: components.schemas.WebhookEvent).",
        "responses": {
          "200": {
            "description": "{ webhooks: [Webhook], events: [string] (every event an endpoint can ask for), default_events: [string] (what an endpoint created without events gets), max: integer (your plan's endpoint limit: Free 2, Starter 5, Pro 10, Agency 25, Scale 50) }"
          },
          "503": {
            "description": "code webhooks_unavailable: webhooks are not switched on on this server yet"
          }
        }
      },
      "post": {
        "summary": "Add a webhook endpoint; the response carries its signing secret, once",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "A public https URL. Redirects are not followed."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "post.published",
                        "post.failed",
                        "connection.reauth_required",
                        "approval.requested",
                        "approval.decided"
                      ]
                    },
                    "description": "Default: post.published, post.failed and connection.reauth_required. approval.requested and approval.decided are sent only to an endpoint that lists them."
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ webhook: Webhook, secret: \"whsec_…\" } — keep the secret: it is not shown again"
          },
          "400": {
            "description": "code bad_url (not https, not public, malformed), bad_request (unknown event) or too_many (your plan's endpoints are all in use; the body carries limit, your plan's number)"
          },
          "503": {
            "description": "code webhooks_unavailable"
          }
        }
      }
    },
    "/api/webhooks/{id}": {
      "delete": {
        "summary": "Delete a webhook endpoint (its pending deliveries are dropped)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "deleted"
          },
          "404": {
            "description": "code not_found"
          }
        }
      }
    },
    "/api/webhooks/{id}/test": {
      "post": {
        "summary": "Send a signed webhook.test event to this endpoint now and report what it answered",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ delivered: boolean, status: HTTP status or null, error?, delivery_id, event }"
          },
          "404": {
            "description": "code not_found"
          }
        }
      }
    },
    "/api/webhooks/{id}/deliveries": {
      "get": {
        "summary": "The delivery log of an endpoint: the last 50 deliveries with status, attempts, the endpoint's answer and the payload",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ webhook, deliveries: [{ id, event, status: pending|delivered|failed, attempts, last_status, last_error, next_attempt_at, created_at, delivered_at, payload }] }"
          }
        }
      }
    },
    "/api/bio": {
      "get": {
        "summary": "Read a brand's link-in-bio page, its views and each link's clicks",
        "description": "The brand's page at postwire.io/@<slug> (free on every plan): its settings, the public URL, views (people only: link previews and bots are left out) and clicks per link, all time and the last 30 days. With ?check=<slug>, says whether that address is free and allowed instead. Before the server's bio-page table exists the answer is available: false, code bio_unavailable.",
        "parameters": [
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The brand; default: the account's first brand"
          },
          {
            "name": "check",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "An address to check: { slug, ok, code?, error? }"
          }
        ],
        "responses": {
          "200": {
            "description": "{ available, brand_id, page: { slug, title, bio, links: [{ label, url }], show_socials, hide_badge, updated_at } | null, url, stats: { views, views_30d, links: [{ label, url, clicks, clicks_30d }] } | null, socials: [{ platform, handle }], avatar_url, can_hide_badge, limits }"
          },
          "404": {
            "description": "code brand_not_found"
          }
        }
      },
      "put": {
        "summary": "Create or update a brand's link-in-bio page",
        "description": "Free on every plan. The address is 3-30 lowercase letters, digits and hyphens, unique, and not a reserved word. Up to 10 links, http or https only; each is published as a tracked postwire.io/r/ link so its clicks are counted. \"Made with PostWire\" can be switched off on paid plans only (on Free the request is saved with it on, and the answer says so in note). Changes show within about a minute.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "slug"
                ],
                "properties": {
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "slug": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 30,
                    "pattern": "^[a-z0-9][a-z0-9-]{1,28}[a-z0-9]$",
                    "description": "postwire.io/@<slug>"
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "The name shown; the brand's name when empty"
                  },
                  "bio": {
                    "type": "string",
                    "maxLength": 280
                  },
                  "links": {
                    "type": "array",
                    "maxItems": 10,
                    "items": {
                      "type": "object",
                      "required": [
                        "label",
                        "url"
                      ],
                      "properties": {
                        "label": {
                          "type": "string",
                          "maxLength": 60
                        },
                        "url": {
                          "type": "string",
                          "format": "uri",
                          "maxLength": 1000
                        }
                      }
                    }
                  },
                  "show_socials": {
                    "type": "boolean",
                    "default": true,
                    "description": "The brand's connected profiles as icons"
                  },
                  "hide_badge": {
                    "type": "boolean",
                    "default": false,
                    "description": "Paid plans only"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok: true, note?, ...the same body as GET }"
          },
          "400": {
            "description": "code slug_required, slug_length, slug_chars, slug_reserved, bad_url, label_required or too_many_links, with field (e.g. links.2.url) and every problem in errors[]"
          },
          "409": {
            "description": "code slug_taken"
          },
          "503": {
            "description": "code bio_unavailable: bio pages are not switched on on this server yet"
          }
        }
      },
      "delete": {
        "summary": "Remove a brand's link-in-bio page",
        "description": "The address becomes free for anyone; the page's views and clicks are deleted with it.",
        "parameters": [
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok: true, removed: <slug> }"
          },
          "404": {
            "description": "code bio_not_found or brand_not_found"
          }
        }
      }
    },
    "/api/status": {
      "get": {
        "summary": "Public service status: components, and delivery success per network over 30 days (no auth)",
        "description": "The data behind https://postwire.io/status/. Counted live from production; totals only.",
        "security": [],
        "responses": {
          "200": {
            "description": "{ overall: operational|degraded|outage, components, networks: [{ platform, last_24h, last_7d, last_30d, days, status }], definitions }"
          }
        }
      }
    },
    "/api/media/upload-url": {
      "post": {
        "summary": "Get a signed URL to upload a photo or video (up to 1 GB). Files over 50 MB: send \"multipart\": true, PUT bytes [start, end) to each returned part's upload_url, then GET /api/media/finalize?path= returns one media_url for the whole file. Media passed by URL is fetched by us: up to 1GB for TikTok and YouTube (streamed), 80MB elsewhere.",
        "description": "Upload your own file instead of hosting it yourself. The bytes go straight from your client to storage — they never pass through this API. 1) POST here. 2) PUT the raw file bytes to upload_url. 3) GET /api/media/finalize?path=<path> to receive media_url. 4) pass media_url as video_url or photo_url to /api/post. Media is deleted the day after the last scheduled post that uses it is published, and 7 days after upload when no scheduled post uses it (30 days at most, never while a scheduled post still waits for it); the answer's retention object says the same in numbers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "content_type"
                ],
                "properties": {
                  "content_type": {
                    "type": "string",
                    "enum": [
                      "image/jpeg",
                      "image/png",
                      "image/webp",
                      "image/gif",
                      "video/mp4",
                      "video/quicktime",
                      "video/webm"
                    ]
                  },
                  "size_bytes": {
                    "type": "integer"
                  },
                  "multipart": {
                    "type": "boolean",
                    "description": "true for files over 50 MB: the answer lists parts, each with its own upload_url and byte range [start, end)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "upload_url + path, retention_days (the 30-day cap) and retention {max_days, after_last_post_days, unused_days, rule}"
          },
          "413": {
            "description": "code use_multipart (send multipart: true) or too_large (over 1 GB)"
          }
        }
      }
    },
    "/api/media/finalize": {
      "get": {
        "summary": "Confirm the upload landed and get the media_url to publish with",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "media_url + bytes"
          },
          "404": {
            "description": "not uploaded yet"
          }
        }
      }
    },
    "/api/generate": {
      "post": {
        "summary": "Write a native post per network, without publishing",
        "description": "Returns one draft per requested network. Feed `drafts` straight back into /api/post as `per_platform` to publish exactly what was written. A draft may carry thread (X, Bluesky, Mastodon: when the idea asks for a thread; Bluesky and Mastodon also when it is too long for one post) and first_comment (LinkedIn, X, Bluesky, Mastodon: the idea's link, out of the body). platforms may be an array or a comma-separated string (\"tiktok, instagram\"); the idea may be sent as prompt, idea, text or topic. With no platforms, the account's connected networks are used. 400 codes: prompt_required, platforms_required, unknown_platform; 502 ai_failed when the writer fails. When the idea asks for a thread (\"write a thread about…\") and x is one of the networks, the X draft also has thread: [\"…\"] (the posts after text), ready for per_platform.x.thread; otherwise X gets one post. Same single AI call either way.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ drafts: { <platform>: { text } } }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "drafts": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "prompt or platforms[] missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "ai_daily_limit (the plan's AI drafts a day) or ai_month_limit (the month's AI drafts and any AI credits used up; with buy_ai_credits links and the plan above)"
          },
          "503": {
            "description": "AI not configured"
          }
        }
      }
    },
    "/api/schedule": {
      "post": {
        "summary": "Queue a post for a later time",
        "description": "Rules are checked NOW, not at send time: a disconnected network or missing media is rejected while you build the flow rather than silently failing overnight. The Free plan keeps 3 scheduled posts waiting at a time: past that the post is not refused but saved as held (202, code queue_limit, with an upgrade link) and scheduled automatically when the plan is upgraded; it is never published on Free and can be canceled. On Free only the first 2 networks of a post are published when it runs; the answer names the others in held_networks. run_at \"next_slot\" puts the post in the brand's next free queue slot (GET/PUT /api/brands/{id}/slots); the Free queue cap applies the same way.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, scheduled: {...}, targets[], message, held_networks?, held_message?, upgrade? }"
          },
          "202": {
            "description": "Saved as held, not scheduled: the plan's queue is full. { ok: true, held: true, code: \"queue_limit\", scheduled: { status: \"held\", ... }, scheduled_queue: { used, limit, held }, message, upgrade, upgrade_url, upgrade_message } Or: 202 = held for approval (the brand's approval rules or a limit on this key): nothing was published. { ok: true, posted: 0, status: \"pending_approval\", id (the post's PostWire id, for GET /api/post/status), approval_id, approval: { reasons, notified: [{ to (masked), role, via, sent }], review_url (the dashboard; sign-in needed), who_can_approve, publishes }, results: [{ platform, ok: false, status: \"pending_approval\", code: \"pending_approval\", account }], message_for_user }. Only a person approves it: the emailed link or a signed-in dashboard session, never an API key or an AI connector. A scheduled post approved before its time goes out at that time; approved after it, right after approval (or at a new time the approver picks)."
          },
          "400": {
            "description": "run_at in the past, network not connected, media required, or the 500-post sanity ceiling",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "code no_free_slot (run_at next_slot found no free slot in 28 days), or ambiguous_brand"
          }
        }
      },
      "get": {
        "summary": "List queued posts",
        "responses": {
          "200": {
            "description": "{ scheduled: [...] }"
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only posts due at or after this time."
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only posts due at or before this time."
          }
        ]
      }
    },
    "/api/brands": {
      "get": {
        "summary": "List brands and the networks connected to each",
        "description": "A brand groups one business's accounts. Use a brand's id as `brand_id` when publishing.",
        "responses": {
          "200": {
            "description": "{ brands: [{ id, name, platforms[], accounts: [{ platform, label, handle, display_name, avatar_url, profile_url, connected_at, needs }] }], limit, plan } — handle, display name and picture are what the network itself reports for that account."
          }
        }
      },
      "post": {
        "summary": "Create a brand",
        "description": "A brand groups one business's connected accounts. The plan sets how many brands an account has (Free 1, Starter 3, Pro 10, Agency 50, Scale 200); one more answers 400 brand_limit_reached with an upgrade link.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, brand: { id, name } }"
          },
          "400": {
            "description": "name required, or code brand_limit_reached { brands_used, brands_allowed, upgrade }"
          }
        }
      }
    },
    "/api/insights": {
      "get": {
        "summary": "What works: your best posts against your own median, and the patterns behind them",
        "description": "Every post PostWire published for the account in the last 90 days, compared with the median of the same social account on the same network (views where the network reports them, otherwise likes + reposts + replies). n is always returned; posts under 24 hours old are not ranked; a network that does not share a number is listed with the reason instead of a zero. Free plans get the 3 best posts; paid plans get the full ranking and the patterns (format, day, time of day, length, hashtags, first-line type), which need at least 10 ranked posts and 3 posts per group. On a plan without patterns, locked.patterns_preview lists the patterns that are ready with the size of each effect (x_median, n) but not the winning value, locked.best_time does the same for the best time to post, and locked.teaser sums it up (or says how many more measured posts are needed).",
        "parameters": [
          {
            "name": "brand_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "platform",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tz",
            "in": "query",
            "description": "IANA timezone for the day/time patterns (default UTC)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ top: [{ id, platform, value, metric, median, n, x_median, headline, why[] }], networks[], patterns | null, locked: { patterns_ready, patterns_status, patterns_preview[], best_time, teaser, more_posts_ranked } | null, insights_teaser?, upgrade? }"
          },
          "401": {
            "description": "API key required"
          },
          "404": {
            "description": "brand not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/insights/replicate": {
      "post": {
        "summary": "Draft new posts modelled on one of your best posts (nothing is published)",
        "description": "Writes one draft per network reusing the structure, opening, length, format and tone of a post from /api/insights, on a new topic or angle; its sentences are not reused. Counts toward the daily AI limit. Paid plans.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "post_id"
                ],
                "properties": {
                  "post_id": {
                    "type": "string"
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "topic": {
                    "type": "string"
                  },
                  "brand_voice": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ drafts: { <platform>: { text, title?, tags? } }, reference, published: false }"
          },
          "402": {
            "description": "not included in the current plan (code plan_feature, with the plan that includes it)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "post not found"
          },
          "429": {
            "description": "daily AI limit"
          },
          "503": {
            "description": "AI not configured"
          }
        }
      }
    },
    "/api/insights/settings": {
      "post": {
        "summary": "Turn click tracking of your own links on or off",
        "description": "With track_links on, https links in posts to Bluesky, Mastodon, LinkedIn, Facebook, Telegram, Discord and YouTube go out as postwire.io/r/<code> and redirect to the same page; clicks show up in /api/insights. Paid plans.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "track_links"
                ],
                "properties": {
                  "track_links": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, track_links }"
          },
          "402": {
            "description": "not included in the current plan"
          }
        }
      }
    },
    "/api/coach": {
      "get": {
        "summary": "Coach: your results, your goal and your next move",
        "description": "What the dashboard's Home shows after you publish, from your own numbers: this week's posts against your weekly goal, the daily streak, views or interactions over 7 days against the 7 days before, follower change where the network shares it, your best post of the week compared with your own median on that network (with n) and what it had — a trait is named as a reason only when your own posts back it (3 posts each way, 1.2x or more) — milestones, the ONE next action, today's next best post (an opening and format your posts back, a ready-to-edit starter, the best time from your data or a sourced benchmark), and your winner adapted to the connected networks it has not been on. Free plans also get, only when a plan limit touched their posts, what a paid plan would have done with their numbers and its price per day. Deterministic: no AI is called. A network that does not share numbers is listed with the reason, never as a zero.",
        "parameters": [
          {
            "name": "tz",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "IANA timezone for the week, the day and the streak (default UTC)"
          },
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "only this brand's posts and networks"
          }
        ],
        "responses": {
          "200": {
            "description": "{ goal, goal_options, cadence_options, week, streak, history, results: { last_7_days, previous_7_days, best_post, best_recent, followers, measured, published }, measurable, milestones, next_action, next_post, repost, moments, ai_drafts, plan, rules }"
          }
        }
      }
    },
    "/api/coach/goal": {
      "post": {
        "summary": "Coach: set your goal and weekly cadence",
        "description": "goal: grow_audience, get_clients, sell_product or personal_brand. cadence: posts a week (3, 5, 7 or 10; one post to several networks counts once). It decides the ideas the coach suggests and the weekly target.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "goal"
                ],
                "properties": {
                  "goal": {
                    "type": "string",
                    "enum": [
                      "grow_audience",
                      "get_clients",
                      "sell_product",
                      "personal_brand"
                    ]
                  },
                  "cadence": {
                    "type": "integer",
                    "enum": [
                      3,
                      5,
                      7,
                      10
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, goal: { goal, cadence, label, set_at } }"
          },
          "400": {
            "description": "unknown goal (the list is returned)"
          }
        }
      }
    },
    "/api/coach/hook": {
      "post": {
        "summary": "Coach: score a post's first line for each network",
        "description": "Rules only, no AI: the kind of opening (question, number, list, how-to, contrarian, story), the network's fold (how much it shows before it cuts; approximate where the network does not publish it), warm-up openers, hashtags, a link or capitals in the first line, and the network's limit. Returns a 0-100 score per network with the top fixes, plus your own opening pattern when your posts show one.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "drafts": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "each network's own text, when it differs"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ overall, networks: [{ platform, score, grade, hook_type, first_line_len, fold, checks, fixes, tip? }] }"
          }
        }
      }
    },
    "/api/coach/share": {
      "post": {
        "summary": "Coach: a public image of your week in numbers",
        "description": "Returns image_url, a PNG (1080x1080) of this week's posts against your goal, the streak, views or interactions and your best post's ratio, with a small \"made with PostWire\" line, and a caption to post with it. The numbers travel inside the signed link: opening it reads nothing else and shows nothing else. Valid 180 days.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tz": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "description": "optional name on the card (40 characters)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, image_url, caption, numbers, note }"
          }
        }
      }
    },
    "/api/connect/{platform}/move": {
      "post": {
        "summary": "Move a connected account to another brand of the same PostWire account",
        "description": "Keeps the same login and token; only the brand changes. Without confirm:true nothing moves and the response describes the move (which account, from which brand, to which). Refused with 409 when the target brand already has that network, or when queued posts of the source brand still publish to it (they are listed).",
        "parameters": [
          {
            "name": "platform",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "to_brand_id"
                ],
                "properties": {
                  "to_brand_id": {
                    "type": "string"
                  },
                  "from_brand_id": {
                    "type": "string",
                    "description": "Needed only when the network is connected in more than one brand."
                  },
                  "confirm": {
                    "type": "boolean",
                    "description": "true performs the move; otherwise it is a preview."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, preview?|moved?, platform, account, from: { brand_id, name }, to: { brand_id, name }, message }"
          },
          "409": {
            "description": "ambiguous_brand | target_has_platform | scheduled_posts_use_it"
          }
        }
      }
    },
    "/api/trial": {
      "get": {
        "summary": "The no-card Pro trial: where it stands, what Pro did for this account, the offer",
        "description": "7 days of Pro with no card, once per person, started by the account's first successful post (or, for an account that already published, its next publish or the next free limit it hits). While it runs the account keeps plan \"free\" and gets Pro's limits, except X (paid per post on paid plans) and an AI budget of Free's month plus Pro's for the trial's days. When it ends nothing is deleted: scheduled posts past Free's queue cap are held (they go out on upgrade), brands made during the trial past Free's count are paused for publishing. Returns { trial: { kind, plan, until, started_at, days_left, active, ended_at? }, line, facts: { posts, network_posts, multi_network_posts, posts_this_month, free_post_limit, posts_over_free, ai_drafts_month_about, queued, held, queued_past_free, brands, brands_past_free }, did[], when_it_ends[], keeps[], paid_offer? } — or { trial: null, available, offer? } for an account that never had one.",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing/invalid API key"
          }
        }
      }
    },
    "/api/trial/start": {
      "post": {
        "summary": "Start the no-card Pro trial now (an account that has published)",
        "description": "For a free account that has published and never had the trial: starts the 7 days now (the dashboard's button on a free limit). An account that has not published yet is told its first post starts it — except `from: \"bizcard\"` (the dashboard's approvals-and-team card) for an account the server finds business-like (3+ networks connected, 2+ brands, or a team seat wall): it starts before the first post, with the same once-per-person rules. 409 `trial_unavailable` with `reason`: not_posted_yet, trial_used, same_person (another account of the same person had it), card_trial_used, paid_plan, off.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string",
                    "description": "where the button was (measurement); \"bizcard\" may start it before the first post for a business-like account"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ started: true, trial_started: { kind, plan, days, started_at, until, no_card }, trial_note, trial }"
          },
          "401": {
            "description": "Missing/invalid API key"
          },
          "409": {
            "description": "trial_unavailable"
          }
        }
      }
    },
    "/api/account": {
      "get": {
        "summary": "Alias of GET /api/me: account info, usage and connections",
        "responses": {
          "200": {
            "description": "Same body as /api/me"
          },
          "401": {
            "description": "Missing/invalid API key"
          }
        }
      }
    },
    "/api/usage": {
      "get": {
        "summary": "This month's posts, today's AI drafts and brands, against the plan's limits",
        "description": "{ plan, plan_name, period, posts: { used, limit, left, resets_on }, ai_drafts_today: { used, limit, left, resets_at }, brands: { used, limit }, networks_per_post: { limit }, scheduled_queue: { used, limit, held, left }, grandfathered_until?, upgrade? } — a limit of null means unlimited; upgrade appears at 80 % of a limit.",
        "responses": {
          "200": {
            "description": "usage"
          }
        }
      }
    },
    "/api/plan": {
      "get": {
        "summary": "The account's plan, what it includes, current usage and the next plan with a checkout link",
        "responses": {
          "200": {
            "description": "{ plan, name, price_usd_month, includes, limits: { posts_per_month, brands, ai_drafts_per_day, networks_per_post, scheduled_queue }, usage, grandfathered_until?, next? }"
          }
        }
      }
    },
    "/api/billing": {
      "get": {
        "summary": "Plan, subscription state and where to manage billing",
        "description": "Changing, cancelling or updating a card is done by a person: POST /api/billing/portal returns the portal link.",
        "responses": {
          "200": {
            "description": "{ plan, name, price_usd_month, subscription: active|none|unknown|null, manage, upgrade, refund }"
          }
        }
      }
    },
    "/api/connections": {
      "get": {
        "summary": "The connected accounts, with their brand and the identity each network reports",
        "responses": {
          "200": {
            "description": "{ connections: [{ platform, brand_id, brand_name, label?, identity, needs }] }"
          }
        }
      }
    },
    "/api/brands/{id}": {
      "get": {
        "summary": "One brand and its connected accounts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ brand: { id, name, platforms[], accounts[] } }"
          },
          "404": {
            "description": "brand_not_found"
          }
        }
      },
      "patch": {
        "summary": "Rename a brand",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, brand }"
          },
          "404": {
            "description": "brand not found"
          }
        }
      },
      "delete": {
        "summary": "Delete a brand and disconnect its networks (an account keeps at least one brand)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "confirm",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Required when the brand has active client links: they are turned off with the brand."
          },
          {
            "name": "dry_run",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Answer what would be deleted (would_delete) without deleting anything."
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, deleted: { client_links, networks, scheduled_posts } } — with dry_run=1: { ok, dry_run, would_delete, can_delete }"
          },
          "400": {
            "description": "the last brand (code last_brand)"
          },
          "404": {
            "description": "brand not found"
          },
          "409": {
            "description": "brand_has_client_links: the brand has active client links; repeat with confirm=1. Nothing was deleted."
          }
        },
        "description": "Deleting a brand also turns off its active client links (the client page stops working at once), disconnects its networks and drops its scheduled posts. A brand with active client links is only deleted with `confirm=1`; without it the answer is 409 `brand_has_client_links` with `would_delete`, and nothing is deleted. `dry_run=1` answers `would_delete` ({ client_links, networks, scheduled_posts }) and deletes nothing."
      }
    },
    "/api/schedule/{id}": {
      "get": {
        "summary": "One scheduled post with each network's result",
        "description": "Also follows a large YouTube/TikTok upload that continues after /api/post answered: its result carries this id as schedule_id. `uploading` shows the bytes sent so far.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ scheduled }"
          },
          "404": {
            "description": "not_found"
          }
        }
      },
      "patch": {
        "summary": "Move or edit a queued post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, scheduled }"
          },
          "409": {
            "description": "no longer queued"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "run_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "label": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "payload": {
                    "type": "object",
                    "description": "The post itself, same shape as POST /api/post (text, per_platform, media, options)."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Cancel a queued or held post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok }"
          },
          "409": {
            "description": "no longer queued"
          }
        }
      }
    },
    "/api/week": {
      "post": {
        "summary": "Write and queue a week of posts from one topic",
        "description": "One topic in, one post a day out: each day is written from a different angle for every network asked, and queued at start_hour in the given IANA timezone, starting tomorrow. Text networks only (a video network answers media_required). Counts as one AI draft against the daily limit; 3 week plans an hour. Days that do not fit the plan (the Free queue of 3, or the month's posts) are written and saved as held, never dropped.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "topic",
                  "platforms"
                ],
                "properties": {
                  "topic": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "tiktok",
                        "instagram",
                        "youtube",
                        "linkedin",
                        "facebook",
                        "bluesky",
                        "mastodon",
                        "telegram",
                        "discord",
                        "wordpress",
                        "devto",
                        "hashnode",
                        "slack",
                        "nostr",
                        "x"
                      ]
                    }
                  },
                  "days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 7,
                    "default": 5
                  },
                  "start_hour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23,
                    "default": 10,
                    "description": "Hour of the day, on the wall clock of timezone."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA name, e.g. America/Lima. Without it, tz_offset_minutes (getTimezoneOffset convention) or UTC."
                  },
                  "tz_offset_minutes": {
                    "type": "integer"
                  },
                  "brand_voice": {
                    "type": "string",
                    "maxLength": 1500
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, queued: [{ id, run_at, status, preview, posts }], held?: [...], failed: [], targets, message, held_networks?, upgrade? }"
          },
          "400": {
            "description": "topic required, platforms[] required, bad_timezone, not_connected, media_required"
          },
          "409": {
            "description": "ambiguous_brand"
          },
          "429": {
            "description": "rate_limited, or the daily AI limit"
          }
        }
      }
    },
    "/api/connect/{platform}": {
      "delete": {
        "summary": "Disconnect one network of one brand",
        "parameters": [
          {
            "in": "path",
            "name": "platform",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "tiktok",
                "instagram",
                "youtube",
                "linkedin",
                "facebook",
                "bluesky",
                "mastodon",
                "telegram",
                "discord",
                "wordpress",
                "devto",
                "hashnode",
                "slack",
                "nostr",
                "x"
              ]
            }
          },
          {
            "in": "query",
            "name": "brand_id",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Which brand's connection, when the network is connected in more than one brand."
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, platform, brand_id, connected: false }"
          },
          "404": {
            "description": "not_connected in that brand"
          },
          "409": {
            "description": "ambiguous_brand: connected in several brands, say which with ?brand_id="
          }
        }
      }
    },
    "/api/connect/{platform}/health": {
      "get": {
        "summary": "Check that a connection still works",
        "description": "Asks the network whether the stored login is still accepted (a revoked token, a Telegram bot removed from its chat, a deleted Discord or Slack webhook, a revoked WordPress application password or Dev.to / Hashnode key). healthy null means the network has no check. 240 checks an hour.",
        "parameters": [
          {
            "in": "path",
            "name": "platform",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "tiktok",
                "instagram",
                "youtube",
                "linkedin",
                "facebook",
                "bluesky",
                "mastodon",
                "telegram",
                "discord",
                "wordpress",
                "devto",
                "hashnode",
                "slack",
                "nostr",
                "x"
              ]
            }
          },
          {
            "in": "query",
            "name": "brand_id",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Which brand's connection, when the network is connected in more than one brand."
          }
        ],
        "responses": {
          "200": {
            "description": "{ platform, brand_id, connected, healthy: true|false|null, reason, action: null|\"reconnect\", account, label }"
          }
        }
      }
    },
    "/api/media/upload-link": {
      "post": {
        "summary": "A link to upload a file from another device (a phone), valid 24 hours",
        "description": "For an assistant or a flow that cannot send the file itself: open the url on the device that has the video, upload, and GET /api/media/uploads/{upload_id} (or the dashboard) returns its media_url. 30 links an hour.",
        "responses": {
          "200": {
            "description": "{ url, upload_id, expires_in: 86400, max_bytes, accepts[] }"
          }
        }
      }
    },
    "/api/media/card": {
      "post": {
        "summary": "Make an image from a post's words, or put the words over your photo (TikTok slide)",
        "description": "Without background_url: the post's words drawn on a clean card (portrait 1080x1350 or story 1080x1920). With background_url: your photo cropped to 1080x1920 with the words over it in white with a black outline, the look of TikTok's own text, placed in the area TikTok leaves clear of its buttons. Six of these sent as media to /api/post make a TikTok photo post (slideshow); add options.tiktok.as_draft to get them as a draft and add a trending sound in the app. No AI is used and nothing is published: pass the returned media_url in media or photo_url. Stored like an upload. 30 an hour per account and a daily cap by plan.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 5000,
                    "description": "The words to draw. On a slide, up to about 220 characters are kept."
                  },
                  "background_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Optional. A public https link to a JPEG, PNG or WebP (up to 15MB). Makes a 1080x1920 slide with the words over it; empty text gives the photo alone, cropped."
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "portrait",
                      "story"
                    ],
                    "default": "portrait",
                    "description": "Card size when there is no background_url."
                  },
                  "style": {
                    "type": "string",
                    "enum": [
                      "light",
                      "dark"
                    ],
                    "default": "light",
                    "description": "Card colours when there is no background_url."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, media_url, path, kind: \"photo\", content_type: \"image/jpeg\", bytes, width, height, format (\"slide\" with background_url), text_on_image, expires_at }"
          },
          "400": {
            "description": "code bad_background (the photo did not download or is not an image) or unsupported_script"
          },
          "429": {
            "description": "30 an hour per account, or code card_daily_limit"
          }
        }
      }
    },
    "/api/media/video": {
      "post": {
        "summary": "Make a short vertical video from a post's words (for YouTube and TikTok)",
        "description": "YouTube takes only video and TikTok video or photos. This turns the words of a post into an MP4 you can publish there: 1080x1920 (9:16), 8 to 12 seconds, H.264 High with AAC sound, 30 fps. The first line (or first sentence) appears as a large heading and up to two more sentences appear one after another over a softly moving plain background, inside the area TikTok and Shorts leave clear of their buttons and caption. Emoji, links and trailing hashtags are left out; nothing is added that you did not write, and there is no PostWire watermark. Music: one of three royalty-free beds (Pixabay Content License, checked free of YouTube Content ID) at about -14 LUFS, or silence. No AI is used and nothing is published: pass the returned media_url as video_url to /api/post or /api/schedule. The file is stored like an upload: deleted the day after the last scheduled post that uses it is published, or 7 days after it is made if no scheduled post uses it. Draws Latin, Greek and Cyrillic text. 10 videos an hour per account; per day 10 on the Free plan and 60 on paid plans. Takes about 3 to 10 seconds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 5000,
                    "description": "The post's words. The first line or sentence becomes the heading; up to two more sentences follow."
                  },
                  "style": {
                    "type": "string",
                    "enum": [
                      "light",
                      "dark"
                    ],
                    "default": "light",
                    "description": "Warm off-white or dark background."
                  },
                  "music": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "lofi",
                      "piano",
                      "upbeat",
                      "none"
                    ],
                    "default": "auto",
                    "description": "auto picks one of the three beds from the text; none gives a silent AAC track."
                  },
                  "footer": {
                    "type": "string",
                    "maxLength": 40,
                    "description": "Optional short line under the text, e.g. the brand or shop name."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, media_url, path, kind: \"video\", content_type: \"video/mp4\", bytes, width: 1080, height: 1920, duration_s, music, text_on_video[], poster_url (the last frame as a JPEG), render_ms, expires_at }"
          },
          "400": {
            "description": "code no_text (not enough words) or unsupported_script (an alphabet the font cannot draw)"
          },
          "429": {
            "description": "10 an hour per account, or code video_daily_limit (the plan's videos a day)"
          },
          "503": {
            "description": "code video_unavailable: the renderer is not available on this server"
          }
        }
      }
    },
    "/api/billing/portal": {
      "post": {
        "summary": "A Stripe customer-portal link to change plan, update the card or cancel",
        "responses": {
          "200": {
            "description": "{ url }"
          },
          "503": {
            "description": "billing not configured"
          }
        }
      }
    },
    "/api/tiktok/creator-info": {
      "get": {
        "summary": "The connected TikTok creator and what it may post with",
        "description": "TikTok's own answer for this creator: the privacy levels it allows (use one in options.tiktok.privacy_level), whether comments, duets and stitches are switched off, and the longest video it may post.",
        "parameters": [
          {
            "in": "query",
            "name": "brand_id",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Which brand's connection, when the network is connected in more than one brand."
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, brand_id, creator_nickname, creator_username, creator_avatar_url, privacy_level_options[], comment_disabled, duet_disabled, stitch_disabled, max_video_post_duration_sec }"
          },
          "400": {
            "description": "TikTok not connected"
          }
        }
      }
    },
    "/api/schedule/next-slot": {
      "get": {
        "summary": "Where run_at \"next_slot\" would put a post now (nothing is queued)",
        "description": "A post goes to the earliest slot that every one of its networks has and that none of them already uses for another waiting (queued, held or publishing) post of the same brand. When its networks share no slot, it goes to the earliest slot of any of them that is free for all. Slots less than 2 minutes away are skipped; the search looks 28 days ahead.",
        "parameters": [
          {
            "in": "query",
            "name": "platforms",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated networks, e.g. linkedin,bluesky."
          },
          {
            "in": "query",
            "name": "brand_id",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "timezone",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "IANA timezone, used when the brand has none saved."
          }
        ],
        "responses": {
          "200": {
            "description": "{ brand_id, platforms, run_at, timezone, local, shared }"
          },
          "400": {
            "description": "platforms missing or unknown, bad_timezone"
          },
          "409": {
            "description": "no_free_slot"
          }
        }
      }
    },
    "/api/brands/{id}/slots": {
      "get": {
        "summary": "A brand's queue slots: weekly times per network, and the timezone",
        "description": "Each network of the brand: its saved slots, or the defaults (most networks every day at 09:00, 12:00 and 17:00; LinkedIn weekdays; TikTok 12:00, 17:00 and 20:00; YouTube 12:00 and 17:00). custom lists the networks with their own.",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "timezone",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Shown when the brand has none saved."
          }
        ],
        "responses": {
          "200": {
            "description": "{ brand_id, name, timezone, timezone_saved, slots: { <network>: { mon: [\"09:00\"], … } }, custom: [], defaults, rule }"
          },
          "404": {
            "description": "brand_not_found"
          }
        }
      },
      "put": {
        "summary": "Set a brand's queue slots and timezone",
        "description": "Replaces the slots of each network named; null puts a network back on the defaults. Networks not named keep theirs.",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "timezone": {
                    "type": "string",
                    "nullable": true,
                    "description": "IANA name, e.g. America/Lima. null clears it."
                  },
                  "slots": {
                    "type": "object",
                    "description": "Keyed by network.",
                    "properties": {
                      "tiktok": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "instagram": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "youtube": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "linkedin": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "facebook": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "bluesky": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "mastodon": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "telegram": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      },
                      "discord": {
                        "type": "object",
                        "description": "Days to times, 24-hour HH:MM in the brand's timezone.",
                        "properties": {
                          "mon": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "tue": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "wed": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "thu": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "fri": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sat": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          },
                          "sun": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "09:00"
                            },
                            "maxItems": 24
                          }
                        },
                        "nullable": true
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, …the same body as GET }"
          },
          "400": {
            "description": "bad_timezone, or a bad day, time or network (bad_request)"
          },
          "404": {
            "description": "brand_not_found"
          },
          "503": {
            "description": "slots_unavailable: slots cannot be saved on this server yet (the defaults still apply)"
          }
        }
      }
    },
    "/api/x": {
      "get": {
        "summary": "X (Twitter) credits: what posting to X uses and what this account has left",
        "description": "X is a pay-per-use add-on of the paid plans (Starter, Pro, Agency, Scale; not Free, not during a trial). 1 X credit = 1 X post; a post with a link uses 10 (X charges about 13 times more for links); each image or video adds 1. Each paid plan includes X credits every month (Starter 30, Pro 150, Agency 600, Scale 2,000; they renew on the 1st and do not roll over) and a daily cap of X posts (5, 20, 60, 150); top-up credits (80 for $5, 340 for $20, one-time) are used after them and do not expire. An X post without enough credits is not sent to X: its result has code x_credits_required and the links to buy more. A thread or a reply under the post: each post is an X post (same credits, counts toward the daily cap), all reserved together before the first one is sent.",
        "responses": {
          "200": {
            "description": "{ network: \"x\", available, mode: paid|free|trial|internal, allowed, killed, pricing: { rule, credits, plans, packs, notes }, credits?: { plan_allowance, allowance_used, allowance_left, topup, total_left, resets_on }, daily?: { used, max }, buy?: [{ pack, usd, credits, url, label }], history: [{ at, kind, what, credits, from_plan, from_topup }], upgrade? (Free), house? (internal: { spent_usd, cap_usd }) }"
          }
        }
      }
    },
    "/api/x/quote": {
      "get": {
        "summary": "How many X credits one post (or a whole thread) would use, before it is published or scheduled",
        "parameters": [
          {
            "name": "text",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The X post's text. A link anywhere in it (also a bare domain such as postwire.io/x) makes it a post with a link."
          },
          {
            "name": "images",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 4
            },
            "description": "Images attached (X takes up to 4)."
          },
          {
            "name": "video",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "A video attached (one, on its own)."
          },
          {
            "name": "thread",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "maxItems": 25,
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true,
            "description": "The posts of a thread after text (repeat the parameter; POST takes a JSON array). The whole chain is priced."
          },
          {
            "name": "reply",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A reply under the post (or under the thread), priced with it."
          }
        ],
        "responses": {
          "200": {
            "description": "{ credits, has_link, images, video, sentence } — e.g. sentence \"This post uses 10 X credits: it contains a link.\" With thread or reply, the whole chain: also x_posts, with_link and posts: [{ n, role: main|thread|reply, credits, has_link }] — e.g. \"This thread uses 13 X credits: 4 X posts, 1 with a link.\""
          },
          "400": {
            "description": "bad_x_thread: a post of the thread or the reply is empty, not text or over 280 characters as X counts them, or there are more than 25."
          }
        }
      }
    },
    "/api/x/credits/checkout": {
      "post": {
        "summary": "A Stripe Checkout link to buy X top-up credits (one-time payment)",
        "description": "Packs: \"5\" = 80 credits for $5, \"20\" = 340 credits for $20. Nothing is charged until the person pays on the Stripe page. Paid plans only (403 x_paid_plan_required otherwise, with the plan that has X).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pack"
                ],
                "properties": {
                  "pack": {
                    "type": "string",
                    "enum": [
                      "5",
                      "20"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ url } of the Stripe Checkout page"
          },
          "403": {
            "description": "x_paid_plan_required (Free or a running trial) or internal_account"
          }
        }
      }
    },
    "/api/ai": {
      "get": {
        "summary": "AI drafts: about how many this month's AI budget holds and has left, AI credits and the packs",
        "description": "Every plan includes AI drafts a day (genDay) and an AI budget a month, said in drafts: about 20 on Free, 30 on Starter, 60 on Pro, 150 on Agency, 330 on Scale (an AI draft is one idea written for every network picked; a draft to two networks uses less of the month than one to ten). It renews on the 1st (UTC). Past it, AI credit packs (one-time, no expiry) are used. When both are used up, AI routes answer 429 `ai_month_limit` with `buy_ai_credits` links and the plan above; publishing and scheduling never stop.",
        "responses": {
          "200": {
            "description": "{ month: { drafts_about, drafts_left_about, used_pct, drafts_a_day, resets_on }, credits: { drafts_left_about }, rule, packs: [{ pack, usd, drafts_about }], buy?: [{ pack, usd, drafts_about, url, label }], history: [...], upgrade? }"
          }
        }
      }
    },
    "/api/ai/credits/checkout": {
      "post": {
        "summary": "A Stripe Checkout link to buy an AI credit pack (one-time payment)",
        "description": "Packs: \"5\" = about 40 AI drafts for $5, \"20\" = about 190 for $20. Used after the month's AI drafts; they do not expire. Nothing is charged until the person pays on the Stripe page. A refund or dispute takes back what is left of the pack.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pack"
                ],
                "properties": {
                  "pack": {
                    "type": "string",
                    "enum": [
                      "5",
                      "20"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ url } of the Stripe Checkout page"
          },
          "403": {
            "description": "internal_account (internal accounts are not billed for AI)"
          },
          "503": {
            "description": "ai_credits_unavailable: packs are not on sale on this server yet"
          }
        }
      }
    },
    "/api/approvals": {
      "get": {
        "summary": "Approvals: posts waiting for a person, and the ones decided",
        "description": "Newest first, each with every network's preview (account, text, title, media, length against the network's limit and, for Instagram and LinkedIn, about where the feed folds it), why it waits, who was notified, the decision and the post's state. counts = how many per status. can_decide = whether this caller may decide (only a signed-in dashboard session).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "pending | approved | rejected | canceled; omit for all",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "approved",
                "rejected",
                "canceled"
              ]
            }
          },
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "description": "Only this brand",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 200, default 50",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "ISO time: only approvals created before it (paging)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ approvals: [{ id, status, schedule_id, brand_id, mode: now|scheduled, run_at, platforms, targets, reasons: [{ code, text }], source: { kind, label }, notified, decision, decided_by, decided_via: link|dashboard|requester, decided_at, reminders, next_reminder_at, preview: [{ platform, name, account, text, title, chars, max, over, fold, media }], post: { status, run_at, results, last_error } }], counts: { pending, approved, … }, can_decide }"
          },
          "503": {
            "description": "governance_unavailable"
          }
        }
      }
    },
    "/api/approvals/{id}": {
      "get": {
        "summary": "One approval, with its preview",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ approval: { …, review_url, post }, can_decide }"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/approvals/{id}/decision": {
      "post": {
        "summary": "Approve or reject a waiting post (dashboard session only)",
        "description": "Only a person signed in to the PostWire dashboard can call this: an API key made in API & MCP, an AI connector or any other source gets 403 approval_requires_human — an agent can never approve its own post. Approve all networks, or only `networks`; `edits` replaces a network's text before it goes out; `run_at` sets a new time. A post whose time is now or has passed is published at once and the response carries each network's result; a post approved before its time goes out at that time. Reject keeps `reason`, shown to whoever sent it. One decision wins: a second one answers 409 not_pending.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "reject"
                    ]
                  },
                  "networks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Approve only these networks of the post; the others are dropped from it. Default: all."
                  },
                  "edits": {
                    "type": "object",
                    "description": "{ \"<network>\": { \"text\": \"…\", \"title\": \"…\" } } — the approved text for that network.",
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "text": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "run_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Publish at this time instead (not in the past, up to 365 days ahead)."
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "Why it was rejected (or a note with an approval)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, decision: approved|rejected, approval, late (its time had passed), post: { id, status, run_at, platforms }, results? (when it was published now), message }"
          },
          "400": {
            "description": "bad_request (no network chosen, an emptied text, a past run_at)"
          },
          "403": {
            "description": "approval_requires_human"
          },
          "404": {
            "description": "not_found"
          },
          "409": {
            "description": "not_pending: already decided, or withdrawn"
          }
        }
      }
    },
    "/api/approvals/link": {
      "post": {
        "summary": "What an approval link shows (no API key: the link is the credential)",
        "description": "The page at /approve/#t=<token> calls this. Each approver gets their own link: HMAC-signed, expiring (72 hours by default, set per brand) and good for one decision. It never carries key ids.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "t"
                ],
                "properties": {
                  "t": {
                    "type": "string",
                    "description": "The token from the link's #t= fragment."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ approval (with preview), brand, requested_by (masked), you: { role: owner|external|chat, approver }, link: { expires_at, used, expired }, can_decide, post }"
          },
          "400": {
            "description": "link_invalid"
          },
          "404": {
            "description": "link_invalid"
          },
          "410": {
            "description": "link_expired"
          }
        }
      }
    },
    "/api/approvals/link/decision": {
      "post": {
        "summary": "Approve or reject through an approval link",
        "description": "Same decision as POST /api/approvals/{id}/decision, by the person the link was sent to (the account owner, a client approver on Pro and above, or the brand's Telegram/Discord chat when switched on). The link is spent by the decision.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "t",
                  "action"
                ],
                "properties": {
                  "t": {
                    "type": "string"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "reject"
                    ]
                  },
                  "networks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "edits": {
                    "type": "object"
                  },
                  "run_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "as POST /api/approvals/{id}/decision"
          },
          "409": {
            "description": "link_used or not_pending"
          },
          "410": {
            "description": "link_expired"
          }
        }
      }
    },
    "/api/approvals/settings": {
      "get": {
        "summary": "Each brand's approval rules, and what the plan includes",
        "responses": {
          "200": {
            "description": "{ plan: { name, approvals, approvers (extra approvers per brand), guardrails, activity_days }, locked: { approvals?|approvers?|guardrails?: { message, plan, upgrade_url } }, sources, defaults, can_edit, brands: [{ id, name, networks, chats: { telegram, discord }, policy, saved }] }"
          }
        }
      }
    },
    "/api/brands/{id}/approvals": {
      "put": {
        "summary": "Set a brand's approval rules (dashboard session only)",
        "description": "Plain rules checked on PostWire's server before anything is sent; no AI is involved. Only a signed-in dashboard session can change them (403 approval_requires_human otherwise), so an agent cannot switch its own approvals off.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "description": "Switching the rules off is allowed on every plan; on needs a paid plan (Starter and above)."
                  },
                  "sources": {
                    "type": "object",
                    "description": "Which sources' posts wait. Defaults: api, agents and automations true; dashboard false.",
                    "properties": {
                      "dashboard": {
                        "type": "boolean"
                      },
                      "api": {
                        "type": "boolean"
                      },
                      "agents": {
                        "type": "boolean",
                        "description": "AI agents over MCP: Claude, ChatGPT, Cursor, the local postwire-mcp."
                      },
                      "automations": {
                        "type": "boolean",
                        "description": "n8n, Make, Zapier."
                      }
                    }
                  },
                  "networks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Only posts that include one of these networks wait (the whole post waits). Empty = every network."
                  },
                  "only_if": {
                    "type": "object",
                    "description": "Only posts that match one of these wait. All off = every post from the sources.",
                    "properties": {
                      "link": {
                        "type": "boolean",
                        "description": "Contains a link (URLs, www., bare domains like shop.com/sale)."
                      },
                      "price": {
                        "type": "boolean",
                        "description": "Mentions a currency amount ($49, 19.99 EUR, S/ 120, 300 soles)."
                      },
                      "words": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Words or phrases (up to 200), case- and accent-insensitive, whole words; a trailing * matches the start of a word."
                      }
                    }
                  },
                  "approvers": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "email"
                    },
                    "description": "Extra approvers who approve from their own link without a PostWire account. Pro: 5 per brand, Agency 25, Scale 100; not on Starter."
                  },
                  "notify": {
                    "type": "object",
                    "properties": {
                      "email": {
                        "type": "boolean",
                        "description": "Email the owner (default true)."
                      },
                      "telegram": {
                        "type": "boolean",
                        "description": "Post the approval link in the brand's connected Telegram (anyone in that chat can approve with it)."
                      },
                      "discord": {
                        "type": "boolean"
                      }
                    }
                  },
                  "remind_every_hours": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 168,
                    "description": "Remind with fresh links after this many hours, at most 3 times (0 = never). Default 12."
                  },
                  "link_hours": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 336,
                    "description": "How long each link works. Default 72."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, brand_id, policy }"
          },
          "400": {
            "description": "bad_request"
          },
          "403": {
            "description": "approval_requires_human, plan_feature or approvers_limit (with upgrade)"
          },
          "503": {
            "description": "governance_unavailable"
          }
        }
      }
    },
    "/api/guardrails": {
      "get": {
        "summary": "Limits per API key and connected AI app, with this month's use",
        "responses": {
          "200": {
            "description": "{ period, available, can_edit, networks, keys: [{ id, name, prefix, session, guard: { monthly_cap, networks, brand_ids, require_approval, used_this_month } | null }], apps: [{ id, name, guard }] }"
          }
        }
      }
    },
    "/api/guardrails/{kind}/{id}": {
      "put": {
        "summary": "Set the limits of one API key or connected AI app (dashboard session only)",
        "description": "kind = key (an API key) or app (a connected AI app, as listed by GET /api/connected-apps). monthly_cap counts each network a post is sent or queued to through it, per UTC month; a network that fails is given back. networks / brand_ids: what it may post to (null = all). require_approval: every post from it waits for approval, whatever the brand's rules. An empty body removes the limits. Paid plans.",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "key",
                "app"
              ]
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "monthly_cap": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0
                  },
                  "networks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true
                  },
                  "brand_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "nullable": true
                  },
                  "require_approval": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, subject: key|app, id, guard }"
          },
          "403": {
            "description": "approval_requires_human or plan_feature"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/activity": {
      "get": {
        "summary": "The account's activity log",
        "description": "Who or what did what: post.published / post.failed / post.deferred / post.canceled (per network), x.credits_spent, approval.requested / approved / rejected / edited / withdrawn, key.created / key.revoked, settings.approvals_changed / settings.guardrails_changed. Each row says its source (actor_kind, actor_label: the dashboard, an API key by name, an AI connector by app, n8n/Make/Zapier, an approver's email) and the X credits it used.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO time (the plan keeps 7, 30, 90 or 365 days)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "ISO time",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "description": "An action (post.published) or a prefix ending in a dot (post., approval., key., settings.); x = rows that used X credits",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "actor",
            "in": "query",
            "required": false,
            "description": "dashboard | api | agents | automations | approver | scheduler | system",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "description": "Only this brand",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "key_id",
            "in": "query",
            "required": false,
            "description": "Only this API key or AI app (its id)",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 500, default 100",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "before_id",
            "in": "query",
            "required": false,
            "description": "Paging: rows older than this id",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ activity: [{ id, at, action, actor_kind, actor_label, key_id, grant_id, brand_id, platform, target_id, x_credits, summary, detail }], days, since, next_before_id? }"
          }
        }
      }
    },
    "/api/activity.csv": {
      "get": {
        "summary": "The activity log as CSV (same filters, up to 5,000 rows)",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO time (the plan keeps 7, 30, 90 or 365 days)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "ISO time",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "description": "An action (post.published) or a prefix ending in a dot (post., approval., key., settings.); x = rows that used X credits",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "actor",
            "in": "query",
            "required": false,
            "description": "dashboard | api | agents | automations | approver | scheduler | system",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "description": "Only this brand",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "key_id",
            "in": "query",
            "required": false,
            "description": "Only this API key or AI app (its id)",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "text/csv: at, action, actor_kind, actor_label, platform, brand_id, key_id, grant_id, target_id, x_credits, summary",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/team": {
      "get": {
        "summary": "The team of this workspace: members, roles, open invitations, seats",
        "description": "Members in seat order (owner first, then by joining) with their role, brand list and read_only (past the plan's seats after a downgrade: they stay, read-only). Owners and admins also get the open invitations; contributors, approvers and viewers see only themselves. `seats` = { plan_seats, used (members + open invitations), free, next_plan }. Seats: Free 1, Starter 3, Pro 25, Agency 100, Scale 500.",
        "responses": {
          "200": {
            "description": "{ teams, workspace: { id, name, display_name, plan }, you: { role, effective_role, read_only, brand_ids, can_manage, can_edit }, seats, roles: [{ id, label, does, takes_brands }], members: [{ account_id, email, role, brand_ids, joined_at, read_only, you }], invites: [{ id, email, role, brand_ids, expires_at, expired, invited_by }], brands }"
          }
        }
      },
      "patch": {
        "summary": "Rename the workspace",
        "description": "Owner or admin. Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, name }"
          },
          "403": {
            "description": "role_forbidden, team_requires_human"
          }
        }
      }
    },
    "/api/team/invites": {
      "post": {
        "summary": "Invite someone by email",
        "description": "Owner or admin. Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's. The invitation is a signed link that works once, only for that address, for 7 days; the person signs in or up with an emailed code, Google or Apple and joins. The response also carries invite_url, to share yourself. Seats count members plus open invitations: past the plan's seats the answer is 403 seat_limit with the next plan's checkout link. At most 30 invitations a day per workspace. Inviting an address again replaces its open invitation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "role"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "editor",
                      "contributor",
                      "approver",
                      "viewer"
                    ],
                    "description": "admin: everything except billing and ownership. editor: write, schedule, publish within approval rules. contributor: drafts and schedules, every post waits for approval. approver: only the approvals inbox. viewer: read-only."
                  },
                  "brand_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Only these brands of the workspace (editor, contributor, approver, viewer). Empty or omitted = every brand."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, invite: { id, email, role, brand_ids, expires_at }, invite_url, email: { sent, note? }, message }"
          },
          "400": {
            "description": "bad_email, bad_role, bad_brands"
          },
          "403": {
            "description": "seat_limit (with upgrade), role_forbidden, team_requires_human"
          },
          "409": {
            "description": "already_member"
          },
          "503": {
            "description": "teams_unavailable"
          }
        }
      }
    },
    "/api/team/invites/{id}/resend": {
      "post": {
        "summary": "Send an invitation again (a new link; the old one stops working)",
        "description": "Owner or admin. Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's. Once an hour per invitation.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, invite, invite_url, email: { sent }, expires_at }"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/team/invites/{id}": {
      "delete": {
        "summary": "Cancel an invitation",
        "description": "Owner or admin. Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's. Its link stops working and the seat is free again.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok }"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/team/members/{id}": {
      "patch": {
        "summary": "Change a member's role or brand list",
        "description": "Owner or admin; never the owner (ownership moves with POST /api/team/transfer). Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's. brand_ids applies to editor, contributor, approver and viewer; [] = every brand.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The member's account_id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "editor",
                      "contributor",
                      "approver",
                      "viewer"
                    ],
                    "description": "admin: everything except billing and ownership. editor: write, schedule, publish within approval rules. contributor: drafts and schedules, every post waits for approval. approver: only the approvals inbox. viewer: read-only."
                  },
                  "brand_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Only these brands of the workspace (editor, contributor, approver, viewer). Empty or omitted = every brand."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, member: { account_id, role, brand_ids } }"
          },
          "409": {
            "description": "owner"
          }
        }
      },
      "delete": {
        "summary": "Remove a member",
        "description": "Owner or admin. Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's. The API keys and AI apps the member created in this workspace are revoked at once, and they get an email. Never the owner, and never the person who created the workspace (their sign-in is the workspace's account: they can be given any role instead).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The member's account_id",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, removed, keys_revoked, apps_disconnected, email: { sent } }"
          },
          "409": {
            "description": "owner, founder"
          }
        }
      }
    },
    "/api/team/leave": {
      "post": {
        "summary": "Leave this workspace",
        "description": "Any member but the owner (transfer first) and the founder. Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's. Your own PostWire account is not touched.",
        "responses": {
          "200": {
            "description": "{ ok }"
          },
          "409": {
            "description": "owner, founder"
          }
        }
      }
    },
    "/api/team/transfer": {
      "post": {
        "summary": "Transfer ownership to a member",
        "description": "Owner only. Only a person signed in to the dashboard (its session key plus X-PostWire-Source: dashboard): an API key or an AI connector gets 403 team_requires_human, even an admin's. The member becomes the owner (billing, members, deleting the workspace); you become an admin. Type their email in confirm_email.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "account_id",
                  "confirm_email"
                ],
                "properties": {
                  "account_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "confirm_email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, owner, you: { role: admin } }"
          },
          "400": {
            "description": "confirmation_required"
          },
          "403": {
            "description": "role_forbidden"
          }
        }
      }
    },
    "/api/workspaces": {
      "get": {
        "summary": "The workspaces you belong to (the switcher)",
        "description": "Your own workspace first, then every team you joined, each with your role there. To act in one, the dashboard sends its id in the X-PostWire-Workspace header with its session key. An API key belongs to the workspace it was created in and never switches (403 workspace_forbidden).",
        "responses": {
          "200": {
            "description": "{ teams, workspaces: [{ id, name, display_name, role, plan, own, members, read_only }] }"
          }
        }
      }
    },
    "/api/invites/view": {
      "post": {
        "summary": "What an invitation is (the /join/ page)",
        "description": "No API key needed: the signed link is the credential. Never returns the link; the invited address is masked.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "t"
                ],
                "properties": {
                  "t": {
                    "type": "string",
                    "example": "inv1.eyJ3…"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ state: open|used|revoked|expired, workspace, invited_by, role, role_label, does, brands, email (masked), expires_at, you? }"
          },
          "400": {
            "description": "invite_invalid"
          },
          "410": {
            "description": "invite_expired"
          }
        }
      }
    },
    "/api/invites/code": {
      "post": {
        "summary": "Email a 6-digit code to the invited address",
        "description": "No API key needed. The code goes to the address the invitation was sent to, never another: a forwarded link is useless without that mailbox. 4 codes per 15 minutes per invitation.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "t"
                ],
                "properties": {
                  "t": {
                    "type": "string",
                    "example": "inv1.eyJ3…"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, challenge, sent_to }"
          }
        }
      }
    },
    "/api/invites/verify": {
      "post": {
        "summary": "Join with the emailed code",
        "description": "No API key needed. Signs the person in (a new address gets a free account: the code proved the mailbox), joins the workspace and returns a dashboard session key.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "t",
                  "challenge",
                  "code"
                ],
                "properties": {
                  "t": {
                    "type": "string",
                    "example": "inv1.eyJ3…"
                  },
                  "challenge": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string",
                    "example": "123456"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, api_key, workspace_id, role, created }"
          },
          "400": {
            "description": "wrong_code, expired, used"
          },
          "403": {
            "description": "seat_limit"
          },
          "409": {
            "description": "invite_used"
          }
        }
      }
    },
    "/api/invites/accept": {
      "post": {
        "summary": "Join with the session you are signed in with",
        "description": "With a dashboard session (not an API key) of the account whose address was invited. Once per link.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "t"
                ],
                "properties": {
                  "t": {
                    "type": "string",
                    "example": "inv1.eyJ3…"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, workspace_id, role, already }"
          },
          "403": {
            "description": "invite_email_mismatch, needs_session, seat_limit"
          },
          "409": {
            "description": "invite_used"
          },
          "410": {
            "description": "invite_expired, invite_revoked"
          }
        }
      }
    },
    "/api/bulk": {
      "post": {
        "summary": "Bulk upload: check, then schedule many posts at once (CSV or rows)",
        "description": "A CSV (field csv, or the request body itself with Content-Type: text/csv) or a list of rows. Columns: date (\"2026-11-02 09:00\" in the row's timezone or the upload's, an ISO time with its offset, or next_slot), time (optional), timezone, networks, text, text_<network> (each network's own text), title, title_<network>, media_urls (https; prefix video: or document:), media_urls_<network>, image_urls, video_url, alt_text (| between images), first_comment (LinkedIn, Bluesky, Mastodon), x_reply, x_thread (||| between posts), brand (name or id), label, privacy. Comma, semicolon or tab separated; UTF-8 with or without a BOM; quoted fields may hold commas and line breaks.\n\ndry_run is true by default: nothing is stored, and every row comes back with its time in its timezone, its networks, each network's length as that network counts it (X: a link 23, an emoji 2), the X credits it would use, whether it waits for approval (the brand's rules, a key's limits, a Contributor) or is held by the plan, and its errors and warnings. With dry_run false, ALL rows are scheduled or NONE: any row with an error answers 422 bulk_rows_invalid and nothing is stored; the rows that go to the queue are inserted in one statement; if the rows that wait for approval cannot be stored, the inserted ones are canceled again (503). The same upload twice answers 409 bulk_already_scheduled unless allow_duplicate is true. Rows per upload: Free 20, Starter 500, Pro 1,000, Agency 2,000, Scale 5,000 (403 bulk_rows_limit past it). On Free, rows past the 3 scheduled posts at a time are saved as held (never published on Free).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "csv": {
                    "type": "string",
                    "description": "The CSV text, first line = column names. Up to 3 MB."
                  },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "description": "Instead of csv: objects with the same column names."
                  },
                  "dry_run": {
                    "type": "boolean",
                    "default": true
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA timezone for dates without one."
                  },
                  "brand_id": {
                    "type": "string",
                    "description": "Default brand (id or name) for rows without a brand column."
                  },
                  "fit_long_text": {
                    "type": "boolean",
                    "default": false,
                    "description": "A text over a network's limit is cut at a sentence or word when published (a warning), instead of an error."
                  },
                  "date_format": {
                    "type": "string",
                    "enum": [
                      "ymd",
                      "dmy",
                      "mdy"
                    ],
                    "default": "ymd",
                    "description": "How to read 12/10/2026."
                  },
                  "allow_duplicate": {
                    "type": "boolean",
                    "default": false
                  },
                  "check_media": {
                    "type": "boolean",
                    "default": true,
                    "description": "Check that each media link answers (each link once, up to 20 seconds in all)."
                  },
                  "batch_id": {
                    "type": "string",
                    "description": "Your own id for the upload (6-64 letters, digits, - or _). Default: a hash of the file."
                  }
                }
              }
            },
            "text/csv": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, dry_run, batch_id, summary: { rows, ok, with_errors, with_warnings, posts, x_credits, wait_for_approval, held, will_queue, plan }, rows: [{ line, ok, run_at, local, timezone, networks, brand, preview, lengths, x_credits?, approval?, held_for?, errors: [{ field, network?, message, code }], warnings, schedule_id?, status? }], x_credits?, ignored_columns?, undo?, message }"
          },
          "400": {
            "description": "bad_csv (with line), bad_timezone, bad_request"
          },
          "403": {
            "description": "bulk_rows_limit (with the plan that takes the upload), email not verified"
          },
          "409": {
            "description": "bulk_already_scheduled"
          },
          "422": {
            "description": "bulk_rows_invalid: nothing was scheduled; each row says what to fix"
          },
          "503": {
            "description": "bulk_store_failed / governance_unavailable: nothing was scheduled"
          }
        }
      }
    },
    "/api/bulk/template.csv": {
      "get": {
        "summary": "The bulk upload template",
        "description": "A CSV with every column and three example rows (dates a week from today). No key needed.",
        "security": [],
        "responses": {
          "200": {
            "description": "text/csv"
          }
        }
      }
    },
    "/api/bulk/{id}": {
      "delete": {
        "summary": "Undo a bulk upload",
        "description": "Cancels every post of the upload (its batch_id) that has not gone out, and withdraws the ones waiting for approval. Posts already published stay.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, batch_id, canceled, already_out, message }"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/recurring": {
      "get": {
        "summary": "List recurring posts",
        "description": "Each with its rule in words (describe), its status (active, paused, ended), and its next occurrences: the ones in the queue with their schedule_id and status, then the later ones (not_yet_queued).",
        "responses": {
          "200": {
            "description": "{ recurring: [{ id, label, platforms, variants, rule, describe, guard_days, status, paused_reason, occurrences, next_at, last_error, next: [...] }], plan: { name, limit, used }, setup_pending? }"
          }
        }
      },
      "post": {
        "summary": "Set up a recurring post",
        "description": "Every paid plan (Starter 25, Pro 100, Agency 500, Scale 2,000 at a time; 403 plan_feature on Free). Occurrences are put in the queue up to 7 days ahead (at most 14 at once) as ordinary scheduled posts with payload._recurring: each can be edited (PATCH /api/schedule/{id}) or canceled alone, and goes through the brand's approval rules, the key's limits, X credits and the plan's monthly posts like any post. An occurrence whose time passed while the publisher was not running is never posted late. Answers with warnings when the duplicate guard would skip posts (one text every day with a 3-day guard).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "tiktok",
                        "instagram",
                        "youtube",
                        "linkedin",
                        "facebook",
                        "bluesky",
                        "mastodon",
                        "telegram",
                        "discord",
                        "wordpress",
                        "devto",
                        "hashnode",
                        "slack",
                        "nostr",
                        "x"
                      ]
                    }
                  },
                  "text": {
                    "type": "string",
                    "description": "The post, when there is one text."
                  },
                  "variants": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            },
                            "per_platform": {
                              "type": "object"
                            }
                          }
                        }
                      ]
                    },
                    "description": "Texts used in turn: occurrence n uses variant ((n-1) mod count) + 1."
                  },
                  "rule": {
                    "type": "object",
                    "required": [
                      "freq"
                    ],
                    "description": "When it repeats. Daylight saving: a time that does not exist on the day clocks go forward runs that much later (02:30 -> 03:30); a time that happens twice runs the first time.",
                    "properties": {
                      "freq": {
                        "type": "string",
                        "enum": [
                          "daily",
                          "weekly",
                          "monthly"
                        ]
                      },
                      "interval": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 52,
                        "default": 1,
                        "description": "Every N days / weeks / months, counted from start."
                      },
                      "days": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "mon",
                            "tue",
                            "wed",
                            "thu",
                            "fri",
                            "sat",
                            "sun"
                          ]
                        },
                        "description": "weekly: the weekdays (default: the start date's)."
                      },
                      "month_days": {
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": -1,
                          "maximum": 31
                        },
                        "description": "monthly: days of the month; -1 = the last day. 31 falls on the last day of shorter months."
                      },
                      "times": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 4,
                        "items": {
                          "type": "string",
                          "example": "09:00"
                        },
                        "description": "24-hour HH:MM, 1-4 a day. Default 09:00."
                      },
                      "timezone": {
                        "type": "string",
                        "description": "IANA name. Default: the brand's queue timezone, else UTC."
                      },
                      "start": {
                        "type": "string",
                        "format": "date",
                        "description": "First day (default today); also the anchor of every N."
                      },
                      "until": {
                        "type": "string",
                        "format": "date",
                        "description": "Last day, inclusive."
                      },
                      "count": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 1000,
                        "description": "Stop after N occurrences."
                      }
                    }
                  },
                  "guard_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 90,
                    "default": 3,
                    "description": "When an occurrence is published, a network where the same text went out in the last N days (3-hour margin) is skipped, with code duplicate_recent in its result. 0 = off."
                  },
                  "per_platform": {
                    "type": "object"
                  },
                  "media": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "photo_url": {
                    "type": "string"
                  },
                  "video_url": {
                    "type": "string"
                  },
                  "options": {
                    "type": "object"
                  },
                  "title": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "platforms",
                  "rule"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ ok, recurring, queued_now, warnings, message }"
          },
          "400": {
            "description": "bad_rule, not_connected, text_required, too_long, media_required"
          },
          "403": {
            "description": "plan_feature, recurring_limit, x_paid_plan_required"
          },
          "503": {
            "description": "automation_unavailable"
          }
        }
      }
    },
    "/api/recurring/preview": {
      "post": {
        "summary": "Preview a rule",
        "description": "The next occurrences of a rule (and which text each would use) and the warnings, without saving anything.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rule": {
                    "type": "object",
                    "required": [
                      "freq"
                    ],
                    "description": "When it repeats. Daylight saving: a time that does not exist on the day clocks go forward runs that much later (02:30 -> 03:30); a time that happens twice runs the first time.",
                    "properties": {
                      "freq": {
                        "type": "string",
                        "enum": [
                          "daily",
                          "weekly",
                          "monthly"
                        ]
                      },
                      "interval": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 52,
                        "default": 1,
                        "description": "Every N days / weeks / months, counted from start."
                      },
                      "days": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "mon",
                            "tue",
                            "wed",
                            "thu",
                            "fri",
                            "sat",
                            "sun"
                          ]
                        },
                        "description": "weekly: the weekdays (default: the start date's)."
                      },
                      "month_days": {
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": -1,
                          "maximum": 31
                        },
                        "description": "monthly: days of the month; -1 = the last day. 31 falls on the last day of shorter months."
                      },
                      "times": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 4,
                        "items": {
                          "type": "string",
                          "example": "09:00"
                        },
                        "description": "24-hour HH:MM, 1-4 a day. Default 09:00."
                      },
                      "timezone": {
                        "type": "string",
                        "description": "IANA name. Default: the brand's queue timezone, else UTC."
                      },
                      "start": {
                        "type": "string",
                        "format": "date",
                        "description": "First day (default today); also the anchor of every N."
                      },
                      "until": {
                        "type": "string",
                        "format": "date",
                        "description": "Last day, inclusive."
                      },
                      "count": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 1000,
                        "description": "Stop after N occurrences."
                      }
                    }
                  },
                  "variants": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "guard_days": {
                    "type": "integer"
                  },
                  "brand_id": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer",
                    "maximum": 30
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ rule, describe, next: [{ at, local, n, variant }], warnings }"
          },
          "400": {
            "description": "bad_rule"
          }
        }
      }
    },
    "/api/recurring/{id}": {
      "get": {
        "summary": "A recurring post",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ recurring (with next), history: [{ schedule_id, at, n, status, error }], warnings }"
          },
          "404": {
            "description": "not_found"
          }
        }
      },
      "patch": {
        "summary": "Edit all occurrences, pause or resume",
        "description": "Changing the content, the rule, the networks or the guard replaces every waiting occurrence that was not edited by hand; the edited ones stay. status paused cancels the waiting occurrences (not the edited ones); active puts them back.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "tiktok",
                        "instagram",
                        "youtube",
                        "linkedin",
                        "facebook",
                        "bluesky",
                        "mastodon",
                        "telegram",
                        "discord",
                        "wordpress",
                        "devto",
                        "hashnode",
                        "slack",
                        "nostr",
                        "x"
                      ]
                    }
                  },
                  "text": {
                    "type": "string",
                    "description": "The post, when there is one text."
                  },
                  "variants": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            },
                            "per_platform": {
                              "type": "object"
                            }
                          }
                        }
                      ]
                    },
                    "description": "Texts used in turn: occurrence n uses variant ((n-1) mod count) + 1."
                  },
                  "rule": {
                    "type": "object",
                    "required": [
                      "freq"
                    ],
                    "description": "When it repeats. Daylight saving: a time that does not exist on the day clocks go forward runs that much later (02:30 -> 03:30); a time that happens twice runs the first time.",
                    "properties": {
                      "freq": {
                        "type": "string",
                        "enum": [
                          "daily",
                          "weekly",
                          "monthly"
                        ]
                      },
                      "interval": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 52,
                        "default": 1,
                        "description": "Every N days / weeks / months, counted from start."
                      },
                      "days": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "mon",
                            "tue",
                            "wed",
                            "thu",
                            "fri",
                            "sat",
                            "sun"
                          ]
                        },
                        "description": "weekly: the weekdays (default: the start date's)."
                      },
                      "month_days": {
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": -1,
                          "maximum": 31
                        },
                        "description": "monthly: days of the month; -1 = the last day. 31 falls on the last day of shorter months."
                      },
                      "times": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 4,
                        "items": {
                          "type": "string",
                          "example": "09:00"
                        },
                        "description": "24-hour HH:MM, 1-4 a day. Default 09:00."
                      },
                      "timezone": {
                        "type": "string",
                        "description": "IANA name. Default: the brand's queue timezone, else UTC."
                      },
                      "start": {
                        "type": "string",
                        "format": "date",
                        "description": "First day (default today); also the anchor of every N."
                      },
                      "until": {
                        "type": "string",
                        "format": "date",
                        "description": "Last day, inclusive."
                      },
                      "count": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 1000,
                        "description": "Stop after N occurrences."
                      }
                    }
                  },
                  "guard_days": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 90,
                    "default": 3,
                    "description": "When an occurrence is published, a network where the same text went out in the last N days (3-hour margin) is skipped, with code duplicate_recent in its result. 0 = off."
                  },
                  "per_platform": {
                    "type": "object"
                  },
                  "media": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "photo_url": {
                    "type": "string"
                  },
                  "video_url": {
                    "type": "string"
                  },
                  "options": {
                    "type": "object"
                  },
                  "title": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "paused"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, recurring, replaced, queued_now, warnings }"
          },
          "404": {
            "description": "not_found"
          }
        }
      },
      "delete": {
        "summary": "Delete a recurring post",
        "description": "Its waiting occurrences are canceled (and ones waiting for approval withdrawn), unless ?keep_queued=1.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "keep_queued",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, canceled }"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/rss": {
      "get": {
        "summary": "List feeds and sheets",
        "responses": {
          "200": {
            "description": "{ feeds: [{ id, kind (rss | sheet), url, title, platforms, template, mode, post_at, interval_minutes, max_items, timezone, status_col, enabled, last_checked_at, last_status, last_error, failures, items_posted, next_check_at }], plan: { name, limit, used, every_minutes, every, items_per_read, rows_per_read, ai, ai_drafts_a_day, scheduled_queue, min_interval_minutes, approvals, sheets } }. A sheet's last_error can be a note while last_status is ok: rows with problems, rows changed after they were scheduled, rows left for the next read."
          }
        }
      },
      "post": {
        "summary": "Add a feed or a Google Sheet",
        "description": "Feeds and sheets per account, both kinds together: Free 1, Starter 25, Pro 100, Agency 500, Scale 2,000. Read no more often than the plan allows: Free every 6 hours, Starter hourly, Pro and above every 30 minutes; asking for faster reads, more items per read or AI writing than the plan has answers 403 with the plan that has it. Find a feed from any site, blog or YouTube channel first with POST /api/rss/discover.\n\nkind rss: the first read happens now and only records what is already in the feed. Each new item (new by its guid AND its link) becomes a post, at most the plan's items per read (Free 1, Starter 3, Pro 5, Agency and Scale 10), queued now or in the brand's next free slot, or sent to approvals; brand approval rules for automations apply too.\n\nkind sheet (a Google Sheets link): the bulk upload's columns plus an optional status column (only Approved or Ready rows). The first read schedules the ready rows ahead (rows in the past are skipped), at most the plan's CSV rows per upload per read; on Free 3 wait in the queue and the rest are saved as held until an upgrade. Each row is scheduled once: a row whose text or time changed after it was scheduled is reported in last_error, never scheduled again. Until sql/pw_sheet_feeds.sql runs on the server a sheet answers 503 automation_unavailable.\n\nA feed is turned off after 10 failed reads in a row.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "rss",
                      "sheet"
                    ],
                    "default": "rss",
                    "description": "sheet: a Google Sheet (a docs.google.com/spreadsheets link is taken as one even without kind)."
                  },
                  "url": {
                    "type": "string",
                    "description": "RSS 2.0, RSS 1.0 or Atom, or for kind sheet a Google Sheets sharing, Publish to web or export link (stored as that tab's CSV address). http or https on ports 80, 443, 8080 or 8443; private, loopback, link-local and metadata addresses are refused (400 feed_url_blocked), also when a name resolves to one or a redirect points at one; at most 3 redirects, 8 seconds, 2 MB."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "kind sheet: the timezone of times without one (a row's timezone column wins). Default: the brand's queue timezone."
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "tiktok",
                        "instagram",
                        "youtube",
                        "linkedin",
                        "facebook",
                        "bluesky",
                        "mastodon",
                        "telegram",
                        "discord",
                        "wordpress",
                        "devto",
                        "hashnode",
                        "slack",
                        "nostr",
                        "x"
                      ]
                    },
                    "description": "Required for a feed. Not YouTube or TikTok (video only). Instagram gets an item only when it has an image. For a sheet: the networks of a row whose networks cell is empty."
                  },
                  "template": {
                    "type": "string",
                    "maxLength": 2000,
                    "default": "{title}\n\n{link}",
                    "description": "{title}, {link}, {summary}. Fitted to each network's limit as that network counts it: the summary is shortened first, then the title; the link is never cut."
                  },
                  "interval_minutes": {
                    "type": "integer",
                    "minimum": 30,
                    "maximum": 10080,
                    "description": "Default: hourly, or the plan's pace when it is slower (Free: 360). Below the plan's pace: 403 feed_interval_limit."
                  },
                  "max_items": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10,
                    "description": "New items posted per read, oldest first; the rest wait for the next read. Default 3, or the plan's items per read when lower (Free: 1). Above it: 403 feed_items_limit."
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "approval"
                    ],
                    "default": "auto",
                    "description": "approval: every new item waits for approval (paid plans)."
                  },
                  "post_at": {
                    "type": "string",
                    "enum": [
                      "now",
                      "next_slot"
                    ],
                    "default": "now"
                  },
                  "include_image": {
                    "type": "boolean",
                    "default": true
                  },
                  "ai_rewrite": {
                    "type": "boolean",
                    "default": false,
                    "description": "Write each network's post with AI (paid plans; on Free 403 plan_feature feed_ai): one AI draft per item, from the workspace's AI budget, never an extra charge; the template when it is used up or the account's email is not confirmed."
                  },
                  "post_latest": {
                    "type": "boolean",
                    "default": false,
                    "description": "Also post the newest item now. Otherwise the items already in the feed are recorded, not posted."
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ ok, feed, first_read: { primed? | posted? | held? | later? | error? }, message }"
          },
          "400": {
            "description": "feed_url_blocked, bad_feed_url, bad_sheet_url, bad_timezone, bad_template, media_required, not_connected, platforms_required"
          },
          "403": {
            "description": "plan_feature (approvals, feed_ai), rss_feed_limit, feed_interval_limit, feed_items_limit — each with the plan that has it"
          },
          "409": {
            "description": "rss_feed_exists"
          },
          "503": {
            "description": "automation_unavailable"
          }
        }
      }
    },
    "/api/rss/discover": {
      "post": {
        "summary": "Find the feed behind any address, or read a Google Sheet",
        "description": "Paste a site, a blog, a YouTube channel (by @handle, /channel/ or /user/), a Substack, Medium, WordPress or Ghost site, or a Google Sheets link. For a page: PostWire looks for its RSS or Atom link, what the page says it is (a YouTube channel id, a WordPress or Ghost generator, Substack), then /feed, /rss, /feed.xml and /index.xml — at most 6 requests, each with the same protections as a feed (8 seconds, 2 MB, private addresses refused on every hop). For a sheet: its next 5 ready rows and where each lands on the plan (to the queue, held, or the next read). Nothing is saved; add it with POST /api/rss. 20 an hour.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "yourblog.com, youtube.com/@you, a Substack or a docs.google.com/spreadsheets link."
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "For a sheet: the networks of rows whose networks cell is empty."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "For a sheet: the timezone of times without one. Default: the brand's, else UTC."
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A feed: { ok, kind: \"rss\", feed_url, title, source (youtube | substack | medium | wordpress | ghost | link | guess | direct), site, items_in_feed, items: the newest 3, plan, message }. A sheet: { ok, kind: \"sheet\", url (its CSV), published, timezone, columns, status_col, rows_total, ready, new, already_scheduled, skipped, skipped_lines, next: [{ line, run_at, next_slot, networks, text, status, lands: queued | held | later }], will_queue, will_hold, later, note, plan, sheets_ready, message }."
          },
          "400": {
            "description": "feed_url_blocked, bad_feed_url"
          },
          "422": {
            "description": "no_feed_found (\"no feed found on this page …\"), feed_http_error, feed_timeout, feed_too_large, feed_too_many_redirects, sheet_not_shared, bad_sheet"
          },
          "429": {
            "description": "rate_limited"
          }
        }
      }
    },
    "/api/rss/preview": {
      "post": {
        "summary": "Preview a feed",
        "description": "Reads the feed (with the same protections) and returns its title, its newest items and what each network's post of the newest would read. Nothing is saved. 30 an hour.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "RSS 2.0, RSS 1.0 or Atom. http or https on ports 80, 443, 8080 or 8443; private, loopback, link-local and metadata addresses are refused (400 feed_url_blocked), also when a name resolves to one or a redirect points at one; at most 3 redirects, 8 seconds, 2 MB."
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "tiktok",
                        "instagram",
                        "youtube",
                        "linkedin",
                        "facebook",
                        "bluesky",
                        "mastodon",
                        "telegram",
                        "discord",
                        "wordpress",
                        "devto",
                        "hashnode",
                        "slack",
                        "nostr",
                        "x"
                      ]
                    }
                  },
                  "template": {
                    "type": "string",
                    "maxLength": 2000,
                    "default": "{title}\n\n{link}",
                    "description": "{title}, {link}, {summary}. Fitted to each network's limit as that network counts it: the summary is shortened first, then the title; the link is never cut."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, url, kind, title, items_in_feed, items, posts: { <network>: { text, trimmed? } }, note }"
          },
          "400": {
            "description": "feed_url_blocked, bad_feed_url"
          },
          "422": {
            "description": "not_a_feed, feed_http_error, feed_timeout, feed_too_large, feed_too_many_redirects"
          }
        }
      }
    },
    "/api/rss/{id}": {
      "patch": {
        "summary": "Change, pause or turn on a feed",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "RSS 2.0, RSS 1.0 or Atom. http or https on ports 80, 443, 8080 or 8443; private, loopback, link-local and metadata addresses are refused (400 feed_url_blocked), also when a name resolves to one or a redirect points at one; at most 3 redirects, 8 seconds, 2 MB."
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "tiktok",
                        "instagram",
                        "youtube",
                        "linkedin",
                        "facebook",
                        "bluesky",
                        "mastodon",
                        "telegram",
                        "discord",
                        "wordpress",
                        "devto",
                        "hashnode",
                        "slack",
                        "nostr",
                        "x"
                      ]
                    },
                    "description": "Not YouTube or TikTok (video only). Instagram gets an item only when it has an image."
                  },
                  "template": {
                    "type": "string",
                    "maxLength": 2000,
                    "default": "{title}\n\n{link}",
                    "description": "{title}, {link}, {summary}. Fitted to each network's limit as that network counts it: the summary is shortened first, then the title; the link is never cut."
                  },
                  "interval_minutes": {
                    "type": "integer",
                    "minimum": 30,
                    "maximum": 10080,
                    "default": 60
                  },
                  "max_items": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10,
                    "default": 3,
                    "description": "New items posted per read, oldest first; the rest wait for the next read."
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "approval"
                    ],
                    "default": "auto",
                    "description": "approval: every new item waits for approval (paid plans)."
                  },
                  "post_at": {
                    "type": "string",
                    "enum": [
                      "now",
                      "next_slot"
                    ],
                    "default": "now"
                  },
                  "include_image": {
                    "type": "boolean",
                    "default": true
                  },
                  "ai_rewrite": {
                    "type": "boolean",
                    "default": false,
                    "description": "Write each network's post with AI: one of the plan's AI drafts a day per item, never an extra charge; the template when they are used up."
                  },
                  "post_latest": {
                    "type": "boolean",
                    "default": false,
                    "description": "Also post the newest item now. Otherwise the items already in the feed are recorded, not posted."
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "brand_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, feed }"
          },
          "404": {
            "description": "not_found"
          }
        }
      },
      "delete": {
        "summary": "Remove a feed",
        "description": "Posts it already queued stay in the queue.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok }"
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/rss/{id}/check": {
      "post": {
        "summary": "Read a feed now",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ ok, result: { new, posted, results } | { not_modified } | { error }, feed }"
          },
          "409": {
            "description": "feed_busy"
          },
          "429": {
            "description": "6 an hour per feed"
          }
        }
      }
    },
    "/api/rss/{id}/items": {
      "get": {
        "summary": "What happened to a feed's items",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ feed, items: [{ item_id, title, link, published_at, status: scheduled | pending_approval | skipped | failed, schedule_id, note, seen_at }] }"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "pw_live_ key"
      }
    },
    "schemas": {
      "PostRequest": {
        "type": "object",
        "properties": {
          "platform": {
            "type": "string",
            "description": "Single platform; or use 'platforms'."
          },
          "platforms": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Cross-post to many at once, in parallel.",
            "example": [
              "tiktok",
              "youtube"
            ]
          },
          "text": {
            "type": "string",
            "description": "Caption / description."
          },
          "title": {
            "type": "string",
            "description": "Title (used by YouTube)."
          },
          "video_url": {
            "type": "string",
            "description": "URL of the video to post (required for YouTube; TikTok takes a video or photos)."
          },
          "photo_url": {
            "type": "string",
            "description": "URL of one image. TikTok posts it as a photo post. Instagram and TikTok take JPEG (TikTok also WebP): PostWire converts PNG, WebP, AVIF and still GIF to JPEG automatically; animated GIF and HEIC are refused."
          },
          "privacy": {
            "type": "string",
            "description": "e.g. private | public | unlisted (YouTube)."
          },
          "media": {
            "type": "array",
            "maxItems": 35,
            "description": "Several images (or images and videos) in one post, in order. Instagram: a carousel of up to 10 (images and MP4 videos). TikTok: a photo post of up to 35 images. PNG (and WebP, AVIF, still GIF) is converted to JPEG automatically for Instagram and TikTok. Bluesky: up to 4 images. Mastodon: up to 4. LinkedIn: up to 20 images, or one document (PDF/PPT/DOC). Networks that take one item get the first, and the result says so. Also accepted inside a per_platform draft.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "description": "Public https URL of the file."
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "image",
                    "video",
                    "document"
                  ],
                  "default": "image"
                },
                "alt": {
                  "type": "string",
                  "description": "Alt text (Bluesky, Mastodon, LinkedIn)."
                },
                "title": {
                  "type": "string",
                  "description": "Document title (LinkedIn)."
                }
              }
            }
          },
          "photo_urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Shorthand for media: a list of image URLs."
          },
          "per_platform": {
            "type": "object",
            "description": "Per-network overrides, keyed by network name (e.g. {\"tiktok\":{\"text\":\"…\"},\"youtube\":{\"title\":\"…\",\"text\":\"…\"}}). Each value may carry text, title, video_url, photo_url, media and network options. X also takes thread: [\"…\", \"…\"] — the posts of a thread after text, in order (at most 25), each published as a reply to the one before it; each at most 280 characters as X counts them (a link counts 23, an emoji 2), and an empty, non-text or over-long post, or a 26th, is refused with code bad_x_thread before anything goes out. Media goes on the first post only. Every post of a thread is an X post: it uses X credits by the same rule (1, or 10 with a link) and counts toward the daily X limit; the whole thread is reserved before the first post is sent, so a thread without enough credits is refused whole. thread: true splits the text itself at 280 as X counts, at paragraph, sentence or word boundaries, never inside a link. Bluesky and Mastodon take thread too (at most 10 posts in all; Bluesky 300 characters each, Mastodon 500 or the server's own limit, a link counting 23): each post is a reply to the one before it (Bluesky reply refs, Mastodon in_reply_to_id), media stays on the first post, and the result lists every post's URL. thread: true splits a long text into posts at the network's limit. first_comment (LinkedIn, X, Bluesky, Mastodon) is posted by the author right under the post, or under the last post of a thread: the place for the link. On X it is the same as reply. Facebook and Instagram report it as not posted. A thread counts as ONE post of the plan's monthly posts, whatever its length.",
            "additionalProperties": {
              "type": "object"
            },
            "properties": {
              "x": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "The first post (the hook). The request's media goes on it."
                  },
                  "thread": {
                    "oneOf": [
                      {
                        "type": "array",
                        "maxItems": 25,
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "boolean",
                        "enum": [
                          true
                        ]
                      }
                    ],
                    "description": "Posts 2..n of an X thread, in order; each a reply to the one before. Or true: the text is split into posts at 280 as X counts."
                  },
                  "reply": {
                    "type": "string",
                    "description": "Same as options.x.reply: one post under the last post of the chain."
                  },
                  "first_comment": {
                    "type": "string",
                    "description": "Same as reply (the name the other networks use). reply wins when both are sent."
                  }
                }
              },
              "bluesky": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "The first post. The request's media goes on it."
                  },
                  "thread": {
                    "oneOf": [
                      {
                        "type": "array",
                        "maxItems": 9,
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "boolean",
                        "enum": [
                          true
                        ]
                      }
                    ],
                    "description": "Posts 2..n of a Bluesky thread, in order, each a reply to the one before; at most 9 (10 posts in all), each at most 300 characters (graphemes). Over the limit is refused with code bad_thread, never cut. Or true: the text is split into posts at the limit."
                  },
                  "first_comment": {
                    "type": "string",
                    "description": "One reply by the author under the post (under the last post of the thread): the place for the link. At most 300 characters (graphemes). A failed comment is tried again on its own later; the post is never re-sent."
                  }
                }
              },
              "mastodon": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "The first post. The request's media goes on it."
                  },
                  "thread": {
                    "oneOf": [
                      {
                        "type": "array",
                        "maxItems": 9,
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "boolean",
                        "enum": [
                          true
                        ]
                      }
                    ],
                    "description": "Posts 2..n of a Mastodon thread, in order, each a reply to the one before; at most 9 (10 posts in all), each at most 500 characters (a link counts 23) or the server's own limit. Over the limit is refused with code bad_thread, never cut. Or true: the text is split into posts at the limit."
                  },
                  "first_comment": {
                    "type": "string",
                    "description": "One reply by the author under the post (under the last post of the thread): the place for the link. At most 500 characters (a link counts 23) or the server's own limit. A failed comment is tried again on its own later; the post is never re-sent."
                  }
                }
              },
              "linkedin": {
                "type": "object",
                "properties": {
                  "first_comment": {
                    "type": "string",
                    "description": "Same as options.linkedin.first_comment."
                  }
                }
              }
            }
          },
          "options": {
            "$ref": "#/components/schemas/NetworkOptions"
          },
          "brand_id": {
            "type": "string",
            "description": "Brand whose connected accounts publish this post (GET /api/brands). Defaults to the account's only brand."
          },
          "idempotency_key": {
            "type": "string",
            "description": "Send the same key on a retry and the post is not published twice."
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "description": "The JSON body PostWire POSTs to a webhook endpoint. Headers: PostWire-Event (the type), PostWire-Delivery (the delivery id, the same on every retry: dedupe on it), PostWire-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint's secret>. Answer 2xx within 5 s; anything else is retried after 1 min, 5 min, 15 min, 1 h, 3 h, 6 h, 12 h and 24 h.",
        "required": [
          "id",
          "type",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "evt_…, unique per event"
          },
          "type": {
            "type": "string",
            "enum": [
              "post.published",
              "post.failed",
              "connection.reauth_required",
              "approval.requested",
              "approval.decided",
              "webhook.test"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "description": "post.* events: one per network. connection.reauth_required: { platform, account, brand_id, reason, reconnect_url }. approval.requested: { approval_id, schedule_id, brand_id, brand, platforms, reasons, requested_by, mode, run_at, label, review_url, preview }. approval.decided: { approval_id, schedule_id, brand_id, brand, decision, decided_by, via, approved_platforms, rejected_platforms, edited_platforms, reason, publishes, run_at, late }.",
            "properties": {
              "approval_id": {
                "type": "string",
                "description": "approval.*: the approval's id (GET /api/approvals/{id})."
              },
              "brand": {
                "type": "string",
                "nullable": true,
                "description": "approval.*: the brand's name."
              },
              "platforms": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "approval.requested: the networks the post waits for."
              },
              "reasons": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "approval.requested: why it waits, in plain words (the brand's rules, a key's limit, a Contributor's post)."
              },
              "requested_by": {
                "type": "object",
                "nullable": true,
                "description": "approval.requested: { kind: dashboard | api | agents | automations, label }, who or what sent the post."
              },
              "mode": {
                "type": "string",
                "enum": [
                  "now",
                  "scheduled"
                ],
                "description": "approval.requested: now = goes out right after approval; scheduled = at run_at if approved before it."
              },
              "run_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true,
                "description": "approval.*: when the post goes out."
              },
              "review_url": {
                "type": "string",
                "description": "approval.requested: the dashboard page where the account owner decides (needs their sign-in). The signed links sent to approvers are never in an event."
              },
              "preview": {
                "type": "array",
                "items": {
                  "type": "object"
                },
                "description": "approval.requested: the post as the approver sees it, per network: { platform, account, text, title, media: [{ url, type }] }."
              },
              "decision": {
                "type": "string",
                "enum": [
                  "approved",
                  "rejected"
                ],
                "description": "approval.decided."
              },
              "decided_by": {
                "type": "string",
                "nullable": true,
                "description": "approval.decided: the email of whoever decided, or the brand's Telegram/Discord chat."
              },
              "via": {
                "type": "string",
                "enum": [
                  "dashboard",
                  "link"
                ],
                "description": "approval.decided: signed in to the dashboard, or from an emailed or chat link."
              },
              "approved_platforms": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "approval.decided: the networks that will publish."
              },
              "rejected_platforms": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "approval.decided: the networks dropped (all of them on a rejection)."
              },
              "edited_platforms": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "approval.decided: the networks whose text the approver changed."
              },
              "reason": {
                "type": "string",
                "nullable": true,
                "description": "approval.decided: the approver's note."
              },
              "publishes": {
                "type": "string",
                "nullable": true,
                "description": "approval.decided: now or scheduled when approved, null when rejected. The networks' results follow as post.published / post.failed."
              },
              "late": {
                "type": "boolean",
                "description": "approval.decided: the scheduled time passed while the post waited, so it goes out right after approval."
              },
              "platform": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "description": "published (or the network's own state, e.g. processing for TikTok), failed, or unknown when the network did not answer in time"
              },
              "post_id": {
                "type": "string",
                "nullable": true,
                "description": "The post's id on the network (post.published)."
              },
              "url": {
                "type": "string",
                "nullable": true
              },
              "error": {
                "type": "string",
                "nullable": true,
                "description": "Why it failed (post.failed)."
              },
              "code": {
                "type": "string",
                "nullable": true,
                "description": "Machine-readable reason, e.g. not_connected, media_required, media_unreachable, limit_reached, timed_out."
              },
              "account": {
                "type": "object",
                "nullable": true,
                "description": "The connected account: { platform, handle, display_name, brand_id, brand, label }."
              },
              "brand_id": {
                "type": "string",
                "nullable": true
              },
              "source": {
                "type": "string",
                "enum": [
                  "api",
                  "schedule"
                ],
                "description": "api: POST /api/post (also the dashboard, n8n and MCP). schedule: a scheduled post."
              },
              "schedule_id": {
                "type": "string",
                "nullable": true
              },
              "idempotency_key": {
                "type": "string",
                "nullable": true,
                "description": "The idempotency_key the publish was sent with, to match the event to your request."
              },
              "label": {
                "type": "string",
                "nullable": true,
                "description": "The scheduled post's label."
              }
            }
          }
        }
      },
      "NetworkOptions": {
        "type": "object",
        "description": "Options for each network, keyed by network name, e.g. {\"tiktok\":{\"privacy_level\":\"PUBLIC_TO_EVERYONE\"},\"youtube\":{\"privacy\":\"public\",\"tags\":[\"n8n\"]},\"instagram\":{\"post_type\":\"reels\"},\"linkedin\":{\"first_comment\":\"Link: https://…\"},\"x\":{\"reply\":\"Link: https://…\"}}. A network ignores the options of the others. Without a TikTok privacy value the post is published privately (SELF_ONLY).",
        "properties": {
          "tiktok": {
            "type": "object",
            "properties": {
              "privacy_level": {
                "type": "string",
                "enum": [
                  "PUBLIC_TO_EVERYONE",
                  "FOLLOWER_OF_CREATOR",
                  "MUTUAL_FOLLOW_FRIENDS",
                  "SELF_ONLY"
                ],
                "description": "Who sees the post. Words also work: public, followers, friends, private. When TikTok does not allow the value for this creator, the closest allowed level that is not more open is used and the result says so. Default: the level saved for the connection (PATCH /api/connect/tiktok/settings with default_privacy public, followers, friends or private; null clears it), else SELF_ONLY."
              },
              "disable_comment": {
                "type": "boolean",
                "default": false
              },
              "disable_duet": {
                "type": "boolean",
                "default": false,
                "description": "Videos only."
              },
              "disable_stitch": {
                "type": "boolean",
                "default": false,
                "description": "Videos only."
              },
              "brand_organic_toggle": {
                "type": "boolean",
                "default": false,
                "description": "Discloses that the post promotes the creator's own business."
              },
              "branded_content_toggle": {
                "type": "boolean",
                "default": false,
                "description": "Discloses a paid partnership with a third party. Cannot be private."
              },
              "ai_generated": {
                "type": "boolean",
                "default": false,
                "description": "Adds TikTok's AI-generated content label (post_info.is_aigc)."
              },
              "auto_add_music": {
                "type": "boolean",
                "default": true,
                "description": "Photo posts: let TikTok add music."
              },
              "photo_cover_index": {
                "type": "integer",
                "minimum": 0,
                "default": 0,
                "description": "Photo posts: which image is the cover."
              },
              "as_draft": {
                "type": "boolean",
                "default": false,
                "description": "Send the photos or the video to the creator's TikTok inbox as a draft instead of publishing: the person opens TikTok, adds a trending sound and posts it from there. The result says delivered_to: \"inbox\" and as_draft: true. Needs a connection made with the video.upload permission."
              },
              "upload_method": {
                "type": "string",
                "enum": [
                  "max",
                  "safe"
                ],
                "description": "Videos only: the \"upload method\" editors use so TikTok leaves the export as it is. PostWire rewrites the MP4 header on the way to TikTok (nothing is re-encoded, no daily limit, files up to 1 GB streamed). max is the usual choice (what editors mean by the method); safe rewrites the movie header only. Also accepted at the top level of /api/post and /api/schedule as upload_method. When the file cannot be patched (a host without byte ranges, a fragmented MP4) the post goes out as-is and the result's notice says so."
              }
            }
          },
          "youtube": {
            "type": "object",
            "properties": {
              "privacy": {
                "type": "string",
                "enum": [
                  "public",
                  "unlisted",
                  "private"
                ],
                "description": "Default: the privacy saved for the connection (POST /api/connect/youtube/settings), else private."
              },
              "title": {
                "type": "string",
                "maxLength": 100,
                "description": "Defaults to the first line of the text; cut at 100 characters."
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Trimmed to YouTube's 500-character budget across all tags."
              },
              "thumbnail_url": {
                "type": "string",
                "format": "uri",
                "description": "Custom thumbnail (the channel must be allowed to set custom thumbnails)."
              },
              "ai_generated": {
                "type": "boolean",
                "default": false,
                "description": "Declares altered or synthetic content (status.containsSyntheticMedia)."
              }
            }
          },
          "instagram": {
            "type": "object",
            "properties": {
              "post_type": {
                "type": "string",
                "enum": [
                  "feed",
                  "reels",
                  "story"
                ],
                "description": "feed (default: a photo is an image post, a video is a Reel), reels (needs a video) or story."
              },
              "trial_reel": {
                "type": "boolean",
                "default": false,
                "description": "Publish a Reel as a trial reel (shown to non-followers first). Falls back to a normal Reel when the account cannot use trial reels."
              }
            }
          },
          "facebook": {
            "type": "object",
            "properties": {
              "post_type": {
                "type": "string",
                "enum": [
                  "feed",
                  "reels",
                  "story"
                ],
                "description": "feed (default), reels (needs a video) or story (photo or video)."
              }
            }
          },
          "linkedin": {
            "type": "object",
            "properties": {
              "first_comment": {
                "type": "string",
                "description": "Posted as the author's first comment right after the post (where a link goes without hurting reach). A failed comment is retried later; the post is never re-sent. Also accepted as per_platform.linkedin.first_comment."
              },
              "document_url": {
                "type": "string",
                "format": "uri",
                "description": "A PDF, PPT or DOC published as a document (carousel) post."
              },
              "document_title": {
                "type": "string"
              }
            }
          },
          "bluesky": {
            "type": "object",
            "properties": {
              "alt_text": {
                "type": "string",
                "description": "Alt text for photo_url (with media, each item has its own alt)."
              },
              "first_comment": {
                "type": "string",
                "description": "One reply by the author under the post (under the last post of a thread): the place for the link. At most 300 characters. Also accepted as per_platform.bluesky.first_comment."
              },
              "thread": {
                "oneOf": [
                  {
                    "type": "array",
                    "maxItems": 9,
                    "items": {
                      "type": "string"
                    }
                  },
                  {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                ],
                "description": "Same as per_platform.bluesky.thread: the posts after the main one, or true to split a long text at 300 characters."
              }
            }
          },
          "mastodon": {
            "type": "object",
            "properties": {
              "alt_text": {
                "type": "string",
                "description": "Alt text for photo_url or video_url (with media, each item has its own alt)."
              },
              "first_comment": {
                "type": "string",
                "description": "One reply by the author under the post (under the last post of a thread): the place for the link. At most 500 characters, or the server's own limit. Also accepted as per_platform.mastodon.first_comment."
              },
              "thread": {
                "oneOf": [
                  {
                    "type": "array",
                    "maxItems": 9,
                    "items": {
                      "type": "string"
                    }
                  },
                  {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                ],
                "description": "Same as per_platform.mastodon.thread: the posts after the main one, or true to split a long text at the server's limit."
              }
            }
          },
          "x": {
            "type": "object",
            "properties": {
              "reply": {
                "type": "string",
                "description": "One more X post published as a reply under the last post of the chain: under the main post, or under the last post of per_platform.x.thread when there is one (the usual place for a link). At most 280 characters as X counts them (a link counts 23, an emoji 2); longer is refused with code bad_x_thread before anything goes out. It is an X post: 1 X credit, 10 with a link, and it counts toward the daily X limit. Also accepted as per_platform.x.reply."
              },
              "first_comment": {
                "type": "string",
                "description": "Same as reply, by the name the other networks use. reply wins when both are sent."
              }
            }
          },
          "wordpress": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "description": "Article title. Without one, an opening '# heading' of the text, else its first line (the result says so). The writer keeps it to 70 characters."
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Tag names (up to 10). Existing tags are matched by name; new ones are created when the user may (Editors, Administrators), else listed in the result's notice."
              },
              "summary": {
                "type": "string",
                "description": "The post's excerpt."
              },
              "status": {
                "type": "string",
                "enum": [
                  "publish",
                  "draft"
                ],
                "description": "publish (default) or draft: saved on the blog for review there. Default: the connection's choice (default_status). Also per_platform.<blog>.status."
              },
              "categories": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Category names (up to 10), matched or created the same way."
              },
              "featured_image": {
                "type": "string",
                "format": "uri",
                "description": "Image uploaded to the media library and set as the featured image (default: photo_url). Up to 15 MB."
              }
            }
          },
          "devto": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "description": "Article title. Without one, an opening '# heading' of the text, else its first line (the result says so). The writer keeps it to 70 characters."
              },
              "tags": {
                "type": "array",
                "maxItems": 4,
                "items": {
                  "type": "string"
                },
                "description": "At most 4; sent as lowercase letters and digits (\"Web Dev\" becomes webdev)."
              },
              "summary": {
                "type": "string",
                "description": "The article's description."
              },
              "status": {
                "type": "string",
                "enum": [
                  "publish",
                  "draft"
                ],
                "description": "publish (default) or draft: saved on the blog for review there. Default: the connection's choice (default_status). Also per_platform.<blog>.status."
              },
              "canonical_url": {
                "type": "string",
                "format": "uri",
                "description": "Where the article was first published."
              },
              "main_image": {
                "type": "string",
                "format": "uri",
                "description": "Cover image (default: photo_url)."
              },
              "series": {
                "type": "string",
                "description": "Series name."
              }
            }
          },
          "hashnode": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "description": "Article title. Without one, an opening '# heading' of the text, else its first line (the result says so). The writer keeps it to 70 characters."
              },
              "tags": {
                "type": "array",
                "maxItems": 5,
                "items": {
                  "type": "string"
                },
                "description": "Tag names, up to 5."
              },
              "summary": {
                "type": "string",
                "description": "The SEO description."
              },
              "status": {
                "type": "string",
                "enum": [
                  "publish",
                  "draft"
                ],
                "description": "publish (default) or draft: saved on the blog for review there. Default: the connection's choice (default_status). Also per_platform.<blog>.status."
              },
              "subtitle": {
                "type": "string",
                "maxLength": 150
              },
              "canonical_url": {
                "type": "string",
                "format": "uri",
                "description": "Where the article was first published (originalArticleURL)."
              },
              "cover_image": {
                "type": "string",
                "format": "uri",
                "description": "Cover image (default: photo_url)."
              }
            }
          },
          "nostr": {
            "type": "object",
            "properties": {
              "long_form": {
                "type": "boolean",
                "description": "true: publish as a long-form article (NIP-23, kind 30023) with title, summary, image and tags; false: always a note (kind 1). Default: a note, or an article past 2,000 characters."
              },
              "title": {
                "type": "string",
                "description": "Long-form only. Default: the first line."
              },
              "summary": {
                "type": "string",
                "description": "Long-form only."
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Topics (t tags), with the post's own #hashtags; up to 10."
              }
            }
          }
        },
        "additionalProperties": {
          "type": "object"
        }
      },
      "PlatformResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "Whether this network accepted the post. Also true for status \"scheduled\" (deferred for a rate limit, see deferred) and \"processing\" (Instagram or a large upload finishing on its own)."
          },
          "platform": {
            "type": "string",
            "enum": [
              "tiktok",
              "instagram",
              "youtube",
              "linkedin",
              "facebook",
              "bluesky",
              "mastodon",
              "telegram",
              "discord",
              "wordpress",
              "devto",
              "hashnode",
              "slack",
              "nostr",
              "x"
            ]
          },
          "id": {
            "type": "string",
            "description": "The published post's id on that network."
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "error": {
            "type": "string",
            "description": "Present only when ok is false."
          },
          "code": {
            "type": "string",
            "enum": [
              "not_connected",
              "too_long",
              "media_required",
              "empty_text",
              "limit_reached",
              "networks_per_post",
              "caption_is_json",
              "bad_media",
              "media_unreachable",
              "rate_limited",
              "rate_limited_deferred",
              "timed_out",
              "pending_approval",
              "bad_x_thread"
            ],
            "description": "Machine-readable reason, so a flow can branch without parsing English. rate_limited: the network asked to wait (retry_after seconds) and it could not be queued. rate_limited_deferred: the network asked to wait and this network was queued for right after the wait (ok true, status scheduled). pending_approval: the post waits for a person to approve it (202); nothing was sent to this network yet."
          },
          "held": {
            "type": "boolean",
            "description": "true when the plan's networks-per-post limit kept this network back (code networks_per_post): its version was written and not sent, and it spent nothing. Not a failure of the network."
          },
          "networks_per_post": {
            "type": "integer",
            "description": "With held: how many networks one post goes out to on the account's plan (Free: 2)."
          },
          "upgrade_url": {
            "type": "string",
            "format": "uri",
            "description": "With limit_reached or networks_per_post: a signed link to the checkout of the plan that lifts the limit (a Stripe session is created only when it is opened)."
          },
          "upgrade_plan": {
            "type": "string",
            "description": "With limit_reached or networks_per_post: the plan the upgrade_url checks out."
          },
          "status": {
            "type": "string",
            "enum": [
              "published",
              "processing",
              "scheduled",
              "unknown"
            ],
            "description": "published: live. processing: accepted, the network or PostWire is still finishing it (follow it with GET /api/post/status or the schedule_id). scheduled: deferred for a rate limit (deferred true). unknown: PostWire ran out of time before the network answered (code timed_out); check the network before posting again."
          },
          "deferred": {
            "type": "boolean",
            "description": "true when the network asked PostWire to wait longer than the request had (today: Telegram's 429 retry_after). Nothing was sent yet and nothing is lost: this network was queued as a scheduled post due right after the wait (schedule_id, run_at). It is counted, logged and sent to your webhooks when it goes out. Not counted in posted."
          },
          "retry_after": {
            "type": "integer",
            "description": "With rate_limited or rate_limited_deferred: the seconds the network asked to wait."
          },
          "schedule_id": {
            "type": "string",
            "format": "uuid",
            "description": "With deferred, or with a large upload finishing later: the scheduled post to follow with GET /api/schedule/{id}. An X thread or reply sent with /api/post also gets one: its progress is kept on that row (GET /api/schedule/{id})."
          },
          "run_at": {
            "type": "string",
            "format": "date-time",
            "description": "With deferred: when the queued network goes out."
          },
          "notice": {
            "type": "string",
            "description": "Something the caller should know about a successful result: text trimmed to fit, a deferral, a fallback PostWire used."
          },
          "thread_url": {
            "type": "string",
            "format": "uri",
            "description": "A thread (X, Bluesky, Mastodon) or an X reply: the link to the first post."
          },
          "thread": {
            "type": "object",
            "description": "X with per_platform.x.thread or options.x.reply. The result is ok once the first post is out, whatever happens to the rest. When X refuses a later post, the posts before it stay published and the rest waits (status pending): PostWire posts it alone on later runs (at least 60 s apart, at most 3 passes), each a reply to the last post that went out — the first post is never sent again and no post goes out twice. After 3 failed passes status is failed, error is X's reason and the credits of the posts never sent are returned. When X does not answer a post, nobody can tell whether it exists, so the chain stops there (status unknown): that post's credits stay used, the others are returned. Bluesky and Mastodon (per_platform.<network>.thread): status complete, or partial when the network refused a later post — the posts before it stay published (posts), failed_post and error say which one and why, and not_posted lists the rest with their text; they are not retried.",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "complete",
                  "partial",
                  "pending",
                  "failed",
                  "unknown"
                ]
              },
              "posts": {
                "type": "array",
                "description": "Bluesky and Mastodon: the posts that went out, in order: { n, role (main or thread), id, url }.",
                "items": {
                  "type": "object"
                }
              },
              "failed_post": {
                "type": "integer",
                "description": "Bluesky and Mastodon, status partial: the post the network refused (2 = the first after the main one)."
              },
              "total": {
                "type": "integer",
                "description": "Posts in the chain (main + thread + reply)."
              },
              "posted": {
                "type": "integer",
                "description": "Posts out so far."
              },
              "url": {
                "type": "string",
                "format": "uri",
                "description": "The first post."
              },
              "tweets": {
                "type": "array",
                "description": "The posts that went out, in order.",
                "items": {
                  "type": "object",
                  "properties": {
                    "n": {
                      "type": "integer"
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "main",
                        "thread",
                        "reply"
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              },
              "pending": {
                "type": "array",
                "description": "The posts still to go out (status pending), in order.",
                "items": {
                  "type": "object",
                  "properties": {
                    "n": {
                      "type": "integer"
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "thread",
                        "reply"
                      ]
                    },
                    "text": {
                      "type": "string"
                    }
                  }
                }
              },
              "not_posted": {
                "type": "array",
                "description": "status failed or unknown: the posts that will not go out.",
                "items": {
                  "type": "object"
                }
              },
              "retries": {
                "type": "integer",
                "description": "Retry passes used."
              },
              "max_retries": {
                "type": "integer",
                "description": "3."
              },
              "retry_pending": {
                "type": "boolean",
                "description": "A later run will try the pending posts."
              },
              "error": {
                "type": "string",
                "nullable": true,
                "description": "X's reason for the last refusal."
              },
              "code": {
                "type": "string",
                "nullable": true
              },
              "credits_returned": {
                "type": "integer",
                "description": "X credits returned for posts that will not go out."
              }
            }
          },
          "first_comment": {
            "type": "object",
            "description": "LinkedIn, Bluesky and Mastodon with a first_comment: { ok: true, id, url? } once it is out, or { ok: false, error, text, retry_pending } — the post is out either way and is never sent again; a pending comment is posted alone on a later run (at least 60 s apart, at most 3 tries; from POST /api/post the result's schedule_id is the row that keeps it). On X the first comment is the reply in thread.",
            "properties": {
              "ok": {
                "type": "boolean"
              },
              "id": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri",
                "nullable": true
              },
              "error": {
                "type": "string"
              },
              "retry_pending": {
                "type": "boolean"
              }
            }
          },
          "x_credits": {
            "type": "object",
            "description": "X: the credits this post used: { used, from_plan, from_topup, left, plan_left, topup_left }; with a thread or reply also reserved (the whole chain), held (still reserved for pending posts), returned and x_posts. An internal account: { used: 0, paid_by: \"house\" }."
          }
        }
      },
      "PublishResponse": {
        "type": "object",
        "properties": {
          "posted": {
            "type": "integer",
            "description": "How many networks published (or accepted and are finishing). Networks deferred for a rate limit are not counted here: see deferred."
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlatformResult"
            }
          },
          "notice": {
            "$ref": "#/components/schemas/QuotaNotice"
          },
          "held_networks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Networks the plan's networks-per-post limit kept back in this request (each also has held true in results)."
          },
          "networks_per_post": {
            "type": "integer",
            "description": "Present with held_networks: networks one post goes out to on this plan."
          },
          "held_message": {
            "type": "string",
            "description": "One sentence to relay to the user about the networks held back."
          },
          "upgrade": {
            "type": "object",
            "description": "When a limit stopped a network: { plan, name, price_usd_month, unlocks, url, reason }."
          },
          "upgrade_message": {
            "type": "string",
            "description": "The upgrade offer in one sentence, with the link."
          },
          "deferred": {
            "type": "array",
            "description": "Networks queued for right after a rate-limit wait: [{ platform, schedule_id, run_at, retry_after }].",
            "items": {
              "type": "object",
              "properties": {
                "platform": {
                  "type": "string"
                },
                "schedule_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "run_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "retry_after": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "QuotaNotice": {
        "type": "object",
        "description": "Present only when the account is close to its monthly allowance.",
        "properties": {
          "code": {
            "type": "string",
            "example": "quota_running_out"
          },
          "message": {
            "type": "string"
          },
          "used": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "left": {
            "type": "integer"
          },
          "publishes_left": {
            "type": "integer",
            "description": "Whole publishes left at the current network count."
          },
          "runs_out_on": {
            "type": "string",
            "format": "date"
          },
          "resets_on": {
            "type": "string",
            "format": "date"
          },
          "upgrade_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        }
      },
      "GenerateRequest": {
        "type": "object",
        "required": [
          "prompt",
          "platforms"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "maxLength": 4000,
            "description": "The idea to communicate."
          },
          "platforms": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "tiktok",
                "instagram",
                "youtube",
                "linkedin",
                "facebook",
                "bluesky",
                "mastodon",
                "telegram",
                "discord",
                "wordpress",
                "devto",
                "hashnode",
                "slack",
                "nostr",
                "x"
              ]
            }
          },
          "media_url": {
            "type": "string",
            "format": "uri"
          },
          "brand_voice": {
            "type": "string",
            "maxLength": 1500
          }
        }
      },
      "ScheduleRequest": {
        "type": "object",
        "required": [
          "platforms",
          "run_at"
        ],
        "properties": {
          "platforms": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "tiktok",
                "instagram",
                "youtube",
                "linkedin",
                "facebook",
                "bluesky",
                "mastodon",
                "telegram",
                "discord",
                "wordpress",
                "devto",
                "hashnode",
                "slack",
                "nostr",
                "x"
              ]
            }
          },
          "text": {
            "type": "string"
          },
          "run_at": {
            "type": "string",
            "description": "When to publish: an ISO 8601 time in the future (up to 365 days), or \"next_slot\" for the brand's next free queue slot. A post goes to the earliest slot that every one of its networks has and that none of them already uses for another waiting (queued, held or publishing) post of the same brand. When its networks share no slot, it goes to the earliest slot of any of them that is free for all. Slots less than 2 minutes away are skipped; the search looks 28 days ahead. The answer then carries slot { run_at, timezone, local, shared }.",
            "example": "next_slot"
          },
          "video_url": {
            "type": "string",
            "format": "uri"
          },
          "brand_id": {
            "type": "string",
            "format": "uuid"
          },
          "label": {
            "type": "string",
            "maxLength": 120
          },
          "timezone": {
            "type": "string",
            "description": "With run_at next_slot: the IANA timezone to read the slots in when the brand has none saved (e.g. America/Lima). Default UTC. Not stored with the post."
          }
        }
      }
    }
  }
}
