{"openapi":"3.1.0","info":{"title":"MindThread API","version":"1.22.0","contact":{"name":"MindThread","email":"contact@ultralab.tw","url":"https://mindthread.tw/developers"},"description":"Threads automation for AI agents: generate posts, publish text / image / carousel / video, manage the content library and schedules, configure cloud patrol (keyword-driven auto-replies on other people's posts, optionally review-before-reply), read analytics and patrol effectiveness, and let the platform enforce the account's content rules in code: length, CTA, hashtags, banned phrases, and `facts` (every number in generated or submitted text must come from the account's fact list). Agents without a public endpoint can poll GET /events instead of registering webhooks. Clients (2026-11-04): hosted MCP at https://mindthread.tw/api/mcp (tools are defined on the server); mindthread-mcp, a stdio bridge to it (`npx -y mindthread-mcp`); mindthread-cli, the `mindthread` command with `--json` and stable exit codes (`npx mindthread-cli`), with a skill for OpenClaw / ClawHub and Claude Code. `x-clients` lists the versions these docs describe; setup for Claude Code, Cursor and OpenClaw: https://mindthread.tw/developers#clients. All times are ISO 8601; the daily quota resets at 00:00 Asia/Taipei. Live quota is per API key / plan; sandbox quota is one pool per member (see GET /me and the X-RateLimit-* headers). Keys: create in the web app (Settings → API keys). `mt_test_` keys return mock data, set `test_mode:true` and `persisted:false` on writes, and never mutate live account state; if an endpoint is not sandboxed yet it returns `test_mode_unsupported` instead of writing. `mt_live_` keys act for real. Scheduling: the canonical time field is `publish_at` (ISO 8601 with offset) on every scheduling endpoint; `schedule_at` and `scheduled_at` are accepted as deprecated aliases and responses echo `publish_at` (plus a deprecated `scheduled_at` mirror). Envelope: success is `{ ok: true, request_id, data, ...}`, errors are `{ error: { code, message, request_id, ...structured fields } }`; every response also sets `X-Request-Id` (send your own to have it echoed). mt_test_ reads are marked `data_source: live_readonly`. Write responses carry a top-level `actor { type: \"key\", key_id }` (which key did it; see components.schemas.Actor; the human-chosen key label is only returned by `GET /me`). Rate limits (1.7.0): every authenticated response sets `X-RateLimit-Limit` / `X-RateLimit-Remaining` / `X-RateLimit-Reset` (epoch seconds, next 00:00 Asia/Taipei), `X-RateLimit-Policy` (`<daily>;w=86400, <per-minute>;w=60`) and `X-RateLimit-Scope` (who shares the counter: `key` for live, `user` for sandbox; it is a quota partition, not a permission scope); sandbox responses add `X-RateLimit-Sandbox: true`. Live: the plan's daily limit per key plus 120 requests/minute per key. Sandbox: all `mt_test_` keys of one member share 500 units/day (does not consume the plan quota) plus 30 requests/minute per member. On a 429 the X-RateLimit-* headers still describe the daily pool; which limit was hit is in the body: code `rate_limit_exceeded` with `window` (daily | minute | global_sandbox | concurrency; named window, not scope, because scope means a permission from 1.8.0), `pool`, `limit`, `used`, `reset_at`, `retry_after_seconds`, plus a `Retry-After` header. `concurrency` means too many simultaneous calls on one quota counter: retry after 1 second (that 429 has no X-RateLimit-Remaining). MCP tool results that consumed quota carry the same numbers in `_meta[\"mindthread.tw/rate_limit\"]` (disable_this_key and 401 results have none), and an MCP error keeps the ErrorEnvelope in `structuredContent`. The one exception is `POST /keys/current/disable`: it consumes no quota and sends no X-RateLimit-* headers. A 401 never carries X-RateLimit-* headers (no quota is checked before authentication succeeds). Polling costs quota (2026-11-02): every call counts against the daily pool, including GET /events and GET /patrol/cloud/pending polls that return nothing. Suggested intervals when you poll one endpoint: free 50/day every 30 minutes (48 calls), 200/day every 15 minutes, 500/day every 5 minutes, 1,000/day every 2 minutes, 5,000/day every minute; poll two endpoints and each needs twice the interval (free: /events and /patrol/cloud/pending every 60 minutes each). GET /patrol/cloud/pending every 15 minutes needs at least the 200/day tier. Prefer POST /webhooks (patrol.pending, post.failed, token.expiring) when you have a public https endpoint. On a daily 429, stop until reset_at (Retry-After is the same number of seconds); every call before then gets 429 again. The daily 429 body also carries suggested_poll_interval_seconds. Key identity: `GET /me` returns `key { id, label, prefix, last4, kind, status, scopes, legacy, scopes_enforced, agent_name, agent_url, created_at, last_used_at }` (components.schemas.Key), `actor { type, key_id, label }` (same object as on write responses, plus the label) and `actor_id` (`api:<key_id>`). `prefix` is `mt_live` or `mt_test` (no trailing underscore). An empty label reads as `legacy-<last4>`. `last_used_at` is the last recorded use before this request (recorded at most once a minute). Keys created before scopes existed report `legacy: true`, `scopes_enforced: false` and allow everything; every other key has `scopes_enforced: true`. `agent_name` / `agent_url` are what the owner entered in Settings (null when empty); no API key can set them. Key metadata is only on `GET /me`: `/keys`, `PATCH /keys/{id}` and `/usage` belong to the web app session and answer an API key with 401 `session_required`. Key management (1.8.1): the owner changes an existing key in place with `PATCH /keys/{id}` (web app session only, `x-audience: human`): a preset, single permissions, label, agent_name and agent_url. Widening needs a sign-in within 24 hours; team members can change only keys they created, to standard or stricter. Setting a permission to deny cancels that key's pending approvals for it (`cancel_reason: permission_set_to_deny`); an approval that slipped through can no longer be approved (decide answers 409 `approval_permission_denied`). `insufficient_scope.fix` names the key (mt_live_...<last4>), the permission and the buttons to press in Settings → API keys; no new key is needed. Errors (standard envelope): 400 `nothing_to_update`, `invalid_preset`, `invalid_scopes`, `invalid_label`, `invalid_agent_name`, `invalid_agent_url`, `invalid_request`; 401 `reauth_required` (widening, including creating a live key wider than standard, needs a sign-in within 24 hours that was not revoked; `reason` sign_in_too_old or sign_in_revoked); 403 `owner_only`, `team_scope_limit`, `workspace_revoked`; 404 `key_not_found`; 409 `key_disabled`, `key_changed` (send `if_scopes_updated_at` from GET /keys; the permissions changed since). Cancelled approvals carry `cancel_reason`: key_revoked, key_disabled_self, permission_set_to_deny; other values are support cancellations. Kill switch: `POST /keys/current/disable` permanently disables the key that calls it (no body, no quota, not subject to the per-minute limit, works for live, test and legacy keys; there is no re-enable). The next request with that key is rejected (promised within 5 seconds; there is no key cache today) with 401 `key_disabled` carrying `key_id` and `disabled_at`; a key revoked in Settings answers the same way. Requests already in progress are not interrupted. Disabling stops API requests only; webhooks, queued posts and cloud patrol settings created with this key keep running. Review them in Settings. Any other authentication failure stays 401 `unauthorized`. Treat both 200 and 401 `key_disabled` from the disable call as \"stopped\". The 200 also carries `cancelled_approvals` and `cancelled_approval_ids` (1.8.1): the approvals this key was still waiting on, now cancelled. To pause posting instead of killing the key, the human uses the global pause in Settings. On `mt_test_` keys, POST /library and PATCH /library/{id} skip judge_claims and POST /accounts/connect-link returns a mock link that connects nothing. Permissions (1.8.0): every non-legacy key has allow | ask | deny per permission (x-scopes; each operation names its permission in `x-scope`, and `x-scope-alt` when the body decides; every operation a permission can refuse lists InsufficientScopeError and, when it can ask, ApprovalRequiredError under 403). deny answers 403 `insufficient_scope` { code, message, required, mode, have, fix, request_id } with header `X-Required-Scope` (MCP clients read error.required[0]); nobody is asked. ask validates the request first (a request that would fail returns its normal error and creates nothing), then creates an approval, notifies the owner (bell, push, email) and answers 403 `approval_required` { code, message, scope, approval_id, approval, request_id } with approval = { id, status, scope, key_id, test_mode, action { method, route, account_id, account_username, summary }, created_at, expires_at, decided_at, decision, result, human_url, human_message, poll, event, execution }: hand human_url or human_message to the human, never open it yourself, never resend; the server executes the request after the owner confirms at /approve/{id}, stores the outcome in `result` (GET /approvals/{id}) and emits `approval.decided`. content:publish_now also covers POST /experiments (variants publish at once) and any publish_at less than 30 minutes away; POST /library without status draft and new text on a queued item need content:schedule. POST /content/generate-and-schedule never waits for approval: with its permission on ask it answers 403 `approval_not_supported` (generate first, then publish the text). Resending a decided request: 409 `approval_already_executed` (this exact request ran within 24 hours; read error.approval.result, do not resend), 409 `approval_in_progress` (confirmed and running), 409 `approval_denied` (the owner denied it within 24 hours). Other refusals: 400 `approval_unsupported_field` (approvals never store secrets), 413 `approval_payload_too_large`, 400 `invalid_idempotency_key` (keys starting with approval: are reserved). A failed execution has result.error.code, including `approval_payload_changed` (library items changed after the owner was asked; nothing ran), `approval_base_changed` (1.8.3: a settings field the request touches changed after the owner was asked; nothing ran, read the settings again and resend) and `execution_unknown` (the outcome was not recorded; check before retrying). A route missing from the permission table answers 403 `scope_unmapped` (a server bug). Approvals expire after 24 hours; at most 10 pending per key and 50 per member per day (test keys 20 more), otherwise 429 `approval_flood` with `window: approvals`. Deciding needs the owner signed in to the web app (`human_required` for keys, `owner_only` for team members, `reauth_required` for a revoked sign-in or for always after 24 hours, 409 `approval_not_pending` / `approval_expired` / `approval_key_revoked`). approval.decided carries a result summary only (ok, http_status, post_id, threads_post_id, error.code); on GET /events the other live keys of the same member see only approval_id, status, decision and, for a cancelled approval, cancel_reason of a live approval; approvals of a test key are sandbox events (1.8.2) that no other key reads. Test keys default to open; set one permission to ask on a test key to rehearse the whole flow (the approved request runs as a mock). For a test key GET /events returns only that key's own sandbox events, including its approval.decided (1.8.2). Observability (1.8.2): GET /keys/current/usage returns the calling key's own usage (summary { calls, units, errors, by_endpoint[] } counted from 00:00 Asia/Taipei, and recent[] { request_id, endpoint, status, units, at } newest first with cursor paging; days 1..30, limit 1..100, cursor = next_cursor of the previous page). It needs no permission and consumes no daily quota; at most 10 requests per minute per key on this endpoint, on top of the usual per-minute limit. No key can read another key's records. Every request a key makes after the server identifies it is recorded, including 400, 403 and 429 refusals. Not recorded: 401 unauthorized, 401 key_disabled, answers given before the key is checked (405 method_not_allowed, 401 session_required), and the validation run before an approval is created. 429 answers and refusals made before the quota check (400 invalid_idempotency_key, 403 scope_unmapped) are recorded about once per key per minute on each server, so those counts are a lower bound. Records are written after the answer is sent, best effort: one can occasionally be missing, so summary and recent may differ slightly. Sandbox events: in the sandbox, publishing now (POST /content/publish or POST /content/generate-and-schedule with publish_now, POST /content/publish-thread, POST /experiments) records post.published, approving a pending cloud reply records patrol.reply, and an approval this key created records approval.decided when it is decided, cancelled or expires. They are real records in the event store (data carries test_mode:true, key_id, persisted:false, request_id), readable only by that test key's GET /events for 7 days. Sandbox events are never delivered to webhooks and never shown to live keys. Other sandbox writes (for example scheduling, library, settings) record no event. From 1.8.2, publishing now with a live key through POST /content/publish or POST /content/generate-and-schedule (publish_now) also emits post.published or post.failed (source api_publish or api_generate_and_schedule); webhook deliveries can repeat, so dedupe by post_id. X-Request-Id values starting with apr_exec_ are reserved for requests the server runs after the owner confirms; a caller's apr_exec_ value is replaced by a server-generated id. Content rules and settings approvals (1.8.3): From 1.8.3, content_rules are checked on every API path that writes or schedules text: POST /content/generate, /content/publish, /content/schedule, /content/generate-and-schedule, /content/publish-thread, /content/generate-thread, /experiments, POST /library and PATCH /library/{id}. With enforce:block a violation answers 422 content_rules_violated and nothing is written, scheduled or published; with enforce:warn (the default) the request succeeds and carries rule_violations (/experiments does not report them). Every path checks the fixed rules (max_chars, min_chars, forbid_cta, forbid_hashtags, banned_phrases, facts, forbid_causal_claims, one_fact_per_post, mention_limits). The model review (judge_claims) and the recently used numbers check (repeated_fact) run only on POST /content/generate, POST /library and PATCH /library/{id}; every other path, including the check right before a scheduled post publishes, runs the fixed rules only. Matching ignores invisible format characters such as zero-width spaces, compares banned_phrases and mention_limits after Unicode NFKC and case folding, and skips a number written next to - : / only when it is part of a date, time or range such as 2026-09-25, 12:30 or 5-10 (so 100000/month now counts). A topic_tag is checked against banned_phrases too; forbid_hashtags covers #hashtags in the text, and on an account with it on, posts from the API and the library go out without a Threads topic tag (topic_tag comes back null). Stored banned phrases are normalized the same way and capped at 100 characters, and invisible characters are removed from facts. error.violations is RuleViolation[] ({ rule, detail }) for one text (/content/publish, /content/schedule, /content/generate-and-schedule, PATCH /library/{id}); one RuleViolation[] per post for /content/generate; [{ index, rule_violations }] for /library and /content/publish-thread (index counts from 0 in the request array) and for /content/generate-thread (index is the thread_parts[].index of the answer, from 1); [{ formula, rule_violations }] for /experiments. Test keys get the same 422: /content/schedule and /content/publish-thread check the submitted text, and the two generating paths check their mock text, which contains the topic, so a banned phrase in the topic rehearses the refusal. The mock text is checked only against banned_phrases, forbid_cta and forbid_hashtags, because length and number rules need real text: a test key can still rehearse a successful call, and an ask permission on /content/generate-thread still creates its approval. /content/generate-and-schedule and /content/generate-thread now put the rules in the prompt and regenerate a violating draft (up to 3 model calls with enforce:block, 2 with warn), like /content/generate; model_calls says how many were made. Posts scheduled through the API are checked again right before they publish, against the rules in force at that moment: with enforce:block a violating post is not published but moved to draft with held_reason and rule_violations (GET /schedules?status=draft), the owner is notified in the web app, and post.failed with error content_rules_violated is emitted; with warn it publishes and the violations are recorded. Not checked: posts written in the web app's compose page, cloud patrol replies, auto-replies to comments on the account's posts, and browser patrol (extension) replies and posts. Behavior change: scheduling or threading text that violates an enforce:block account through these paths used to succeed and now answers 422, and such a post already in the queue is held as a draft instead of published. Also a behavior change: PATCH /accounts/{id}/settings with a live key (legacy keys included) used to merge content_rules key by key and now replaces the object, so rules left out of the body are removed, and the stricter matching above can refuse text that used to pass. PATCH /accounts/{id}/settings now really replaces content_rules as a whole on live keys, as documented: before 1.8.3 a live write merged the object key by key, so rules left out of the body silently stayed. A settings approval (PATCH /accounts/{id}/settings waiting for the owner) now shows the owner every field the body touches as current and proposed value, using the value the server would actually write, including fields that are not guardrails such as persona and schedule_times; content_rules is itemized down to the added and removed facts and banned phrases and the enforce change. A fact that differs only in spaces is listed too, with the numbers the change newly allows. The comparison is capped at 60,000 characters: long current values are shortened (truncated:true), and a request whose comparison still does not fit answers 413 approval_payload_too_large. A facts change counts as loosening (accounts:guardrails) when a fact is new ignoring spaces, when the set of numbers the facts allow grows (a space inside 101563 allows 10 and 1563), or when a new Chinese quantity phrase appears. Such an approval also records the current value of every field the body touches. If any of those fields changes before the request runs, it is not run: the approval turns failed with result.error.code approval_base_changed as soon as it is read, listed or decided (deciding answers 409 approval_base_changed, checked in the same transaction, and always is not applied), or right before it runs. Changes to fields the body does not touch do not matter. Read the settings again and resend: the same body then gets a new approval. Settings approvals created before 1.8.3 have no recorded values and end the same way when read, listed or decided. Guardrail versions, history and rollback (1.9.0): Shared policy, minimal version: the guardrails on the account are the active policy for every key and automation on it; a pending settings approval is the desired (proposed) change; the owner confirming it applies it. There is no separate policy object or proposal endpoint yet. From 1.9.0, GET /accounts/{id}/settings returns data.guardrails: etag (an opaque version of the five guardrails: content_rules, review_before_publish, auto_reply_enabled, video_autopilot, enabled), covers, last_change, pending, enforced_on and not_enforced_on. PATCH /accounts/{id}/settings accepts an optional if_match with that etag. It is compared only on the guardrails the body sends, content_rules as one part and each of the four switches on its own, so a change to another part does not refuse the request. If a sent part changed since you read it, the answer is 412 guardrails_changed with current_etag, changed, current (the five current values) and last_change, and nothing is written: read again, apply your change to the current content_rules (it is replaced as a whole) and resend. Without if_match the last writer wins, as before, and every change is recorded. dry_run:true only previews: it needs the read permission, creates no approval and writes nothing, and each key can dry-run at most 10 times a minute (429 rate_limit_exceeded). It answers changed, loosened, tightened, required_scope, your_mode, outcome (apply, approval_required or denied), etag_now and impact: how many of the first 200 queued library items, in publishing order, the new content_rules would newly flag, checked with the fixed rules only (no judge_claims, no scheduled posts). Every change to a guardrail made through the API, by an approval or by the system writes a revision that is never edited or deleted: GET /accounts/{id}/guardrails/history (read permission, newest first, limit up to 50, before=next_before for the next page) lists id, at, source (api, approval, rollback or system), actor, mine, changed_fields, loosened, tightened, gap_before, before, after and restore_body; approval_id, request_id and reason only on revisions your own key made. PATCH accepts reason (up to 200 characters, plain text, links removed) to explain a change. gap_before:true means the guardrails changed outside the record since the previous revision (in the web app, or before 1.9.0); those changes are not recorded by name yet. A system revision (actor type system) records the server pausing an account (its authorization failed, it is blocked or publishing keeps failing) or turning it back on after a reconnect or token refresh, with system_reason; it cannot be undone. Test keys read live revisions and write none. The owner can undo one revision: POST /accounts/{id}/guardrails/rollback { revision_id, if_match } (web app session only, x-audience human; an API key gets 401 session_required, a team member 403 owner_only; in the web app the owner presses the undo button in the change history on the page /accounts/{id}/guardrails). It restores the fields that revision changed to their previous values, only while they still hold the values that revision wrote; otherwise it answers 409 rollback_conflict with later_revision_id (the later revision that changed them) or changed_outside_record:true, and nothing changes. If those fields already hold their previous values, it answers 200 with already_rolled_back:true and writes nothing. An undo is recorded as a revision with source rollback. An undo that loosens a guardrail needs a sign-in within 24 hours (401 reauth_required). To undo through the API instead, send restore_body with if_match as a normal PATCH: loosening still needs the owner. Loosening is now decided field by field from one comparison table that every content_rules field must be declared in: a difference that is not proven stricter counts as loosening, and a change that loosens one rule and tightens another counts as loosening. The first facts list on an account that had none is not loosening, because numbers were not checked before; the revision records it as facts_created. The same comparison decides the permission, the approval preview, and loosened and tightened in revisions and dry runs. Writes are transactional: a settings approval that runs after the owner confirmed checks its recorded values again in the same transaction as the write, and a request that became loosening after the permission check (the guardrails changed in between) answers 412 guardrails_changed instead of writing. 422 content_rules_violated now carries guardrails_etag, the version of the rules that refused the text; a scheduled API post held at publish time carries held_guardrails_etag next to held_reason (GET /schedules) and guardrails_etag in post.failed, and a queued library item held at publish time carries held_guardrails_etag next to held_reason (GET /library). When a guardrail is loosened without the owner pressing allow (the key has accounts:guardrails on allow, or it is a legacy key), the owner gets an in-app notification (no email); more loosening by the same key on the same account within the same 30 minutes updates that notification instead of adding another. content_rules can only be changed through PATCH /accounts/{id}/settings: the web app's direct database writes can no longer change it (the web app never wrote it), and an account that has had content_rules cannot be deleted and created again under the same id from the web app, so every change is recorded. Event stream across live and sandbox: a mt_live_ key reads the member's live events on GET /events and never sandbox ones; a mt_test_ key reads only its own sandbox events. Build against a test key, then switch keys and start the live cursor fresh (omit since, or use the time you switched): a latest_at from one stream means nothing in the other, and the two are never merged. Webhooks carry live events only. From 1.9.0 every webhook body is { id, event, timestamp, data }, and id is the id GET /events gives the same event. A webhook delivery can repeat, so dedupe by id, on webhooks and on GET /events alike. post_id says which post an event is about, but one post can fail more than once, so do not dedupe by post_id alone. GET /events returns the newest events after since, up to limit (at most 200): when count equals limit, or when you filter by types, older events after since may have been skipped, so poll more often or with a larger limit. Key boundaries: a key only sees and acts on the Threads accounts of the member it belongs to (another member's account answers 403 forbidden). A key a team member creates in the owner's workspace belongs to the owner's member. For a third-party evaluation, create both the suite key and the disposable key under the same member as the accounts being evaluated, otherwise GET /accounts is empty and every account id is refused. The suite key is the long-lived key the evaluation runs everything with and is never disabled; a disposable key exists only for destructive checks such as POST /keys/current/disable and is thrown away afterwards. Each key reads only its own approvals and usage, so check a disposable key's results with that key before disabling it. Publishing in progress and unknown results (1.9.1): From 1.9.1 the publisher marks a scheduled post or a queued library item as publishing right before it sends it to Threads, and records published, partial or failed when it is done. While an item is publishing it can no longer be changed: PATCH /library/{id} and POST /library/{id}/approve answer 409 publishing_in_progress, POST /library/bulk reports publishing_in_progress for that item on archive, approve and queue, and DELETE /schedules/{id} answers 409 publishing_in_progress. Read it again in a minute. PATCH /library/{id} writes in a transaction: when the item's status changes between the read and the write, nothing is written and it answers 409 status_changed (read the item again and retry), or 409 publishing_in_progress when the item became publishing. If a publishing run is cut off before it records the result, the item is moved to draft, usually 15 to 20 minutes later, and is never resent automatically, because it may already be on Threads. It then carries held_reason publish_result_unknown, ahead of any other held reason, and reclaimed: true (GET /library?status=draft, GET /schedules?status=draft), and the owner is notified in the web app. An API key cannot put such an item back in the queue: POST /library/{id}/approve and PATCH /library/{id} with status queued answer 409 publish_result_unknown, and POST /library/bulk reports publish_result_unknown for it on approve and queue. Archiving it first does not make it queueable. Ask the owner to check Threads: the owner re-queues it in the web app only if it was not posted, or deletes it. Behavior change: DELETE /schedules/{id} on a post that is being published used to answer 400 cannot_cancel and now answers 409 publishing_in_progress, and GET /schedules now reports a post whose publish result is unknown with held_reason publish_result_unknown and reclaimed: true instead of held_reason null. PATCH /library/{id}, POST /library/{id}/approve and POST /library/bulk can answer the new codes above. Guardrail errors (1.9.0): 412 `guardrails_changed` (if_match does not match, or the request became loosening after the permission check; re-read and resend), 400 `invalid_if_match`, `invalid_reason`, `invalid_dry_run`, 404 `revision_not_found` (history before, or a rollback of an unknown revision), 409 `rollback_conflict` (owner rollback only: the fields changed again after that revision). Account availability (1.9.1): POST /content/publish (publish_now), POST /content/publish-thread and POST /content/generate-and-schedule (publish_now) answer 409 `account_unavailable` when the account's healthStatus is blocked or token_error: the platform does not publish through that account right now. The message says which. token_error: the owner reconnects the account in the web app and the code clears immediately. blocked: wait for the platform block to clear (re-checked every 6 hours). Do not retry in a loop. Scheduling with publish_at is still accepted, but if the account is still unavailable at publish time the scheduled post fails (post.failed) instead of publishing. The MCP tool publish returns the same code as a tool result with isError:true. In-channel approval (1.10.0): From 1.10.0 the owner can decide from the notification itself: a one-time link (https://mindthread.tw/a/{lid}, with the secret in the URL fragment, 10 minutes by default, single use, bound to the approval, the owner and the allowed decisions) is sent to the owner's verified channels (email and web push in 1.10.0; LINE follows) once the owner has turned approval links on in Settings. API keys never receive, see or need that link: keep handing human_url and human_message to the human as is, never ask the human to paste the link or any code to you, and never open it yourself. New read-only fields on Approval: tier (t1, t2 or t3), channels_notified (type and status per channel, never an address), decision_via (web, link, push, client_attested or null), decision_channel (email, line, web_push or null), decided_by ({ type: \"human\", role: \"owner\" } or null) and step_up ({ method: none | session | passkey | code } or null); settings approvals also carry guardrails_etag_at_request. approval.decided carries tier, decision_via, decision_channel, decided_by and step_up_method (the same method as a plain string). Approvals created before 1.10.0 carry null in these fields, except decided_by, which is derived from the decision and reads { type: \"human\", role: \"owner\" } whenever the owner decided; every decision made before 1.10.0 was made on the web. always (allow this permission from now on) is still decided only at /approve/{id}, signed in; a link can only allow once or deny. No behavior change for keys: approval_required stays HTTP 403 with the same shape, human_url still points to /approve/{id}, polling GET /approvals/{id} and approval.decided work as before; only the wording of human_message changes to name the channels the link reached. The link endpoints (POST /a/{lid}/view, /a/{lid}/decide, /a/{lid}/step-up/code, /a/{lid}/reissue and /a/{lid}/deny-all) and the owner settings endpoints (/notification-channels, /approval-settings and POST /approvals/{id}/links/revoke) are for humans: an API key gets 401 session_required on the settings endpoints, and the link endpoints ignore an API key entirely (a missing or wrong secret answers 404 approval_link_not_found, the same answer as an unknown link). Warnings (1.17.0): scheduling responses carry `data.warnings[]`, a list of `{ code, message, message_zh, detail }` that never blocks the request. `off_hours`: an explicit publish_at falls outside the hours this account usually posts in its audience time zone (hours with posts in the last 60 days plus its schedule_times; at night 00:00-05:59 it fires 2 hours from the nearest usual hour, in the day 4 hours; with no data at all only night times fire). `stale_time_reference`: the text has words tied to the day it was written (昨天, 上週, 剛剛, 今晚, yesterday, last week, just now, tonight...) and it publishes on a later day (a later week for week words, 6 hours or more for just-now words); a bare 今天/today does not count. Show `message` (or `message_zh`) to the human before confirming; codes are stable, messages may be reworded. `changed_since_last_viewed` (1.18.0): the content (text, media, or a scheduled post's time) differs from the last version the account owner saw on the web, or, if the owner never saw it, from the last version read through the API; detail lists removed[] and added[] sentences, previous_text and current_text. Writes are not views, so after you edit a draft the owner has not seen your change yet: show the human the difference before releasing it. Analytics: `GET /analytics/insights` requires `account_id`; the literal `all` gives the organization-wide view (`scope: organization`). Auto-patrol on the user's own browser (海巡 extension) is a disclosed platform-ToS grey area and is not exposed here; cloud patrol runs through the official API with conservative quality gates."},"servers":[{"url":"https://mindthread.tw/api/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Authorization: Bearer mt_live_... (or mt_test_... for mock mode)"},"firebaseIdToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"The MindThread web app session (Firebase ID token of the signed-in owner). Only /approvals, /approvals/{id}/decide, PATCH /keys/{id}, /accounts/{id}/guardrails/rollback, /notification-channels, /approval-settings and /approvals/{id}/links/revoke use it (x-audience human); an API key gets 401 session_required there. The one-time link endpoints (POST /a/{lid}/…) take no credential at all: the secret in the body is the proof, and the same header carrying a Firebase ID token only serves as the session step-up"}},"schemas":{"SuccessEnvelope":{"type":"object","required":["ok","request_id","data"],"properties":{"ok":{"type":"boolean","const":true},"request_id":{"type":"string","description":"Same value as the X-Request-Id header"},"data":{"type":"object"},"test_mode":{"type":"boolean","description":"Present on mt_test_ responses"},"persisted":{"type":"boolean","description":"mt_test_ writes: false (nothing written), except POST /keys/current/disable, which really disables the calling test key and says true"},"data_source":{"type":"string","enum":["live_readonly","mock","sandbox"],"description":"mt_test_ reads: live_readonly (live state, read only), sandbox (GET /events: this test key's own sandbox events, 1.8.2)"},"usage":{"type":"object"}}},"ErrorEnvelope":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","description":"snake_case, never an HTTP status string"},"message":{"type":"string"},"request_id":{"type":"string"}},"additionalProperties":true}}},"RateLimitError":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id","window","pool","retry_after_seconds"],"properties":{"code":{"type":"string","const":"rate_limit_exceeded"},"message":{"type":"string"},"request_id":{"type":"string"},"window":{"type":"string","enum":["daily","minute","global_sandbox","concurrency"],"description":"Which limit was hit. concurrency (too many simultaneous calls on one counter) carries no limit / used / reset_at: retry after 1 second"},"pool":{"type":"string","enum":["live","sandbox"]},"limit":{"type":"integer"},"used":{"type":"integer"},"reset_at":{"type":"string","format":"date-time"},"retry_after_seconds":{"type":"integer","description":"Same value as the Retry-After header"},"suggested_poll_interval_seconds":{"type":"integer","description":"Daily live window only (2026-11-02): a polling interval that fits this key's daily limit when you poll one endpoint (free 50/day: 1800)"},"key":{"type":"object","properties":{"id":{"type":"string"}}}}}}},"WebhookEvent":{"type":"string","enum":["post.published","post.failed","reply.sent","patrol.reply","patrol.pending","token.expiring","usage.threshold","approval.decided"]},"InsufficientScopeError":{"type":"object","description":"403. The key has this permission set to deny. Header X-Required-Scope names it (MCP clients: read error.required[0]). No approval is created and nobody is notified: stop and tell the human.","properties":{"error":{"type":"object","required":["code","message","required","mode","have","fix","request_id"],"properties":{"code":{"type":"string","const":"insufficient_scope"},"message":{"type":"string"},"required":{"type":"array","items":{"type":"string"}},"mode":{"type":"string","const":"deny"},"have":{"type":"array","items":{"type":"string"},"description":"Permissions currently allow, sorted. Ask-state permissions are listed in GET /me data.key.scopes"},"fix":{"type":"string","description":"What the owner can do today, naming the permission (English, then Chinese): change this key in Settings (PATCH /keys/{id}); no new key is needed"},"request_id":{"type":"string"}}}},"example":{"error":{"code":"insufficient_scope","message":"This key is not allowed to do this (content:publish_now).","required":["content:publish_now"],"mode":"deny","have":["content:schedule","content:write","read","webhooks:write"],"fix":"The key owner can change this key in place, no new key needed: sign in at https://mindthread.tw/settings (Settings → API keys), find the key mt_live_...8f2a, press “Edit permissions and name”, open “Advanced: set each permission” and set “Publish now” (content:publish_now) to “Allow” (or “Ask me”, so each such request waits for the owner to confirm). Widening a permission needs a sign-in within the last 24 hours. Team members can change only keys they created, and can set this permission to Ask me at most; Allow needs the owner. 中文：這把金鑰的「立刻發文」權限設成不允許。擁有者可以直接修改這把金鑰，不用建立新金鑰：登入 mindthread.tw/settings，在「API 金鑰」找到 mt_live_...8f2a 這把，按「修改權限與名稱」，再展開「進階：逐項設定」，把「立刻發文」改成「允許」或「先問我」（每次都等你確認再做）。放寬權限需要 24 小時內登入過。團隊成員只能改自己建立的金鑰，而且這一項最多設成「先問我」，要設成「允許」請擁有者操作。","request_id":"req_mf1x2y3z4abcd"}}},"ApprovalRequiredError":{"type":"object","description":"403. The key has this permission set to ask. The request passed validation, an approval was created and the owner was notified. Hand approval.human_url or approval.human_message to the human, do not open it yourself, do not resend. There is no approve_path: only the signed-in owner can approve. From 1.10.0 the owner may also decide from a one-time link in their own email or push notification (approval.channels_notified says where they were reached); you never receive that link and must never ask the human for it or for a code.","properties":{"error":{"type":"object","required":["code","message","scope","approval_id","approval","request_id"],"properties":{"code":{"type":"string","const":"approval_required"},"message":{"type":"string"},"scope":{"type":"string"},"approval_id":{"type":"string","description":"Same as approval.id"},"approval":{"$ref":"#/components/schemas/Approval"},"request_id":{"type":"string"}}}},"example":{"error":{"code":"approval_required","message":"This action needs the key owner's confirmation. ...","scope":"content:publish_now","approval_id":"apr_7QxK2mZ9pLr4tWv8aB1c","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"pending","scope":"content:publish_now","key_id":"K9f2abc","test_mode":false,"action":{"method":"POST","route":"/content/publish","account_id":"utOW1","account_username":"ultraprobe.tw","summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」"},"created_at":"2026-09-24T05:05:00.000Z","expires_at":"2026-09-25T05:05:00.000Z","decided_at":null,"decision":null,"result":null,"tier":"t1","channels_notified":[{"type":"bell","status":"sent"},{"type":"email","status":"sent"}],"decision_via":null,"decision_channel":null,"decided_by":null,"step_up":null,"guardrails_etag_at_request":null,"human_url":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c","human_message":"已送到你的電郵，可以在通知裡直接核准；或打開 https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c：立刻發文到 @ultraprobe.tw：「今天聊聊…」。","poll":"GET /approvals/apr_7QxK2mZ9pLr4tWv8aB1c","event":"approval.decided","execution":"server-side after the owner confirms; the result is in GET /approvals/{id} (result), and approval.decided announces it. Do not resend while it is pending or approved. Once it has ended, follow result.error: approval_base_changed or approval_payload_changed means read the current values again and resend (you get a new approval)."},"request_id":"req_mf1x2y3z4abcd"}}},"Approval":{"type":"object","required":["id","status","scope","key_id","action","created_at","expires_at","human_url"],"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["pending","approved","executed","failed","denied","expired","cancelled"],"description":"approved = the owner confirmed and the server is executing; executed / failed = finished (see result)"},"scope":{"type":"string"},"key_id":{"type":"string"},"test_mode":{"type":"boolean"},"action":{"type":"object","properties":{"method":{"type":"string"},"route":{"type":"string"},"account_id":{"type":["string","null"]},"account_username":{"type":["string","null"]},"summary":{"type":"string"}}},"created_at":{"type":"string","format":"date-time"},"expires_at":{"type":"string","format":"date-time","description":"24 hours after creation"},"decided_at":{"type":["string","null"],"format":"date-time"},"decision":{"type":["string","null"],"enum":["once","always","deny",null]},"result":{"type":["object","null"],"description":"{ ok:true, http_status, data, post_id, threads_post_id, permalink? } or { ok:false, http_status, error { code, message } } after execution. error.code approval_payload_changed = library items changed after the owner was asked (nothing ran); approval_base_changed (1.8.3) = a settings field this request touches changed after the owner was asked (nothing ran; read the settings again and resend); execution_unknown = the outcome was not recorded (check before retrying)"},"human_url":{"type":"string"},"human_message":{"type":"string","description":"Key view only, for the human as is. Names only the channels that actually reached the owner (channels_notified status sent). From 1.10.0, when a one-time link reached at least one channel: 已送到你的{channels}，可以在通知裡直接核准；或打開 {human_url}：{summary}。 (prefixed [測試] on test keys); when no link channel was reached it keeps the older wording 請打開 {human_url} 確認：{summary}（也已送到你的站內通知…）。"},"poll":{"type":"string"},"event":{"type":"string","const":"approval.decided"},"execution":{"type":"string","description":"Key view only: how the request will run"},"cancel_reason":{"type":["string","null"],"description":"Only when status is cancelled (1.8.1). Known values: key_revoked, key_disabled_self, permission_set_to_deny. Why a cancelled approval was cancelled: key_revoked (revoked in Settings, or its team member was removed), key_disabled_self (the key called POST /keys/current/disable), permission_set_to_deny (the owner set that permission to deny with PATCH /keys/{id}; the key itself still works). Other values are support cancellations."},"tier":{"type":["string","null"],"enum":["t1","t2","t3",null],"description":"Risk tier frozen when the approval was created (1.10.0): t1 patrol:reply_send, content:publish_now and every test_mode approval; t2 patrol:cloud_enable, patrol:browser_command, content:schedule; t3 accounts:guardrails, accounts:connect and every other permission. Decides whether a one-time link may allow on its own or needs a second proof. null on approvals created before 1.10.0"},"channels_notified":{"type":["array","null"],"items":{"$ref":"#/components/schemas/ChannelsNotifiedItem"},"description":"Where the owner was notified (1.10.0): one item per channel with type (bell, email, line, web_push) and status (sent, skipped_throttled, skipped_disabled, skipped_cooldown, failed). Never an address, a channel id or a link. null on approvals created before 1.10.0"},"decision_via":{"type":["string","null"],"enum":["web","link","push","client_attested",null],"description":"How the owner decided (1.10.0): web (/approve/{id}), link (a one-time link in their own channel), push (a notification button; later), client_attested (an owner-registered client; later). null while pending, on expired and on system cancellations, and on every approval decided before 1.10.0 (those were all made on the web)"},"decision_channel":{"type":["string","null"],"enum":["email","line","telegram","web_push",null],"description":"Only when decision_via is link or push: the channel that carried the link (email, telegram or web_push; line is reserved)"},"decided_by":{"type":["object","null"],"description":"Who decided (1.10.0): { type: \"human\", role: \"owner\" }. null while pending and for system outcomes (expired, cancelled). The key view never carries a user id or address","properties":{"type":{"type":"string","const":"human"},"role":{"type":"string","enum":["owner"],"description":"owner today; admin may follow with multi-owner workspaces"}}},"step_up":{"type":["object","null"],"description":"The second proof the decision carried (1.10.0): { method: none | session | passkey | code }. session on the web page; none when a link allowed on its own or on a deny. null while pending","properties":{"method":{"type":"string","enum":["none","session","passkey","code"]}}},"guardrails_etag_at_request":{"type":["string","null"],"description":"Settings approvals only (1.10.0): the guardrails.etag when the approval was created (the key could read it anyway). null otherwise"}}},"OwnerKey":{"type":"object","description":"A key as the owner sees it in Settings: each item of GET /keys and data.key of PATCH /keys/{id} (web app session only; API callers read GET /me data.key instead)","required":["id","label","prefix","last4","createdAt","lastUsedAt","revoked","kind","scopes","legacy","scopes_enforced","scopes_updated_at","agent_name","agent_url","createdByUid","viaTeam"],"properties":{"scopes_updated_at":{"type":["string","null"],"format":"date-time","description":"When the permissions last changed (null: never set, a legacy key). Send it back as if_scopes_updated_at on PATCH /keys/{id}"},"id":{"type":"string"},"label":{"type":"string","description":"May be empty (GET /me shows legacy-<last4> then)"},"prefix":{"type":"string","enum":["mt_live","mt_test"]},"last4":{"type":"string"},"createdAt":{"type":["string","null"],"format":"date-time"},"lastUsedAt":{"type":["string","null"],"format":"date-time"},"revoked":{"type":"boolean","description":"Revoked in Settings or disabled by the key itself; cannot be undone"},"kind":{"type":"string","enum":["live","test"]},"scopes":{"type":"object","additionalProperties":{"type":"string","enum":["allow","ask","deny"]},"description":"Effective permissions (a legacy key shows allow everywhere)"},"legacy":{"type":"boolean","description":"Created before permissions existed; any permission change makes it non-legacy"},"scopes_enforced":{"type":"boolean"},"agent_name":{"type":["string","null"]},"agent_url":{"type":["string","null"]},"createdByUid":{"type":["string","null"],"description":"Who pressed create (a team member when viaTeam)"},"viaTeam":{"type":"boolean"}},"example":{"id":"K9f2abc","label":"OpenClaw Agent","prefix":"mt_live","last4":"8f2a","createdAt":"2026-09-24T01:00:00.000Z","lastUsedAt":"2026-09-24T03:12:45.000Z","revoked":false,"kind":"live","scopes":{"read":"allow","content:write":"allow","content:schedule":"allow","content:publish_now":"deny","patrol:reply_send":"ask","patrol:cloud_enable":"ask","patrol:browser_command":"ask","accounts:connect":"ask","accounts:guardrails":"ask","webhooks:write":"allow"},"legacy":false,"scopes_enforced":true,"scopes_updated_at":"2026-09-24T04:30:00.000Z","agent_name":"OpenClaw","agent_url":"https://openclaw.example/agent","createdByUid":"u_owner","viaTeam":false}},"KeyUsage":{"type":"object","description":"data of GET /keys/current/usage: the calling key only","required":["key_id","kind","window","summary","recent","next_cursor","has_more","note"],"properties":{"key_id":{"type":"string","description":"The calling key (GET /me data.key.id)"},"kind":{"type":"string","enum":["live","test"]},"window":{"type":"object","required":["days","since","until","timezone"],"properties":{"days":{"type":"integer","minimum":1,"maximum":30},"since":{"type":"string","format":"date-time","description":"00:00 Asia/Taipei of the first day (days=1 is today, the same cut as the quota reset)"},"until":{"type":"string","format":"date-time"},"timezone":{"type":"string","const":"Asia/Taipei"}}},"summary":{"allOf":[{"type":"object","description":"Totals for the window, from per-day counters that start with 1.8.2","required":["calls","units","errors"],"properties":{"calls":{"type":"integer"},"units":{"type":"integer","description":"Daily-quota units consumed"},"errors":{"type":"integer","description":"Responses with HTTP status 400 or above"}}},{"type":"object","required":["by_endpoint"],"properties":{"by_endpoint":{"type":"array","description":"Most calls first","items":{"allOf":[{"type":"object","description":"One route","required":["calls","units","errors"],"properties":{"calls":{"type":"integer"},"units":{"type":"integer","description":"Daily-quota units consumed"},"errors":{"type":"integer","description":"Responses with HTTP status 400 or above"}}},{"type":"object","required":["endpoint"],"properties":{"endpoint":{"type":"string","description":"METHOD /path with path parameters as {id}, e.g. POST /library/{id}/approve"}}}]}}}}]},"recent":{"type":"array","description":"Newest first","items":{"type":"object","required":["request_id","endpoint","status","units","at"],"properties":{"request_id":{"type":["string","null"],"description":"Same as the request_id / X-Request-Id of that response; apr_exec_<approval id> for a request the server ran after the owner confirmed"},"endpoint":{"type":"string","description":"METHOD /path (records written before 1.8.2 show the older /v1/path form)"},"status":{"type":"integer","description":"HTTP status of that response"},"units":{"type":["integer","null"],"description":"Daily-quota units consumed; null on records written before 1.8.2"},"at":{"type":"string","format":"date-time"}}}},"next_cursor":{"type":["string","null"],"description":"Pass as cursor for the next page; null on the last page"},"has_more":{"type":"boolean"},"note":{"type":"string","description":"What is and is not recorded (the text is in the example)"}},"example":{"key_id":"K9f2abc","kind":"test","window":{"days":1,"since":"2026-09-23T16:00:00.000Z","until":"2026-09-24T03:12:45.000Z","timezone":"Asia/Taipei"},"summary":{"calls":3,"units":2,"errors":1,"by_endpoint":[{"endpoint":"POST /content/publish","calls":2,"units":2,"errors":1},{"endpoint":"GET /keys/current/usage","calls":1,"units":0,"errors":0}]},"recent":[{"request_id":"req_mf1x2y3z4abcd","endpoint":"POST /content/publish","status":200,"units":1,"at":"2026-09-24T03:12:40.000Z"},{"request_id":"req_mf1x2y3z4abce","endpoint":"POST /content/publish","status":403,"units":1,"at":"2026-09-24T03:10:02.000Z"}],"next_cursor":null,"has_more":false,"note":"Only this key's records. Coverage: every request this key made after the server identified it and answered, success or error, including requests refused for permission (403), quota (429) or a bad request (400). Not recorded: 401 unauthorized, 401 key_disabled, answers given before the key is checked (405 method_not_allowed, 401 session_required), and the validation run before an approval is created. 429 answers and refusals made before the quota check (400 invalid_idempotency_key, 403 scope_unmapped) are recorded about once per key per minute on each server, so those counts are a lower bound. Requests the server ran after the owner confirmed an approval appear under this key with request_id apr_exec_<approval id> and units 0. units: daily-quota units the request consumed (0 for GET /approvals/{id}, this endpoint and POST /keys/current/disable). Records are written after the answer is sent, best effort: one can occasionally be missing, so summary and recent may differ slightly. summary counts start with version 1.8.2; recent covers the requested window, at most the last 30 days (units is null on records written before 1.8.2)."}},"SandboxEventData":{"type":"object","description":"data of an event recorded by a test key's sandbox write (GET /events with a mt_test_ key). approval.decided events of test approvals carry test_mode:true and key_id like any approval.decided","required":["test_mode","key_id","persisted","request_id"],"properties":{"test_mode":{"type":"boolean","const":true},"key_id":{"type":"string"},"persisted":{"type":"boolean","const":false},"request_id":{"type":["string","null"],"description":"The request that caused it (apr_exec_<approval id> when the owner confirmed a test approval)"},"approval_id":{"type":"string","description":"Only when the owner confirmed a test approval and the server ran it"}},"additionalProperties":true},"GuardrailsState":{"type":"object","description":"data.guardrails of GET /accounts/{id}/settings (1.9.0). From 1.9.0, GET /accounts/{id}/settings returns data.guardrails: etag (an opaque version of the five guardrails: content_rules, review_before_publish, auto_reply_enabled, video_autopilot, enabled), covers, last_change, pending, enforced_on and not_enforced_on.","required":["etag","covers","last_change","enforced_on","not_enforced_on"],"properties":{"etag":{"type":"string","description":"Opaque; send it back as if_match. g1. followed by five 16-character parts, one per guardrail (content_rules, then the four switches), so if_match is compared only on the guardrails a PATCH sends"},"etag_parts":{"type":"object","description":"The same etag split per guardrail (informational)","additionalProperties":{"type":"string"}},"covers":{"type":"array","items":{"type":"string","enum":["content_rules","review_before_publish","auto_reply_enabled","video_autopilot","enabled"]}},"last_change":{"oneOf":[{"type":"null"},{"type":"object","properties":{"revision_id":{"type":"string"},"at":{"type":"string","format":"date-time"},"source":{"type":"string","enum":["api","approval","rollback","system"]},"actor":{"type":"object","properties":{"type":{"type":"string","enum":["key","human","system"]},"key_id":{"type":["string","null"]},"via_key_id":{"type":"string","description":"Only when source is approval: the key that asked"}}},"mine":{"type":"boolean"},"loosened":{"type":"array","items":{"type":"string"}},"tightened":{"type":"array","items":{"type":"string"}},"gap_before":{"type":"boolean"}}}]},"pending":{"type":"array","description":"Loosening approvals for this account still waiting for the owner (same live or test side as the caller). approval_id only on approvals your key created","items":{"type":"object","properties":{"mine":{"type":"boolean"},"approval_id":{"type":"string"},"changes":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time"},"expires_at":{"type":"string","format":"date-time"}}}},"enforced_on":{"type":"array","items":{"type":"string"},"description":"Where the server enforces content_rules"},"not_enforced_on":{"type":"array","items":{"type":"string"},"description":"Where it does not"},"notes":{"type":"string","description":"Plain-language summary of this block"}},"example":{"etag":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","covers":["content_rules","review_before_publish","auto_reply_enabled","video_autopilot","enabled"],"last_change":{"revision_id":"grv_4f1c2a9e0b7d3e55","at":"2026-09-25T03:10:00.000Z","source":"api","actor":{"type":"key","key_id":"K9f2abc"},"mine":true,"loosened":[],"tightened":["banned_phrases_added"],"gap_before":false},"pending":[],"enforced_on":["POST /content/generate","POST /content/publish","POST /content/schedule","POST /content/generate-and-schedule","POST /content/publish-thread","POST /content/generate-thread","POST /experiments","POST /library","PATCH /library/{id}","publish time: posts scheduled through the API","publish time: the library queue, including items written by the nightly refill and other tools"],"not_enforced_on":["the web app's compose page (posts written or scheduled there)","cloud patrol replies","auto-replies to comments on this account's posts","browser patrol (extension) replies and posts"]}},"GuardrailRevision":{"type":"object","description":"One entry of GET /accounts/{id}/guardrails/history. Every change to a guardrail made through the API, by an approval or by the system writes a revision that is never edited or deleted: GET /accounts/{id}/guardrails/history (read permission, newest first, limit up to 50, before=next_before for the next page) lists id, at, source (api, approval, rollback or system), actor, mine, changed_fields, loosened, tightened, gap_before, before, after and restore_body; approval_id, request_id and reason only on revisions your own key made. PATCH accepts reason (up to 200 characters, plain text, links removed) to explain a change. gap_before:true means the guardrails changed outside the record since the previous revision (in the web app, or before 1.9.0); those changes are not recorded by name yet. A system revision (actor type system) records the server pausing an account (its authorization failed, it is blocked or publishing keeps failing) or turning it back on after a reconnect or token refresh, with system_reason; it cannot be undone. Test keys read live revisions and write none.","required":["id","at","source","actor","mine","changed_fields","loosened","tightened","gap_before","before","after","restore_body"],"properties":{"id":{"type":"string","description":"grv_ followed by 16 hex characters"},"at":{"type":"string","format":"date-time"},"source":{"type":"string","enum":["api","approval","rollback","system"]},"actor":{"type":"object","properties":{"type":{"type":"string","enum":["key","human","system"]},"key_id":{"type":["string","null"]},"via_key_id":{"type":"string","description":"Only when source is approval: the key that asked"}}},"mine":{"type":"boolean","description":"Made by the calling key"},"changed_fields":{"type":"array","items":{"type":"string","enum":["content_rules","review_before_publish","auto_reply_enabled","video_autopilot","enabled"]}},"loosened":{"type":"array","items":{"type":"string"}},"tightened":{"type":"array","items":{"type":"string"},"description":"facts_created marks the first facts list on the account (not loosening)"},"gap_before":{"type":"boolean","description":"The guardrails changed outside the record since the previous revision (in the web app, or before 1.9.0); not recorded by name yet"},"gap_fields":{"type":"array","items":{"type":"string"}},"rollback_of":{"type":["string","null"]},"system_reason":{"type":"string","enum":["auto_paused_token_error","auto_paused_blocked","auto_paused_publish_failing","resumed_after_reconnect","resumed_after_token_refresh","deauthorized"],"description":"Only on source system: why the server changed it"},"before":{"type":"object","description":"The five guardrails before, same shape as GET settings"},"after":{"type":"object"},"restore_body":{"type":"object","description":"PATCH body that puts back the values from before this revision (only the fields it changed); add if_match"},"approval_id":{"type":["string","null"],"description":"Only when mine"},"request_id":{"type":["string","null"],"description":"Only when mine"},"reason":{"type":["string","null"],"description":"Only when mine"},"decision_via":{"type":["string","null"],"description":"Since 1.10.0, source approval only: how the owner decided (web, link, push or client_attested); null for other sources and for revisions made before 1.10.0"},"step_up_method":{"type":["string","null"],"description":"Since 1.10.0, only when mine and source is approval: the second proof the owner gave (none, session, passkey or code); null otherwise"}}},"GuardrailsChangedError":{"type":"object","description":"412. PATCH /accounts/{id}/settings accepts an optional if_match with that etag. It is compared only on the guardrails the body sends, content_rules as one part and each of the four switches on its own, so a change to another part does not refuse the request. If a sent part changed since you read it, the answer is 412 guardrails_changed with current_etag, changed, current (the five current values) and last_change, and nothing is written: read again, apply your change to the current content_rules (it is replaced as a whole) and resend. Without if_match the last writer wins, as before, and every change is recorded.","properties":{"error":{"type":"object","required":["code","message","current_etag","changed","current","request_id"],"properties":{"code":{"type":"string","const":"guardrails_changed"},"message":{"type":"string"},"current_etag":{"type":"string"},"changed":{"type":"array","items":{"type":"string"}},"current":{"type":"object","description":"The five guardrails now"},"last_change":{"type":["object","null"]},"loosens":{"type":"array","items":{"type":"string"},"description":"Only when the request became loosening after the permission check"},"request_id":{"type":"string"}}}},"example":{"error":{"code":"guardrails_changed","message":"This account's guardrails changed since you read them. Re-read GET /accounts/{id}/settings, apply your change to the current content_rules (it is replaced as a whole), and resend with the new if_match.","current_etag":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","changed":["content_rules"],"current":{"content_rules":{"max_chars":220,"min_chars":80,"forbid_cta":true,"forbid_hashtags":true,"banned_phrases":["保證獲利","競品A"],"enforce":"block","facts":["客戶 120 位"],"forbid_causal_claims":false,"one_fact_per_post":false,"mention_limits":[],"judge_claims":false},"review_before_publish":true,"auto_reply_enabled":false,"video_autopilot":false,"enabled":true},"last_change":{"revision_id":"grv_4f1c2a9e0b7d3e55","at":"2026-09-25T03:10:00.000Z","source":"api","actor":{"type":"key","key_id":"K9f2abc"},"mine":true,"loosened":[],"tightened":["banned_phrases_added"],"gap_before":false},"request_id":"req_mf1x2y3z4abcd"}}},"SettingsDryRun":{"type":"object","description":"data of PATCH /accounts/{id}/settings with dry_run:true. dry_run:true only previews: it needs the read permission, creates no approval and writes nothing, and each key can dry-run at most 10 times a minute (429 rate_limit_exceeded). It answers changed, loosened, tightened, required_scope, your_mode, outcome (apply, approval_required or denied), etag_now and impact: how many of the first 200 queued library items, in publishing order, the new content_rules would newly flag, checked with the fixed rules only (no judge_claims, no scheduled posts).","required":["dry_run","loosened","tightened","required_scope","your_mode","outcome","etag_now"],"properties":{"dry_run":{"type":"boolean","const":true},"account_id":{"type":"string"},"changed":{"type":"array","items":{"type":"string"}},"loosened":{"type":"array","items":{"type":"string"}},"tightened":{"type":"array","items":{"type":"string"}},"required_scope":{"type":"string","enum":["content:write","accounts:guardrails"]},"your_mode":{"type":"string","enum":["allow","ask","deny"]},"outcome":{"type":"string","enum":["apply","approval_required","denied"]},"etag_now":{"type":"string"},"etag_after":{"type":"string"},"impact":{"type":["object","null"],"description":"Only when content_rules is in the body","properties":{"queued_checked":{"type":"integer","description":"Queued items checked: the first 200 in publishing order"},"queued_not_checked":{"type":["integer","null"],"description":"Queued items after the first 200 (null when the count could not be read)"},"violating":{"type":"integer"},"newly_violating":{"type":"integer"},"would_be_held":{"type":"integer"},"samples":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"rules":{"type":"array","items":{"type":"string"}}}}},"not_checked":{"type":"array","items":{"type":"string"}}}}}},"SettingsWriteResult":{"type":"object","description":"data of a PATCH /accounts/{id}/settings that was applied: the settings as GET returns them, plus guardrails { etag, revision_id } (revision_id null when no guardrail changed, and on a test key)","properties":{"account_id":{"type":"string"},"content_rules":{"type":["object","null"]},"guardrails":{"type":"object","required":["etag","revision_id"],"properties":{"etag":{"type":"string"},"revision_id":{"type":["string","null"]}}}}},"GuardrailRollbackResult":{"type":"object","description":"data of POST /accounts/{id}/guardrails/rollback","required":["account_id","rolled_back","already_rolled_back","restored_fields","revision_id","etag","loosened","tightened"],"properties":{"account_id":{"type":"string"},"rolled_back":{"type":"string","description":"The revision you asked to undo"},"already_rolled_back":{"type":"boolean","description":"true: those fields already held their previous values, so nothing was written"},"rolled_back_by":{"type":["string","null"],"description":"The latest rollback revision of that revision, when there is one"},"restored_fields":{"type":"array","items":{"type":"string","enum":["content_rules","review_before_publish","auto_reply_enabled","video_autopilot","enabled"]}},"revision_id":{"type":["string","null"],"description":"The new rollback revision (null when nothing was written)"},"etag":{"type":"string"},"loosened":{"type":"array","items":{"type":"string"}},"tightened":{"type":"array","items":{"type":"string"}}}},"StepUp":{"type":"object","description":"Second proof needed before a link may allow, as POST /a/{lid}/view reports it (link.step_up; null when the link is no longer active). 1.10.0 methods: session (the card page runs in a browser signed in as the owner and sends the Firebase ID token: silent, 0 steps) and code (6 digits sent to a verified channel with POST /a/{lid}/step-up/code; 5 minutes, single use, 5 wrong attempts lock the link with 429 step_up_locked). passkey follows in 1.10.1. On 401 step_up_required the same object comes back as error.step_up with only methods, code_channels and reason. Denying is always allowed from a link (T0), including \"deny every pending request of this key\". T1: patrol:reply_send, content:publish_now (live) and every test_mode approval. Pure link when the channel is marked link-only; otherwise the same second proof as T2. T2: patrol:cloud_enable, patrol:browser_command, content:schedule. Needs a second proof: a signed-in browser session, or a 6-digit code sent to any verified channel (the same one is fine). T3: accounts:guardrails, accounts:connect, and any permission not listed here. Needs a signed-in session from the last 24 hours, or a 6-digit code sent to a different channel than the one that carried the link (an owner with a single channel can only use the session).","required":["required","methods","code_channels"],"properties":{"required":{"type":"boolean","description":"false when the link alone may allow (t1 on a link-only channel) or when the decision is deny"},"satisfied_by_session":{"type":"boolean","description":"The browser is signed in as the owner and that is enough for this tier: approving needs no further step"},"session_mismatch":{"type":"boolean","description":"The browser is signed in to another MindThread account (decide would answer 403 approval_link_wrong_user)"},"session_too_old":{"type":"boolean","description":"t3 only: the sign-in is older than 24 hours, so the session does not count; sign in again or use a code"},"methods":{"type":"array","items":{"type":"string","enum":["session","code","passkey"]},"description":"Subset of session and code in 1.10.0; code only when at least one channel can receive one"},"code_channels":{"type":"array","description":"Channels a code can be sent to. t2: any verified channel, the one that carried the link included. t3: never the channel that carried the link and never a channel marked agent_readable, so an owner with a single channel cannot use a code for t3","items":{"type":"object","properties":{"channel_id":{"type":"string"},"type":{"type":"string","enum":["email","line","telegram","web_push"]},"masked":{"type":["string","null"]}}}},"reason":{"type":["string","null"],"enum":["tier_t3","tier_t2","channel_not_link_only","session_too_old","session_invalid",null],"description":"Why a second proof is needed: the tier, or a t1 link on a channel that is not link-only (email by default). On 401 step_up_required also session_too_old or session_invalid (the ID token sent did not verify)"}}},"ChannelsNotifiedItem":{"type":"object","description":"Key view of one channel the owner was notified on: only the type and whether it was reached; never an address, a channel id or the link","required":["type","status"],"properties":{"type":{"type":"string","enum":["bell","email","line","telegram","web_push"]},"status":{"type":"string","enum":["sent","skipped_throttled","skipped_disabled","skipped_cooldown","failed"],"description":"sent (handed to the provider: an email accepted by the mail service, a push accepted by the push service; keys are not told whether it carried a one-time link, and human_message names only the channels whose notification carried one); skipped_throttled (email: another approval email went out within 10 minutes; no link was issued); skipped_disabled (the channel has approval_links off, or links are off for the owner); skipped_cooldown (a channel added less than 24 hours ago on an approval that may only be allowed, not denied); failed (delivery error)"}}},"ApprovalLinkView":{"type":"object","description":"data of POST /a/{lid}/view: the card behind a one-time link, as the owner sees it","required":["link","approval","csrf","anti_phishing_phrase","web_fallback"],"properties":{"link":{"type":"object","required":["lid","channel","expires_at","allowed_decisions","tier","state","reissue_available","step_up"],"properties":{"lid":{"type":"string"},"channel":{"type":"string","enum":["email","line","telegram","web_push"],"description":"The channel this link was sent to (email or web_push in 1.10.0)"},"expires_at":{"type":"string","format":"date-time","description":"created_at plus the owner's link_ttl_seconds (600 by default; test_link_ttl_seconds on test approvals), never later than the approval's expires_at"},"allowed_decisions":{"type":"array","items":{"type":"string","enum":["once","deny"]},"description":"A link on a channel added less than 24 hours ago carries only deny"},"tier":{"type":"string","enum":["t1","t2","t3"]},"state":{"type":"string","enum":["active","used","expired","superseded","revoked"]},"reissue_available":{"type":"boolean","description":"true only on an expired link of a pending approval that was resent fewer than 3 times and whose channel still receives links: POST /a/{lid}/reissue works"},"step_up":{"anyOf":[{"$ref":"#/components/schemas/StepUp"},{"type":"null"}],"description":"null when the link is no longer active"}}},"approval":{"type":"object","description":"While the link is active, the card: id, status, scope, scope_label, test_mode, action { method, route, account_id, account_username, summary }, requested_by { key_id, label, prefix, last4, agent_name, agent_domain } (the label and last4 of the key, never the key itself), diff (settings approvals: field, current, proposed, kind loosened | changed, label; null otherwise), base { guardrails_etag_at_request, fresh, changed } (fresh false and changed non-empty when the approval already failed with approval_base_changed), agent_content (publishing approvals: text as plain text, media_count, video, publish_target, publish_at, publish_now, thread_parts, items, target_post; null otherwise), agent_note, preview (the stored preview the /approve page renders), created_at, expires_at, decision, decision_via, decided_at, cancel_reason, result (a summary: ok, http_status). When the link is used, expired, superseded or revoked only the summary: id, status, decision, decision_via, decided_at, expires_at, cancel_reason, result_summary and action { summary, account_username }, so the owner still sees the outcome"},"csrf":{"type":["string","null"],"description":"Send it back on decide, step-up/code and deny-all. Bound to the lid, the link nonce and the __Host-mt_al cookie this response sets (15 minutes). null when the link is no longer active: nothing can be decided with it, so no cookie is set either"},"anti_phishing_phrase":{"type":["string","null"],"description":"The phrase the owner chose in approval-settings (null when none); every notification and the card show it. A page or message without it is not from MindThread"},"web_fallback":{"type":"string","description":"https://mindthread.tw/approve/{id}: the signed-in page that can always decide instead (also the only place for always)"}}},"ApprovalLinkDecideRequest":{"type":"object","required":["k","decision","csrf"],"properties":{"k":{"type":"string","description":"The secret from the URL fragment (43 characters base64url). Never logged, never shown to any API key"},"decision":{"type":"string","enum":["once","deny"],"description":"always cannot be decided from a link (403 decision_not_allowed_via_link): only at /approve/{id}, signed in. Anything else answers 400 invalid_decision; once on a link that only allows deny answers 403 decision_not_allowed_via_link"},"csrf":{"type":"string","description":"The csrf value POST /a/{lid}/view returned; checked together with the __Host-mt_al cookie, Origin https://mindthread.tw and Sec-Fetch-Site same-origin when the browser sends it"},"step_up":{"type":"object","description":"Omit when the tier allows the link alone, when the decision is deny, or when the browser sends Authorization: Bearer <Firebase ID token> (that counts as method session; t3 needs a sign-in from the last 24 hours). code: { method: \"code\", code, channel_id } after POST /a/{lid}/step-up/code (channel_id must be the channel the code was sent to). passkey (1.10.1) also sends credential_id, client_data_json, authenticator_data, signature and user_handle (base64url)","properties":{"method":{"type":"string","enum":["session","code","passkey"]},"code":{"type":"string","pattern":"^[0-9]{6}$"},"channel_id":{"type":"string"},"credential_id":{"type":"string"},"client_data_json":{"type":"string"},"authenticator_data":{"type":"string"},"signature":{"type":"string"},"user_handle":{"type":"string"}}}}},"ApprovalLinkError":{"type":"object","description":"Every error of the link endpoints (POST /a/{lid}/…): the standard ErrorEnvelope, fix on every 1.10.0 code (English, then Chinese after 中文：) and the structured fields below where they apply. Order of checks: the link itself (wrong secret or unknown lid 404, used 409, superseded or revoked 410, expired 410), then on decide the decision (403, 400), then the approval state (409 approval_already_decided, approval_expired, approval_key_revoked, approval_permission_denied, approval_stale), then the step-up (401, 429, 403)","properties":{"error":{"type":"object","required":["code","message","request_id"],"additionalProperties":true,"properties":{"code":{"type":"string","enum":["approval_link_not_found","approval_link_expired","approval_link_revoked","approval_link_used","approval_already_decided","approval_stale","step_up_required","step_up_failed","step_up_locked","approval_link_wrong_user","decision_not_allowed_via_link","csrf_failed","approval_links_disabled","approval_expired","approval_key_revoked","approval_permission_denied","invalid_decision","invalid_channel","invalid_request"]},"message":{"type":"string"},"fix":{"type":"string","description":"What the owner can do now; names https://mindthread.tw/approve/{id} where useful. On every 1.10.0 code and on approval_expired"},"request_id":{"type":"string"},"approval":{"type":"object","description":"On approval_link_used, approval_link_revoked, approval_already_decided, approval_stale, approval_expired, approval_key_revoked and approval_permission_denied: the summary (id, status, decision, decision_via, decided_at, expires_at, cancel_reason, result_summary, action { summary, account_username }); approval_link_expired carries only id, status and expires_at; approval_stale adds result.error.code"},"reason":{"type":["string","null"],"enum":["key_disabled","permission_denied","channel_removed","reissued","too_many_attempts","bad_secret_attempts","workspace_revoked","links_disabled","delivery_failed","owner_revoked","superseded",null],"description":"approval_link_revoked: why. superseded = the approval was decided through another link or on the web"},"reissue_available":{"type":"boolean","description":"approval_link_expired: POST /a/{lid}/reissue can send a new link to the same channel"},"stale_reason":{"type":"string","enum":["base_changed","payload_changed"]},"changed":{"type":"array","items":{"type":"string"}},"current_etag":{"type":["string","null"]},"step_up":{"type":"object","description":"step_up_required: { methods, code_channels, reason }","properties":{"methods":{"type":"array","items":{"type":"string"}},"code_channels":{"type":"array","items":{"type":"object"}},"reason":{"type":["string","null"]}}},"attempts_left":{"type":"integer","description":"step_up_failed: wrong codes left before the link locks"},"allowed_decisions":{"type":"array","items":{"type":"string"}},"web_fallback":{"type":"string"},"code_channels":{"type":"array","description":"invalid_channel on step-up/code: the channels a code may go to","items":{"type":"object"}}}}}},"NotificationChannel":{"type":"object","description":"One channel of the owner as Settings shows it (GET /notification-channels items, data.channel of POST, verify and PATCH). Addresses are always masked; the push subscription itself is never returned","required":["channel_id","type","masked_address","verified","approval_links","link_only_allowed","agent_readable","cooldown_until","primary","created_at","last_delivery_at","last_error"],"properties":{"channel_id":{"type":"string","description":"nch_ followed by an id. The account's own email is always nch_email_primary; the web push subscription of the web app is nch_push_primary (listed only while a subscription exists)"},"type":{"type":"string","enum":["email","line","telegram","web_push"],"description":"email or web_push in 1.10.0. line is reserved: POST with type line answers 400 invalid_channel until LINE ships"},"masked_address":{"type":["string","null"],"description":"email: m***@gmail.com. web_push: null (there is no address to show)"},"verified":{"type":"boolean","description":"email: the 6-digit code was entered (POST /notification-channels/{id}/verify); the account's own email and the web push subscription count as verified from the start"},"approval_links":{"type":"boolean","description":"Send one-time approval links to this channel. Off by default on every channel, including the two created automatically; the owner turns it on in Settings (PATCH, needs a sign-in within 24 hours). Turning it off revokes the links already sent to it"},"link_only_allowed":{"type":"boolean","description":"A t1 approval may be allowed with the link alone. Default false for email (mailboxes are often read by assistants and scanners, so t1 on email needs the same second proof as t2) and true for web_push. Turning it on needs a sign-in within 24 hours and is refused while agent_readable is on"},"agent_readable":{"type":"boolean","description":"The owner said an AI assistant can read this channel: link_only_allowed is forced off and a t3 code is never sent here. Turning it off needs a sign-in within 24 hours"},"cooldown_until":{"type":["string","null"],"format":"date-time","description":"Set when a new email channel is verified: for 24 hours it only receives links that can deny (allowed_decisions [deny]). null once over, and always null for the account's own email and the push subscription"},"primary":{"type":"boolean","description":"Created automatically from the account (its sign-in email, its web push subscription); never in cooldown and cannot be deleted (turn approval_links off instead)"},"created_at":{"type":"string","format":"date-time"},"last_delivery_at":{"type":["string","null"],"format":"date-time"},"last_error":{"type":["string","null"],"description":"Last delivery error, if any"}},"example":{"channel_id":"nch_email_primary","type":"email","masked_address":"m***@gmail.com","verified":true,"approval_links":true,"link_only_allowed":false,"agent_readable":false,"cooldown_until":null,"primary":true,"created_at":"2026-09-28T04:00:00.000Z","last_delivery_at":"2026-09-28T05:05:02.000Z","last_error":null}},"ApprovalSettings":{"type":"object","description":"data.settings of GET and PATCH /approval-settings: how this owner confirms approvals from notifications. Everything here is opt-in and only the owner changes it, signed in","required":["links_enabled","link_ttl_seconds","test_link_ttl_seconds","tier_overrides","test_mode_step_up","anti_phishing_phrase","email_digest","updated_at"],"properties":{"links_enabled":{"type":"boolean","description":"Off by default (1.10.0). Turning it on needs at least one verified channel with approval_links on (409 no_verified_channel) and a sign-in within 24 hours; off means approvals are notified as before, without links"},"link_ttl_seconds":{"type":"integer","minimum":300,"maximum":900,"description":"How long a link stays valid on live approvals; default 600, never past the approval's expires_at (400 invalid_ttl outside 300 to 900; raising it needs a recent sign-in)"},"test_link_ttl_seconds":{"type":"integer","minimum":60,"maximum":900,"description":"The same for test_mode approvals; default 600, 60 to 900, so an expiry can be rehearsed without waiting 10 minutes"},"tier_overrides":{"type":"object","additionalProperties":{"type":"string","enum":["t1","t2","t3"]},"description":"Permission name to tier, only stricter than the server default and never below the floor (400 tier_below_floor); send null for a permission to remove its override. Denying is always allowed from a link (T0), including \"deny every pending request of this key\". T1: patrol:reply_send, content:publish_now (live) and every test_mode approval. Pure link when the channel is marked link-only; otherwise the same second proof as T2. T2: patrol:cloud_enable, patrol:browser_command, content:schedule. Needs a second proof: a signed-in browser session, or a 6-digit code sent to any verified channel (the same one is fine). T3: accounts:guardrails, accounts:connect, and any permission not listed here. Needs a signed-in session from the last 24 hours, or a 6-digit code sent to a different channel than the one that carried the link (an owner with a single channel can only use the session)."},"test_mode_step_up":{"type":"string","enum":["off","mirror_live"],"description":"off: every test approval is t1. mirror_live: test approvals use the tier of the live permission, so the step-up path can be rehearsed with a test key (going back to off needs a recent sign-in)"},"anti_phishing_phrase":{"type":"string","description":"2 to 16 characters chosen by the owner, shown in every approval notification and on the card; an empty string means none (400 invalid_phrase otherwise). Lets the owner tell a real notification from a fake one"},"email_digest":{"type":"boolean","description":"Stored in 1.10.0; the digest itself follows in 1.10.1. Until then an email throttled within 10 minutes of the previous one is reported as skipped_throttled and gets no link"},"updated_at":{"type":["string","null"],"format":"date-time"}},"example":{"links_enabled":true,"link_ttl_seconds":600,"test_link_ttl_seconds":60,"tier_overrides":{"content:publish_now":"t2"},"test_mode_step_up":"off","anti_phishing_phrase":"藍色鯨魚","email_digest":true,"updated_at":"2026-09-28T04:00:00.000Z"}},"PostWarning":{"type":"object","required":["code","message","message_zh","detail"],"description":"A reminder that never blocks (1.17.0). Show it to the human before confirming.","properties":{"code":{"type":"string","enum":["off_hours","stale_time_reference","changed_since_last_viewed"],"description":"Stable code"},"message":{"type":"string","description":"English sentence for people; wording may change"},"message_zh":{"type":"string","description":"Traditional Chinese sentence for people; wording may change"},"detail":{"type":"object","description":"off_hours: publish_at, local_time, time_zone, usual_hours[], usual_source (history | schedule | history+schedule | none), posts_considered. stale_time_reference: words[], written_at, publish_at, days_apart, hours_apart, time_zone. changed_since_last_viewed (1.18.0): viewed_at, viewed_by (member | api_key), removed[], added[], removed_count, added_count, media_changed, time_changed (with previous_scheduled_at, scheduled_at), previous_text, current_text, previous_media_urls when media changed, library_id or post_id"}}},"PostWarnings":{"type":"array","items":{"$ref":"#/components/schemas/PostWarning"}},"Key":{"type":"object","required":["id","label","prefix","last4","kind","status","scopes","legacy","scopes_enforced","agent_name","agent_url","created_at","last_used_at"],"properties":{"id":{"type":"string","description":"Key id; equals actor.key_id on write responses"},"label":{"type":"string","description":"Human-chosen label; an empty label reads as legacy-<last4>"},"prefix":{"type":"string","enum":["mt_live","mt_test"],"description":"No trailing underscore"},"last4":{"type":"string"},"kind":{"type":"string","enum":["live","test"]},"status":{"type":"string","const":"active","description":"Always active here: a disabled key cannot call /me (401 key_disabled)"},"scopes":{"type":"object","description":"Permission name to allow | ask | deny (see x-scopes). Enforced from 1.8.0 unless legacy","additionalProperties":{"type":"string","enum":["allow","ask","deny"]}},"legacy":{"type":"boolean","description":"Created before scopes existed; allows everything"},"scopes_enforced":{"type":"boolean","description":"true from 1.8.0 for every key except legacy keys"},"agent_name":{"type":["string","null"],"description":"The AI assistant name the owner entered in Settings (PATCH /keys/{id}); null when empty. An API key cannot set it"},"agent_url":{"type":["string","null"],"description":"The https address the owner entered in Settings (PATCH /keys/{id}); null when empty. An API key cannot set it"},"created_at":{"type":["string","null"],"format":"date-time"},"last_used_at":{"type":["string","null"],"format":"date-time","description":"Last recorded use before the current request; recorded at most once a minute, so it can lag by up to 60 seconds"}}},"Actor":{"type":"object","required":["type","key_id"],"properties":{"type":{"type":"string","enum":["key","human","system"],"description":"key for API calls; human when the owner confirmed an approval (then key_id is null and via_key_id names the key); system for expiry and cancellation"},"key_id":{"type":"string","description":"The API key that made the call (GET /me data.key.id)"},"label":{"type":"string","description":"Only present on GET /me (data.actor). Write responses never carry it, because resellers forward them to end customers"}}}},"headers":{"X-RateLimit-Limit":{"description":"Daily units for this key's pool (live: plan limit per key; sandbox: 500 per member). Same meaning on 429, whichever limit was hit","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Units left today in the daily pool (after this call when it succeeded)","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Epoch seconds of the next 00:00 Asia/Taipei","schema":{"type":"integer"}},"X-RateLimit-Policy":{"description":"`<daily>;w=86400, <per-minute>;w=60`","schema":{"type":"string"}},"X-RateLimit-Scope":{"description":"Who shares the quota counter: `key` (live, per key) or `user` (sandbox, pooled per member). A quota partition, not a permission scope","schema":{"type":"string","enum":["key","user"]}},"X-RateLimit-Sandbox":{"description":"Present and `true` on mt_test_ responses","schema":{"type":"string"}},"Retry-After":{"description":"Seconds to wait; only on 429","schema":{"type":"integer"}},"X-Required-Scope":{"description":"On 403 insufficient_scope, approval_required and approval_not_supported: the permission this request needed (same as error.required[0] or error.scope). MCP clients cannot see headers: read the body","schema":{"type":"string"}}}},"paths":{"/approvals":{"get":{"summary":"List confirmation requests (web app session only; the signed-in owner sees all of theirs)","operationId":"listApprovals","security":[{"firebaseIdToken":[]}],"description":"Firebase ID token of the account owner. An API key gets 401 session_required; a team member gets 403 owner_only. Response: { ok, data: { approvals: Approval[] (plus key_label, key_last4, key_prefix, preview, delivered; from 1.10.0 also the full channels_notified with channel_id and masked_address, decision_via, decision_channel, decided_by, step_up, tier and link_stats { issued, viewed, used }), count, pending } }. An AI assistant that lost its approval_id resends the same request: while the approval is pending it gets the same approval back.","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["pending","approved","executed","failed","denied","expired","cancelled"]}},{"name":"limit","in":"query","schema":{"type":"integer","maximum":100}}],"responses":{"200":{"description":"Approvals"},"401":{"description":"session_required","content":{"application/json":{"example":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"owner_only or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can see confirmation requests","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/approvals/{id}":{"get":{"summary":"Read one approval: an API key sees only approvals it created; the signed-in owner sees theirs","operationId":"getApproval","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearerAuth":[]},{"firebaseIdToken":[]}],"description":"For API keys this is exempt from permissions, subject to the per-minute limit, and does not consume the daily quota. Pending or approved answers carry Retry-After: 15. Poll this instead of resending the original request; the full result is only here (approval.decided carries a summary). A pending approval whose permission the owner has set to deny meanwhile is cancelled when read (cancel_reason permission_set_to_deny). preview.warnings (1.17.0) holds the warnings computed when the approval was created for posts, schedules and library releases; the owner sees them before deciding. For library releases preview.warnings also holds changed_since_last_viewed (1.18.0); when the owner opens a pending library approval, the versions on it count as viewed by the owner.","responses":{"200":{"description":"Approval","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","scope":"content:publish_now","key_id":"K9f2abc","test_mode":false,"action":{"method":"POST","route":"/content/publish","account_id":"utOW1","account_username":"ultraprobe.tw","summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」"},"created_at":"2026-09-24T05:05:00.000Z","expires_at":"2026-09-25T05:05:00.000Z","decided_at":"2026-09-24T05:08:10.000Z","decision":"once","result":{"ok":true,"http_status":200,"post_id":"abc","threads_post_id":"1809...","permalink":"https://www.threads.net/@ultraprobe.tw/post/...","data":{"post":{"id":"abc","status":"published","threads_post_id":"1809..."}}},"tier":"t1","channels_notified":[{"type":"bell","status":"sent"},{"type":"email","status":"sent"}],"decision_via":"link","decision_channel":"email","decided_by":{"type":"human","role":"owner"},"step_up":{"method":"session"},"guardrails_etag_at_request":null,"human_url":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c","human_message":"已送到你的電郵，可以在通知裡直接核准；或打開 https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c：立刻發文到 @ultraprobe.tw：「今天聊聊…」。","poll":"GET /approvals/apr_7QxK2mZ9pLr4tWv8aB1c","event":"approval.decided","execution":"server-side after the owner confirms; the result is in GET /approvals/{id} (result), and approval.decided announces it. Do not resend while it is pending or approved. Once it has ended, follow result.error: approval_base_changed or approval_payload_changed means read the current values again and resend (you get a new approval)."}}}}},"403":{"description":"Signed-in team member","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can view or decide this request. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"approval_not_found","content":{"application/json":{"example":{"error":{"code":"approval_not_found","message":"Approval not found","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"self"}},"/approvals/{id}/remind":{"post":{"summary":"Ask MindThread to remind the owner about a pending approval this key created (1.12.0)","operationId":"remindApproval","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"security":[{"bearerAuth":[]}],"description":"API key only, and only for approvals this key created (any other id answers 404). Exempt from permissions, subject to the per-minute limit, does not consume the daily quota. MindThread re-sends the in-app bell, web push and email, all pointing to the owner's web page /approve/{id}; no new one-time link is issued. Limits: the approval must still be pending with at least 10 minutes left; at least 30 minutes after the last notification (creation or any reminder); at most 3 reminders per approval from the key. The email shares the owner's 10-minute email cooldown, so channels may report email skipped_throttled while bell and push still go out. MindThread also reminds once automatically when an approval has waited 4 hours. Response: { ok, data: { id, reminded: true, remind_count, remind_max, next_remind_after, channels: [{ type: bell|web_push|email, status }], expires_at } }. Do not loop on this: remind once when the human has not answered for a while, then keep polling GET /approvals/{id}.","responses":{"200":{"description":"Reminder sent"},"401":{"description":"unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Use the API key that created this approval.","request_id":"req_mf1x2y3z4abcd"}}}}},"404":{"description":"approval_not_found","content":{"application/json":{"example":{"error":{"code":"approval_not_found","message":"Approval not found (a key can only remind about approvals it created)","request_id":"req_mf1x2y3z4abcd"}}}}},"409":{"description":"Nothing to remind (error.approval has its state)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"approval_not_pending":{"value":{"error":{"code":"approval_not_pending","message":"This request is already executed; there is nothing to remind the owner about.","request_id":"req_mf1x2y3z4abcd"}}},"approval_expiring":{"value":{"error":{"code":"approval_expiring","message":"This request expires in less than 10 minutes, too soon for a reminder to help.","request_id":"req_mf1x2y3z4abcd"}}},"approval_key_revoked":{"value":{"error":{"code":"approval_key_revoked","message":"The API key that sent this request has been disabled, so the owner can no longer approve it.","request_id":"req_mf1x2y3z4abcd"}}},"approval_permission_denied":{"value":{"error":{"code":"approval_permission_denied","message":"The owner set this permission to deny for this key, so the request was cancelled. There is nothing to remind about.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"429":{"description":"Too soon or too many (Retry-After on remind_too_soon)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"remind_too_soon":{"value":{"error":{"code":"remind_too_soon","message":"The owner was notified less than 30 minutes ago. Try again later.","request_id":"req_mf1x2y3z4abcd"}}},"remind_limit_reached":{"value":{"error":{"code":"remind_limit_reached","message":"This request was already reminded 3 times. Wait for the owner, or let it expire.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"503":{"description":"remind_paused","content":{"application/json":{"example":{"error":{"code":"remind_paused","message":"Reminders are paused right now. The owner still sees the request in MindThread.","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"self"}},"/approvals/{id}/decide":{"post":{"summary":"Owner decides: once, always (this key never asks again for this permission) or deny. Web app session only","operationId":"decideApproval","security":[{"firebaseIdToken":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"description":"Only the signed-in owner (not a team member, never an API key). always needs a sign-in within the last 24 hours; a revoked sign-in (password change, sign-out on all devices) is refused. On once / always the server executes the original request itself (idempotency_key approval:<id>, a namespace outside requests cannot use), stores the outcome in result, and emits approval.decided with actor { type: \"human\", key_id: null, via_key_id, label: \"owner\" }. If the key's permission for this approval is deny by now (1.8.1), the approval is cancelled on the spot (cancel_reason permission_set_to_deny) and decide answers 409 approval_permission_denied; always can never turn a deny back into allow. A settings approval (1.8.3) whose touched fields changed since it was created answers 409 approval_base_changed: the approval turns failed, nothing runs and always is not applied; deny is still accepted. Every 409 carries error.approval (the current state). From 1.10.0 a decision made here is recorded with decision_via web, decided_by { type: \"human\", role: \"owner\" } and step_up { method: \"session\" }; the same core also serves the one-time links (POST /a/{lid}/decide), whose error codes differ only on the link surface.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["decision"],"properties":{"decision":{"type":"string","enum":["once","always","deny"]}}}}}},"responses":{"200":{"description":"Decided (and executed when allowed): { ok, data: Approval (+ owner fields, key_scopes_updated), actor }"},"400":{"description":"invalid_decision","content":{"application/json":{"example":{"error":{"code":"invalid_decision","message":"decision must be 'once', 'always' or 'deny'","request_id":"req_mf1x2y3z4abcd"}}}}},"401":{"description":"Not signed in, or sign-in too old / revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to view or decide this request","request_id":"req_mf1x2y3z4abcd"}}},"reauth_required":{"value":{"error":{"code":"reauth_required","message":"Allowing this permission permanently needs a sign-in within the last 24 hours.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"Not the owner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"human_required":{"value":{"error":{"code":"human_required","message":"Only the key owner can decide, signed in to the MindThread web app.","request_id":"req_mf1x2y3z4abcd"}}},"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can view or decide this request. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"approval_not_found","content":{"application/json":{"example":{"error":{"code":"approval_not_found","message":"Approval not found","request_id":"req_mf1x2y3z4abcd"}}}}},"409":{"description":"The approval can no longer be decided (error.approval has its state)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"approval_not_pending":{"value":{"error":{"code":"approval_not_pending","message":"This request is already executed","request_id":"req_mf1x2y3z4abcd"}}},"approval_expired":{"value":{"error":{"code":"approval_expired","message":"This request expired (24 hours).","request_id":"req_mf1x2y3z4abcd"}}},"approval_key_revoked":{"value":{"error":{"code":"approval_key_revoked","message":"The API key that sent this request has been disabled, so it can no longer be approved.","request_id":"req_mf1x2y3z4abcd"}}},"approval_permission_denied":{"value":{"error":{"code":"approval_permission_denied","message":"The owner set this permission to deny for the key that sent this request, so the request was cancelled and can no longer be approved.","request_id":"req_mf1x2y3z4abcd"}}},"approval_base_changed":{"value":{"error":{"code":"approval_base_changed","message":"The account settings this request touches changed after the owner was asked, so the version the owner would confirm no longer exists. Nothing was run.","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/keys/{id}":{"patch":{"summary":"Owner changes an existing key in place: permissions, label, agent_name, agent_url (web app session only)","operationId":"updateKey","security":[{"firebaseIdToken":[]}],"x-audience":"human","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"The key id (GET /me data.key.id, or id in GET /keys)"}],"description":"For the owner in the MindThread web app (Settings, API keys), signed in with a Firebase ID token. An API key gets 401 session_required: an AI assistant can never change its own permissions, and there is no MCP tool for this. Send at least one field. preset replaces all ten permissions; scopes changes only the permissions it lists. With both, preset applies first, then scopes. read is allow or deny only. Any permission change makes the key non-legacy (legacy:false, scopes_enforced:true); GET /me with that key reflects it on its next call (no cache). A label or agent_* change alone leaves permissions and legacy status as they are. Widening any permission (deny to ask or allow, ask to allow) needs a sign-in within the last 24 hours that was not revoked (password change or sign-out on all devices); otherwise 401 reauth_required with reason sign_in_too_old or sign_in_revoked and the widened permissions. Tightening never needs it. Creating a live key wider than standard with POST /keys needs the same sign-in. Send if_scopes_updated_at (the key's scopes_updated_at as you read it; null for a key whose permissions were never set) with any permission change: if the permissions changed since (another tab, or an approval allowed from now on), nothing is saved and the answer is 409 key_changed with error.key, the current state. The web app always sends it, so a stale screen can never widen a permission without showing the widening first. Team members (x-mt-workspace) can change only keys they created (else 403 owner_only), and the preset and values they send must be standard or stricter (else 403 team_scope_limit with too_wide). Another member's key, a missing key or a malformed id: 404 key_not_found. A revoked or disabled key: 409 key_disabled (it cannot be changed or re-enabled). Setting a permission to deny cancels this key's pending approvals for that permission (status cancelled, cancel_reason permission_set_to_deny, approval.decided emitted); data.cancelled_approvals counts them (null only if that step failed after the permission was saved). agent_name (1 to 60 characters) and agent_url (https, no user name or password, up to 300 characters) are shown on GET /me data.key; null or an empty string clears them. Only a signed-in human can set them. label and agent_name refuse line breaks and invisible control characters (C0 and C1 controls, zero-width spaces, bidirectional overrides and isolates, line and paragraph separators); POST /keys applies the same label rule and answers 400 invalid_label instead of cutting the label short.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","minProperties":1,"properties":{"preset":{"type":"string","enum":["conservative","standard","open"]},"scopes":{"type":"object","additionalProperties":false,"description":"Only the permissions to change; the others keep their current value (a legacy key starts from standard)","properties":{"read":{"type":"string","enum":["allow","deny"]},"content:write":{"type":"string","enum":["allow","ask","deny"]},"content:schedule":{"type":"string","enum":["allow","ask","deny"]},"content:publish_now":{"type":"string","enum":["allow","ask","deny"]},"patrol:reply_send":{"type":"string","enum":["allow","ask","deny"]},"patrol:cloud_enable":{"type":"string","enum":["allow","ask","deny"]},"patrol:browser_command":{"type":"string","enum":["allow","ask","deny"]},"accounts:connect":{"type":"string","enum":["allow","ask","deny"]},"accounts:guardrails":{"type":"string","enum":["allow","ask","deny"]},"webhooks:write":{"type":"string","enum":["allow","ask","deny"]}}},"label":{"type":"string","maxLength":50,"description":"Up to 50 characters, no line breaks or invisible control characters; an empty string means unnamed"},"agent_name":{"type":["string","null"],"maxLength":60},"agent_url":{"anyOf":[{"type":"string","format":"uri","pattern":"^https://","maxLength":300},{"type":"string","maxLength":0},{"type":"null"}],"description":"https address; an empty string or null clears it"},"if_scopes_updated_at":{"type":["string","null"],"description":"Precondition for permission changes: scopes_updated_at as you read it (null for a key whose permissions were never set). A mismatch answers 409 key_changed; it does not count as a field to update"}}},"example":{"scopes":{"content:publish_now":"deny"},"if_scopes_updated_at":"2026-09-24T04:30:00.000Z","agent_name":"OpenClaw","agent_url":"https://openclaw.example/agent"}}}},"responses":{"200":{"description":"Saved: { ok, data: { key: OwnerKey, changes: [{ scope, from, to }], cancelled_approvals, cancelled_approval_ids } }","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"key":{"id":"K9f2abc","label":"OpenClaw Agent","prefix":"mt_live","last4":"8f2a","createdAt":"2026-09-24T01:00:00.000Z","lastUsedAt":"2026-09-24T03:12:45.000Z","revoked":false,"kind":"live","scopes":{"read":"allow","content:write":"allow","content:schedule":"allow","content:publish_now":"deny","patrol:reply_send":"ask","patrol:cloud_enable":"ask","patrol:browser_command":"ask","accounts:connect":"ask","accounts:guardrails":"ask","webhooks:write":"allow"},"legacy":false,"scopes_enforced":true,"scopes_updated_at":"2026-09-24T04:30:00.000Z","agent_name":"OpenClaw","agent_url":"https://openclaw.example/agent","createdByUid":"u_owner","viaTeam":false},"changes":[{"scope":"content:publish_now","from":"ask","to":"deny"}],"cancelled_approvals":1,"cancelled_approval_ids":["apr_7QxK2mZ9pLr4tWv8aB1c"]}}}}},"400":{"description":"Invalid body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"nothing_to_update":{"value":{"error":{"code":"nothing_to_update","message":"Send at least one of: preset, scopes, label, agent_name, agent_url","request_id":"req_mf1x2y3z4abcd"}}},"invalid_preset":{"value":{"error":{"code":"invalid_preset","message":"preset must be one of: conservative, standard, open","valid_presets":["conservative","standard","open"],"request_id":"req_mf1x2y3z4abcd"}}},"invalid_scopes":{"value":{"error":{"code":"invalid_scopes","message":"Unknown permission or value: read. Permissions: …. Values: allow, ask, deny (read: allow or deny only).","invalid":["read"],"valid_scopes":["read","content:write","content:schedule","content:publish_now","patrol:reply_send","patrol:cloud_enable","patrol:browser_command","accounts:connect","accounts:guardrails","webhooks:write"],"valid_modes":["allow","ask","deny"],"read_modes":["allow","deny"],"request_id":"req_mf1x2y3z4abcd"}}},"invalid_label":{"value":{"error":{"code":"invalid_label","message":"label must be text of up to 50 characters without line breaks or invisible control characters","request_id":"req_mf1x2y3z4abcd"}}},"invalid_agent_name":{"value":{"error":{"code":"invalid_agent_name","message":"agent_name must be text of 1 to 60 characters without line breaks or invisible control characters, or null to clear it","request_id":"req_mf1x2y3z4abcd"}}},"invalid_agent_url":{"value":{"error":{"code":"invalid_agent_url","message":"agent_url must be a full https:// address without user name or password, up to 300 characters, or null to clear it","request_id":"req_mf1x2y3z4abcd"}}},"invalid_request":{"value":{"error":{"code":"invalid_request","message":"Send a JSON object with at least one of: preset, scopes, label, agent_name, agent_url","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"Not a signed-in human, or the sign-in is too old or revoked for widening","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session. The calling key's metadata is on GET /me under data.key.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage API keys","request_id":"req_mf1x2y3z4abcd"}}},"reauth_required":{"value":{"error":{"code":"reauth_required","message":"Widening a permission needs a sign-in within the last 24 hours. Sign in again and retry.","reason":"sign_in_too_old","widened":["content:publish_now"],"request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"Team member limits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the workspace owner can change this key. Team members can change only keys they created.","request_id":"req_mf1x2y3z4abcd"}}},"team_scope_limit":{"value":{"error":{"code":"team_scope_limit","message":"Team members can only set the standard permissions or stricter (the six sensitive permissions at ask at most). The owner can allow more.","too_wide":["content:publish_now"],"max_preset":"standard","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"Not this member's key (existence is not revealed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"key_not_found":{"value":{"error":{"code":"key_not_found","message":"Key not found","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"The key is revoked or disabled, or its permissions changed since you read them","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This key has been revoked or disabled. A disabled key cannot be changed or re-enabled; create a new key instead.","key_id":"K9f2abc","request_id":"req_mf1x2y3z4abcd"}}},"key_changed":{"value":{"error":{"code":"key_changed","message":"This key's permissions changed after you loaded them (another tab, or an approval allowed from now on). Nothing was saved; error.key is the current state. Review it and send again.","key":{"id":"K9f2abc","label":"OpenClaw Agent","prefix":"mt_live","last4":"8f2a","createdAt":"2026-09-24T01:00:00.000Z","lastUsedAt":"2026-09-24T03:12:45.000Z","revoked":false,"kind":"live","scopes":{"read":"allow","content:write":"allow","content:schedule":"allow","content:publish_now":"deny","patrol:reply_send":"ask","patrol:cloud_enable":"ask","patrol:browser_command":"ask","accounts:connect":"ask","accounts:guardrails":"ask","webhooks:write":"allow"},"legacy":false,"scopes_enforced":true,"scopes_updated_at":"2026-09-24T04:30:00.000Z","agent_name":"OpenClaw","agent_url":"https://openclaw.example/agent","createdByUid":"u_owner","viaTeam":false},"scopes_updated_at":"2026-09-24T04:30:00.000Z","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/accounts/{account_id}/guardrails/history":{"get":{"summary":"Guardrail change history of an account (newest first)","operationId":"listGuardrailChanges","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50}},{"name":"before","in":"query","description":"next_before of the previous page","schema":{"type":"string"}}],"description":"Every change to a guardrail made through the API, by an approval or by the system writes a revision that is never edited or deleted: GET /accounts/{id}/guardrails/history (read permission, newest first, limit up to 50, before=next_before for the next page) lists id, at, source (api, approval, rollback or system), actor, mine, changed_fields, loosened, tightened, gap_before, before, after and restore_body; approval_id, request_id and reason only on revisions your own key made. PATCH accepts reason (up to 200 characters, plain text, links removed) to explain a change. gap_before:true means the guardrails changed outside the record since the previous revision (in the web app, or before 1.9.0); those changes are not recorded by name yet. A system revision (actor type system) records the server pausing an account (its authorization failed, it is blocked or publishing keeps failing) or turning it back on after a reconnect or token refresh, with system_reason; it cannot be undone. Test keys read live revisions and write none. Shared policy, minimal version: the guardrails on the account are the active policy for every key and automation on it; a pending settings approval is the desired (proposed) change; the owner confirming it applies it. There is no separate policy object or proposal endpoint yet.","responses":{"200":{"description":"{ ok, data: { account_id, count, revisions: GuardrailRevision[], next_before, note } }","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"type":"object","required":["account_id","count","revisions","next_before"],"properties":{"account_id":{"type":"string"},"count":{"type":"integer"},"revisions":{"type":"array","items":{"$ref":"#/components/schemas/GuardrailRevision"}},"next_before":{"type":["string","null"]},"note":{"type":"string"}}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"account_id":"utOW1","count":1,"revisions":[{"id":"grv_4f1c2a9e0b7d3e55","at":"2026-09-25T03:10:00.000Z","source":"api","actor":{"type":"key","key_id":"K9f2abc"},"mine":true,"changed_fields":["content_rules"],"loosened":[],"tightened":["banned_phrases_added"],"gap_before":false,"gap_fields":[],"rollback_of":null,"before":{"content_rules":{"max_chars":220,"min_chars":80,"forbid_cta":true,"forbid_hashtags":true,"banned_phrases":["保證獲利"],"enforce":"block","facts":["客戶 120 位"],"forbid_causal_claims":false,"one_fact_per_post":false,"mention_limits":[],"judge_claims":false},"review_before_publish":true,"auto_reply_enabled":false,"video_autopilot":false,"enabled":true},"after":{"content_rules":{"max_chars":220,"min_chars":80,"forbid_cta":true,"forbid_hashtags":true,"banned_phrases":["保證獲利","競品A"],"enforce":"block","facts":["客戶 120 位"],"forbid_causal_claims":false,"one_fact_per_post":false,"mention_limits":[],"judge_claims":false},"review_before_publish":true,"auto_reply_enabled":false,"video_autopilot":false,"enabled":true},"restore_body":{"content_rules":{"max_chars":220,"min_chars":80,"forbid_cta":true,"forbid_hashtags":true,"banned_phrases":["保證獲利"],"enforce":"block","facts":["客戶 120 位"],"forbid_causal_claims":false,"one_fact_per_post":false,"mention_limits":[],"judge_claims":false}},"approval_id":null,"request_id":"req_mf1x2y3z4abcd","reason":"擁有者要求不提競品"}],"next_before":null}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"404":{"description":"account_not_found or revision_not_found (before does not name a revision of this account)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"revision_not_found":{"value":{"error":{"code":"revision_not_found","message":"No guardrail revision grv_… on this account. Pass next_before from the previous page.","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"read"}},"/accounts/{account_id}/guardrails/rollback":{"post":{"summary":"Owner undoes one guardrail revision (web app session only)","operationId":"rollbackGuardrails","security":[{"firebaseIdToken":[]}],"x-audience":"human","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}}],"description":"The owner can undo one revision: POST /accounts/{id}/guardrails/rollback { revision_id, if_match } (web app session only, x-audience human; an API key gets 401 session_required, a team member 403 owner_only; in the web app the owner presses the undo button in the change history on the page /accounts/{id}/guardrails). It restores the fields that revision changed to their previous values, only while they still hold the values that revision wrote; otherwise it answers 409 rollback_conflict with later_revision_id (the later revision that changed them) or changed_outside_record:true, and nothing changes. If those fields already hold their previous values, it answers 200 with already_rolled_back:true and writes nothing. An undo is recorded as a revision with source rollback. An undo that loosens a guardrail needs a sign-in within 24 hours (401 reauth_required). To undo through the API instead, send restore_body with if_match as a normal PATCH: loosening still needs the owner.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["revision_id"],"properties":{"revision_id":{"type":"string"},"if_match":{"type":"string","description":"Optional etag; compared only on the fields that revision changed"}}}}}},"responses":{"200":{"description":"Undone, or already_rolled_back:true when those fields already held their previous values (nothing written)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/GuardrailRollbackResult"},"actor":{"type":"object","properties":{"type":{"type":"string","enum":["key","human","system"]},"key_id":{"type":["string","null"]},"via_key_id":{"type":"string","description":"Only when source is approval: the key that asked"}}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"account_id":"utOW1","rolled_back":"grv_4f1c2a9e0b7d3e55","already_rolled_back":false,"rolled_back_by":null,"restored_fields":["content_rules"],"revision_id":"grv_9a8b7c6d5e4f3a2b","etag":"g1.77aa0c12e4d3b2a1.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","loosened":["banned_phrases_removed"],"tightened":[]},"actor":{"type":"human","key_id":null,"label":"owner"}}}}},"400":{"description":"invalid_request or invalid_if_match","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"invalid_request":{"value":{"error":{"code":"invalid_request","message":"revision_id is required","request_id":"req_mf1x2y3z4abcd"}}},"invalid_if_match":{"value":{"error":{"code":"invalid_if_match","message":"if_match must be the guardrails.etag from GET /accounts/{id}/settings","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"session_required (an API key), unauthorized, or reauth_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"reauth_required":{"value":{"error":{"code":"reauth_required","message":"Widening a permission needs a sign-in within the last 24 hours. Sign in again and retry.","request_id":"req_mf1x2y3z4abcd","reason":"sign_in_too_old","widened":["banned_phrases_removed"]}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can undo a guardrail change. Team members can read the history but cannot undo it.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"account_not_found or revision_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"revision_not_found":{"value":{"error":{"code":"revision_not_found","message":"No such guardrail revision on this account","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"rollback_conflict: those guardrails changed after that revision; later_revision_id names the later revision that changed them, or changed_outside_record is true. system_revision: a system revision cannot be undone","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"system_revision":{"value":{"error":{"code":"system_revision","message":"This revision was made by the system (it pauses an account when its authorization fails, it is blocked or publishing keeps failing, and turns it back on after a reconnect or token refresh), so it cannot be undone. Fix the cause in the web app instead, for example reconnect the account, or change the setting directly.","request_id":"req_mf1x2y3z4abcd"}}},"rollback_conflict":{"value":{"error":{"code":"rollback_conflict","message":"Those guardrails changed again after that revision (see later_revision_id), so undoing it would overwrite that later change. Nothing was changed. Read the later revision before deciding what to undo.","request_id":"req_mf1x2y3z4abcd","fields":["content_rules"],"current":{"content_rules":{"max_chars":220,"min_chars":80,"forbid_cta":true,"forbid_hashtags":true,"banned_phrases":["保證獲利","競品A"],"enforce":"block","facts":["客戶 120 位"],"forbid_causal_claims":false,"one_fact_per_post":false,"mention_limits":[],"judge_claims":false}},"current_etag":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","later_revision_id":"grv_0c1d2e3f4a5b6c7d","changed_outside_record":false,"rolled_back_by":null,"last_change":{"revision_id":"grv_4f1c2a9e0b7d3e55","at":"2026-09-25T03:10:00.000Z","source":"api","actor":{"type":"key","key_id":"K9f2abc"},"mine":true,"loosened":[],"tightened":["banned_phrases_added"],"gap_before":false}}}}}}}},"412":{"description":"guardrails_changed (if_match does not match)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GuardrailsChangedError"}}}}},"x-scope":"session"}},"/a/{lid}/view":{"post":{"summary":"The card behind a one-time approval link (for the owner's browser; does not use the link up)","operationId":"approvalLinkView","x-audience":"human","security":[],"parameters":[{"name":"lid","in":"path","required":true,"schema":{"type":"string","pattern":"^al_[0-9A-Za-z]{20}$"},"description":"al_ followed by 20 characters: the lookup key of the link (not secret). The secret k travels only in the URL fragment and in the POST body"}],"description":"Called by the card page https://mindthread.tw/a/{lid} after it read the secret k from the URL fragment and removed it from the address bar (the page itself is static and holds no data, so mail scanners and link previews learn nothing). Answers the card: the link (channel, expiry, allowed decisions, tier, state, step-up), the approval as the owner should see it, a csrf token for decide, and the owner's anti-phishing phrase. Repeatable and free of side effects apart from a link_viewed entry in the owner's activity log (at most one per 5 minutes). A used, expired, superseded or revoked link still answers 200 with its state, step_up null, csrf null (and no cookie) and a summary of the approval, so the owner sees the outcome. Reading also settles the approval like GET /approvals/{id} does: a permission set to deny meanwhile cancels it, a changed settings base fails it. Sets the cookie __Host-mt_al (Secure, HttpOnly, SameSite=Strict, 15 minutes) that decide checks together with csrf. 1.10.0 channels: email and web_push; LINE follows. For humans (x-audience human). An API key is ignored here entirely: Authorization: Bearer mt_… neither authenticates nor is recorded, and a missing or wrong secret answers 404 approval_link_not_found, the same answer as an unknown link. Not part of the key quota (no X-RateLimit-* headers); own rate limit, 429 rate_limit_exceeded with window approval_link.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["k"],"properties":{"k":{"type":"string","description":"The secret from the URL fragment (43 characters base64url). Never logged, never shown to any API key"}}},"example":{"k":"kQ3w9Zr1Lx8vT5nB2pH6mC4dF7sJ0aY9eG1uK3iO5tW"}}}},"responses":{"200":{"description":"Card (ApprovalLinkView)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ApprovalLinkView"}}}]},"examples":{"publish_now_t1":{"summary":"A live publish_now approval (t1) sent to the owner's email: email is not link-only, so the same second proof as t2 is needed (silent when the browser is signed in)","value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"link":{"lid":"al_4k2P9xQzR7mN1bV8cT3w","channel":"email","expires_at":"2026-09-24T05:15:00.000Z","allowed_decisions":["once","deny"],"tier":"t1","state":"active","reissue_available":false,"step_up":{"required":true,"satisfied_by_session":false,"session_mismatch":false,"session_too_old":false,"methods":["session","code"],"code_channels":[{"channel_id":"nch_email_primary","type":"email","masked":"m***@gmail.com"}],"reason":"channel_not_link_only"}},"approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"pending","scope":"content:publish_now","scope_label":"立刻發文","test_mode":false,"action":{"method":"POST","route":"/content/publish","account_id":"utOW1","account_username":"ultraprobe.tw","summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」"},"requested_by":{"key_id":"K9f2abc","label":"OpenClaw Agent","prefix":"mt_live","last4":"8f2a","agent_name":"OpenClaw","agent_domain":"openclaw.example"},"diff":null,"base":{"guardrails_etag_at_request":null,"fresh":true,"changed":[]},"agent_content":{"text":"今天聊聊…","media_count":0,"video":false,"publish_target":"ultraprobe.tw","publish_at":null,"publish_now":true,"thread_parts":null,"items":null,"target_post":null},"agent_note":null,"preview":{"kind":"post","text":"今天聊聊…","media_count":0,"publish_now":true},"created_at":"2026-09-24T05:05:00.000Z","expires_at":"2026-09-25T05:05:00.000Z","decision":null,"decision_via":null,"decided_at":null,"cancel_reason":null,"result":null},"csrf":"c1.9f3a2b7c4d1e8f60a5b2c9d7e4f1a3b8","anti_phishing_phrase":"藍色鯨魚","web_fallback":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c"}}},"settings_t3":{"summary":"A guardrail loosening (t3): a signed-in session from the last 24 hours, or a code on a channel other than the one that carried the link","value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"link":{"lid":"al_9sT2vKq4Lm7nB1xZ3cRw","channel":"email","expires_at":"2026-09-28T08:19:00.000Z","allowed_decisions":["once","deny"],"tier":"t3","state":"active","reissue_available":false,"step_up":{"required":true,"satisfied_by_session":false,"session_mismatch":false,"session_too_old":false,"methods":["session","code"],"code_channels":[{"channel_id":"nch_push_primary","type":"web_push","masked":null}],"reason":"tier_t3"}},"approval":{"id":"apr_3Hn8VqLm2sKd7wPz1xRa","status":"pending","scope":"accounts:guardrails","scope_label":"放寬帳號護欄","test_mode":false,"action":{"method":"PATCH","route":"/accounts/utOW1/settings","account_id":"utOW1","account_username":"ultraprobe.tw","summary":"放寬 @ultraprobe.tw 的護欄：放寬字數上限"},"requested_by":{"key_id":"K9f2abc","label":"Grok P2-5 E2E","prefix":"mt_live","last4":"a1b2","agent_name":null,"agent_domain":null},"diff":[{"field":"content_rules.max_chars","current":500,"proposed":501,"kind":"loosened","label":"字數上限"}],"base":{"guardrails_etag_at_request":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","fresh":true,"changed":[]},"agent_content":null,"agent_note":"P2-5-E2E-OWNER loosen","preview":{"kind":"guardrails","fields":[{"field":"content_rules.max_chars","changed":true,"loosens":true,"current":500,"proposed":501}]},"created_at":"2026-09-28T08:09:00.000Z","expires_at":"2026-09-29T08:09:00.000Z","decision":null,"decision_via":null,"decided_at":null,"cancel_reason":null,"result":null},"csrf":"c1.77aa0c12e4d3b2a18b7d1e22c9a0f311","anti_phishing_phrase":"藍色鯨魚","web_fallback":"https://mindthread.tw/approve/apr_3Hn8VqLm2sKd7wPz1xRa"}}},"used":{"summary":"The same link after the owner decided: state used, step_up null, the approval summary shows the outcome","value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"link":{"lid":"al_4k2P9xQzR7mN1bV8cT3w","channel":"email","expires_at":"2026-09-24T05:15:00.000Z","allowed_decisions":[],"tier":"t1","state":"used","reissue_available":false,"step_up":null},"approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"csrf":"c1.9f3a2b7c4d1e8f60a5b2c9d7e4f1a3b8","anti_phishing_phrase":"藍色鯨魚","web_fallback":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c"}}}}}}},"404":{"description":"approval_link_not_found: unknown lid or wrong secret, the same answer for both (constant-time comparison; 10 wrong secrets revoke the link)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_not_found":{"value":{"error":{"code":"approval_link_not_found","message":"This approval link is not valid.","fix":"Open the link from the original notification again, or sign in at https://mindthread.tw/approve to see the requests waiting for you. 中文：請從原通知重新開啟連結，或登入 mindthread.tw/approve 查看待確認的請求。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"429":{"description":"rate_limit_exceeded with window approval_link (20 requests a minute per link, 60 per IP, 200 an hour per owner; not the key quota, no X-RateLimit-* headers)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"rate_limit_exceeded":{"value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests. Retry after 60 seconds.","window":"approval_link","retry_after_seconds":60,"request_id":"req_mf1x2y3z4abcd"}}}}}}},"503":{"description":"approval_links_disabled: the global kill flag is off (web_fallback is /approve) or the owner turned links off (web_fallback is /approve/{id})","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_links_disabled":{"value":{"error":{"code":"approval_links_disabled","message":"Approval links are turned off right now.","fix":"Decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：連結核准目前關閉，請登入後到 /approve 頁決定。","web_fallback":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"link"}},"/a/{lid}/decide":{"post":{"summary":"Owner decides from the link: once (allow this one request) or deny. Uses the link up","operationId":"approvalLinkDecide","x-audience":"human","security":[],"parameters":[{"name":"lid","in":"path","required":true,"schema":{"type":"string","pattern":"^al_[0-9A-Za-z]{20}$"},"description":"al_ followed by 20 characters: the lookup key of the link (not secret). The secret k travels only in the URL fragment and in the POST body"}],"description":"Same core as POST /approvals/{id}/decide (the web page): checks the key is still active and the permission still ask, reruns the base check of a settings approval, then writes the decision, executes the original request server-side (idempotency_key approval:<id>), emits approval.decided with decision_via link and records decision_channel, decided_by { type: \"human\", role: \"owner\" } and step_up { method }. The link is single use: the same transaction marks it used and supersedes the other links of the approval. Order of checks: the secret (404 approval_link_not_found), the csrf from view with its cookie (403 csrf_failed; a card left open longer than the 15-minute cookie gets this, and the card page then calls view again), the link state (409 approval_link_used, 410 approval_link_revoked or approval_link_expired), then the decision (403 decision_not_allowed_via_link for always or for once on a channel in its 24-hour cooldown, 400 invalid_decision), then the approval (409 approval_already_decided, approval_expired, approval_key_revoked, approval_permission_denied, approval_stale), then the step-up for once (401 step_up_required or step_up_failed, 429 step_up_locked after 5 wrong codes, 403 approval_link_wrong_user when the signed-in browser belongs to another account). Needs Origin https://mindthread.tw, Sec-Fetch-Site same-origin when the browser sends it, the __Host-mt_al cookie and the csrf from view (else 403 csrf_failed). A session step-up is the header Authorization: Bearer <Firebase ID token of the owner>; a revoked sign-in does not count. deny never needs a step-up and, three times in 30 minutes for the same key, tells the owner to consider disabling that key. Test approvals: the request runs as a mock (persisted:false) like on the web. For humans (x-audience human). An API key is ignored here entirely: Authorization: Bearer mt_… neither authenticates nor is recorded, and a missing or wrong secret answers 404 approval_link_not_found, the same answer as an unknown link. Not part of the key quota (no X-RateLimit-* headers); own rate limit, 429 rate_limit_exceeded with window approval_link.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkDecideRequest"},"examples":{"link_only_or_session":{"summary":"Pure link (t1 on a link-only channel), or session step-up carried in the Authorization header","value":{"k":"kQ3w9Zr1Lx8vT5nB2pH6mC4dF7sJ0aY9eG1uK3iO5tW","decision":"once","csrf":"c1.9f3a2b7c4d1e8f60a5b2c9d7e4f1a3b8"}},"code":{"summary":"Code step-up after POST /a/{lid}/step-up/code","value":{"k":"kQ3w9Zr1Lx8vT5nB2pH6mC4dF7sJ0aY9eG1uK3iO5tW","decision":"once","csrf":"c1.9f3a2b7c4d1e8f60a5b2c9d7e4f1a3b8","step_up":{"method":"code","code":"482913","channel_id":"nch_email_primary"}}}}}}},"responses":{"200":{"description":"Decided: { ok, data: { approval { id, status, decision, decision_via, decision_channel, decided_by, step_up, decided_at, result, permalink? }, next }, actor }. status approved = the server is still executing (poll the card: view answers state used with the latest status, or open the web page); executed or failed = already finished, result is the summary; denied = nothing runs. next is a Chinese sentence for the card","content":{"application/json":{"examples":{"approved":{"value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"approved","decision":"once","decision_via":"link","decision_channel":"email","decided_by":{"type":"human","role":"owner"},"step_up":{"method":"session"},"decided_at":"2026-09-24T05:08:10.000Z","result":null},"next":"執行中，結果會出現在 https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c；你可以關閉此頁。"},"actor":{"type":"human","key_id":null,"via_key_id":"K9f2abc","label":"owner"}}},"denied":{"value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"denied","decision":"deny","decision_via":"link","decision_channel":"email","decided_by":{"type":"human","role":"owner"},"step_up":{"method":"none"},"decided_at":"2026-09-24T05:08:10.000Z","result":null},"next":"已拒絕，不會執行。"},"actor":{"type":"human","key_id":null,"via_key_id":"K9f2abc","label":"owner"}}}}}}},"400":{"description":"invalid_decision (not once or deny)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"invalid_decision":{"value":{"error":{"code":"invalid_decision","message":"decision must be 'once' or 'deny' (always is decided only at /approve/{id})","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"step_up_required (this tier needs a second proof: sign in, or ask for a code; error.step_up says which) or step_up_failed (wrong, expired or misdirected code; attempts_left, reason wrong_code | code_expired | channel_mismatch)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"step_up_required":{"value":{"error":{"code":"step_up_required","message":"This decision needs a second proof that it is you.","fix":"Open the link in a browser where you are signed in to MindThread, or ask for a verification code. 中文：用已登入 MindThread 的瀏覽器開啟這條連結，或索取驗證碼。","step_up":{"methods":["session","code"],"code_channels":[{"channel_id":"nch_email_primary","type":"email","masked":"m***@gmail.com"}],"reason":"channel_not_link_only"},"request_id":"req_mf1x2y3z4abcd"}}},"step_up_failed":{"value":{"error":{"code":"step_up_failed","message":"The verification did not pass.","fix":"Check the code and try again; after 5 wrong attempts this link is locked. 中文：確認驗證碼後再試，錯 5 次這條連結就會鎖定。","attempts_left":3,"reason":"wrong_code","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"approval_link_wrong_user, decision_not_allowed_via_link or csrf_failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_wrong_user":{"value":{"error":{"code":"approval_link_wrong_user","message":"You are signed in to a different MindThread account than the one this request belongs to.","fix":"Sign in with the account that owns this key, or use a verification code instead of the session. 中文：你目前登入的是另一個帳號，請換成擁有這把金鑰的帳號，或改用驗證碼。","request_id":"req_mf1x2y3z4abcd"}}},"decision_not_allowed_via_link":{"value":{"error":{"code":"decision_not_allowed_via_link","message":"This decision cannot be made from a link.","fix":"To allow this permission permanently, sign in at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c. A link on a channel verified less than 24 hours ago can only deny. 中文：永久允許請登入後到 /approve 頁；驗證完不到 24 小時的管道只能拒絕。","allowed_decisions":["deny"],"request_id":"req_mf1x2y3z4abcd"}}},"csrf_failed":{"value":{"error":{"code":"csrf_failed","message":"This request did not come from the approval page.","fix":"Reload the approval page and try again. 中文：請重新整理此頁再試。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"approval_link_not_found: unknown lid or wrong secret, the same answer for both (constant-time comparison; 10 wrong secrets revoke the link)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_not_found":{"value":{"error":{"code":"approval_link_not_found","message":"This approval link is not valid.","fix":"Open the link from the original notification again, or sign in at https://mindthread.tw/approve to see the requests waiting for you. 中文：請從原通知重新開啟連結，或登入 mindthread.tw/approve 查看待確認的請求。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"The link is valid but the request cannot be decided this way any more (error.approval has its state)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_used":{"value":{"error":{"code":"approval_link_used","message":"This approval link was already used.","fix":"Nothing to do: the request was already handled. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這條連結已使用過，請求已處理，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_already_decided":{"value":{"error":{"code":"approval_already_decided","message":"This request was already decided.","fix":"Nothing to do: see https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這個請求已經有人決定了，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"denied","decision":"deny","decision_via":"web","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_expired":{"value":{"error":{"code":"approval_expired","message":"This request expired (24 hours).","fix":"Nothing to do: see https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這個請求已經有人決定了，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"expired","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_key_revoked":{"value":{"error":{"code":"approval_key_revoked","message":"The API key that sent this request has been disabled, so it can no longer be approved.","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"cancelled","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":"key_disabled_self","result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_permission_denied":{"value":{"error":{"code":"approval_permission_denied","message":"The owner set this permission to deny for the key that sent this request, so the request was cancelled and can no longer be approved.","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"cancelled","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":"permission_set_to_deny","result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_stale":{"value":{"error":{"code":"approval_stale","message":"The settings this request touches changed after the owner was asked, so the version you would approve no longer exists. Nothing ran.","fix":"Ask the AI assistant to read the current settings again and resend the request; you will get a new link. 中文：你要核准的版本已不存在，請 AI 助手重讀設定後重送。","stale_reason":"base_changed","changed":["content_rules"],"current_etag":"g1.77aa0c12e4d3b2a1.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","approval":{"id":"apr_3Hn8VqLm2sKd7wPz1xRa","status":"failed","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":false,"http_status":409},"action":{"summary":"放寬 @ultraprobe.tw 的護欄：放寬字數上限","account_username":"ultraprobe.tw"},"result":{"error":{"code":"approval_base_changed"}}},"request_id":"req_mf1x2y3z4abcd"}}}}}}},"410":{"description":"approval_link_expired (the request may still be pending: reissue_available) or approval_link_revoked (reason)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_expired":{"value":{"error":{"code":"approval_link_expired","message":"This approval link has expired; the request itself may still be waiting.","fix":"Press \"resend the link\" to get a new one on the same channel, or decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：按「重新寄送連結」，或登入後到 /approve 頁決定。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"pending","expires_at":"2026-09-25T05:05:00.000Z"},"reissue_available":true,"request_id":"req_mf1x2y3z4abcd"}}},"approval_link_revoked":{"value":{"error":{"code":"approval_link_revoked","message":"This approval link is no longer valid.","fix":"The request was decided through another link or the link was withdrawn. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for its state. 中文：這條連結已作廢（可能已用別的連結決定），狀態請見 /approve 頁。","reason":"superseded","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}}}}}},"429":{"description":"rate_limit_exceeded with window approval_link (20 requests a minute per link, 60 per IP, 200 an hour per owner; not the key quota, no X-RateLimit-* headers), or step_up_locked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"rate_limit_exceeded":{"value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests. Retry after 60 seconds.","window":"approval_link","retry_after_seconds":60,"request_id":"req_mf1x2y3z4abcd"}}},"step_up_locked":{"value":{"error":{"code":"step_up_locked","message":"This link is locked after too many failed verification attempts.","fix":"Sign in at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c to decide. 中文：此連結已鎖定，請登入後到 /approve 頁決定。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"503":{"description":"approval_links_disabled: the global kill flag is off (web_fallback is /approve) or the owner turned links off (web_fallback is /approve/{id})","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_links_disabled":{"value":{"error":{"code":"approval_links_disabled","message":"Approval links are turned off right now.","fix":"Decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：連結核准目前關閉，請登入後到 /approve 頁決定。","web_fallback":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"link"}},"/a/{lid}/step-up/code":{"post":{"summary":"Send a 6-digit verification code to one of the owner's channels (second proof for a t2 or t3 link, or a t1 link on a channel that is not link-only)","operationId":"approvalLinkStepUpCode","x-audience":"human","security":[],"parameters":[{"name":"lid","in":"path","required":true,"schema":{"type":"string","pattern":"^al_[0-9A-Za-z]{20}$"},"description":"al_ followed by 20 characters: the lookup key of the link (not secret). The secret k travels only in the URL fragment and in the POST body"}],"description":"Sends a 6-digit code to channel_id, one of the code_channels the view listed: t2 accepts any verified channel (the one that carried the link is fine), t3 only a channel other than the one that carried the link, never a channel marked agent_readable (otherwise 400 invalid_channel with code_channels). The code is valid 5 minutes, single use, stored only as a hash; at most 3 codes per link per 10 minutes (429 rate_limit_exceeded); the link locks after 5 wrong codes on decide (429 step_up_locked). A link that needs no second proof answers 400 invalid_request. Needs the csrf from view. 1.10.0 code channels: email and web_push. For humans (x-audience human). An API key is ignored here entirely: Authorization: Bearer mt_… neither authenticates nor is recorded, and a missing or wrong secret answers 404 approval_link_not_found, the same answer as an unknown link. Not part of the key quota (no X-RateLimit-* headers); own rate limit, 429 rate_limit_exceeded with window approval_link.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["k","csrf","channel_id"],"properties":{"k":{"type":"string","description":"The secret from the URL fragment (43 characters base64url). Never logged, never shown to any API key"},"csrf":{"type":"string","description":"The csrf value POST /a/{lid}/view returned; checked together with the __Host-mt_al cookie, Origin https://mindthread.tw and Sec-Fetch-Site same-origin when the browser sends it"},"channel_id":{"type":"string","description":"One of step_up.code_channels[].channel_id from the view"}}},"example":{"k":"kQ3w9Zr1Lx8vT5nB2pH6mC4dF7sJ0aY9eG1uK3iO5tW","csrf":"c1.9f3a2b7c4d1e8f60a5b2c9d7e4f1a3b8","channel_id":"nch_email_primary"}}}},"responses":{"200":{"description":"Sent: { ok, data: { sent, channel { channel_id, type, masked }, expires_at, attempts_left } }","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"sent":true,"channel":{"channel_id":"nch_email_primary","type":"email","masked":"m***@gmail.com"},"expires_at":"2026-09-24T05:13:00.000Z","attempts_left":5}}}}},"400":{"description":"invalid_channel (channel_id is not one of the channels a code may go to for this link; error.code_channels lists them) or invalid_request (this link needs no second proof)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"invalid_channel":{"value":{"error":{"code":"invalid_channel","message":"The code must go to a verified channel other than the one that carried this link (and not one an AI assistant can read).","code_channels":[{"channel_id":"nch_push_primary","type":"web_push"}],"request_id":"req_mf1x2y3z4abcd"}}},"invalid_request":{"value":{"error":{"code":"invalid_request","message":"This link needs no second proof: press approve directly.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"csrf_failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"csrf_failed":{"value":{"error":{"code":"csrf_failed","message":"This request did not come from the approval page.","fix":"Reload the approval page and try again. 中文：請重新整理此頁再試。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"approval_link_not_found: unknown lid or wrong secret, the same answer for both (constant-time comparison; 10 wrong secrets revoke the link)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_not_found":{"value":{"error":{"code":"approval_link_not_found","message":"This approval link is not valid.","fix":"Open the link from the original notification again, or sign in at https://mindthread.tw/approve to see the requests waiting for you. 中文：請從原通知重新開啟連結，或登入 mindthread.tw/approve 查看待確認的請求。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"The link is used, or the request was decided elsewhere or can no longer be decided (error.approval)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_used":{"value":{"error":{"code":"approval_link_used","message":"This approval link was already used.","fix":"Nothing to do: the request was already handled. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這條連結已使用過，請求已處理，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_already_decided":{"value":{"error":{"code":"approval_already_decided","message":"This request was already decided.","fix":"Nothing to do: see https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這個請求已經有人決定了，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"denied","decision":"deny","decision_via":"web","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_expired":{"value":{"error":{"code":"approval_expired","message":"This request expired (24 hours).","fix":"Nothing to do: see https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這個請求已經有人決定了，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"expired","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_key_revoked":{"value":{"error":{"code":"approval_key_revoked","message":"The API key that sent this request has been disabled, so it can no longer be approved.","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"cancelled","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":"key_disabled_self","result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_permission_denied":{"value":{"error":{"code":"approval_permission_denied","message":"The owner set this permission to deny for the key that sent this request, so the request was cancelled and can no longer be approved.","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"cancelled","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":"permission_set_to_deny","result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_stale":{"value":{"error":{"code":"approval_stale","message":"The settings this request touches changed after the owner was asked, so the version you would approve no longer exists. Nothing ran.","fix":"Ask the AI assistant to read the current settings again and resend the request; you will get a new link. 中文：你要核准的版本已不存在，請 AI 助手重讀設定後重送。","stale_reason":"base_changed","changed":["content_rules"],"current_etag":"g1.77aa0c12e4d3b2a1.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","approval":{"id":"apr_3Hn8VqLm2sKd7wPz1xRa","status":"failed","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":false,"http_status":409},"action":{"summary":"放寬 @ultraprobe.tw 的護欄：放寬字數上限","account_username":"ultraprobe.tw"},"result":{"error":{"code":"approval_base_changed"}}},"request_id":"req_mf1x2y3z4abcd"}}}}}}},"410":{"description":"The link expired or was revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_expired":{"value":{"error":{"code":"approval_link_expired","message":"This approval link has expired; the request itself may still be waiting.","fix":"Press \"resend the link\" to get a new one on the same channel, or decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：按「重新寄送連結」，或登入後到 /approve 頁決定。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"pending","expires_at":"2026-09-25T05:05:00.000Z"},"reissue_available":true,"request_id":"req_mf1x2y3z4abcd"}}},"approval_link_revoked":{"value":{"error":{"code":"approval_link_revoked","message":"This approval link is no longer valid.","fix":"The request was decided through another link or the link was withdrawn. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for its state. 中文：這條連結已作廢（可能已用別的連結決定），狀態請見 /approve 頁。","reason":"superseded","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}}}}}},"429":{"description":"rate_limit_exceeded with window approval_link (20 requests a minute per link, 60 per IP, 200 an hour per owner; not the key quota, no X-RateLimit-* headers); here also after 3 codes in 10 minutes","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"rate_limit_exceeded":{"value":{"error":{"code":"rate_limit_exceeded","message":"Too many codes were sent for this link; wait or decide at /approve.","window":"approval_link","retry_after_seconds":540,"request_id":"req_mf1x2y3z4abcd"}}}}}}},"503":{"description":"approval_links_disabled: the global kill flag is off (web_fallback is /approve) or the owner turned links off (web_fallback is /approve/{id})","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_links_disabled":{"value":{"error":{"code":"approval_links_disabled","message":"Approval links are turned off right now.","fix":"Decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：連結核准目前關閉，請登入後到 /approve 頁決定。","web_fallback":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"link"}},"/a/{lid}/reissue":{"post":{"summary":"Link expired but the request is still waiting: send a fresh link to the same channel (the response never contains it)","operationId":"approvalLinkReissue","x-audience":"human","security":[],"parameters":[{"name":"lid","in":"path","required":true,"schema":{"type":"string","pattern":"^al_[0-9A-Za-z]{20}$"},"description":"al_ followed by 20 characters: the lookup key of the link (not secret). The secret k travels only in the URL fragment and in the POST body"}],"description":"Only for an expired link of an approval that is still pending (view reports reissue_available). A new link goes to the same channel as the old one; the old link becomes superseded (reason reissued). The response says only that it was sent: the link itself is never returned by any endpoint. At most 3 times per channel per approval, at least 60 seconds apart (429 rate_limit_exceeded). A link that is still active answers 400 invalid_request (open it instead); a used link 409 approval_link_used; a revoked or superseded one 410 approval_link_revoked, also when the channel no longer receives links (reason channel_removed). For humans (x-audience human). An API key is ignored here entirely: Authorization: Bearer mt_… neither authenticates nor is recorded, and a missing or wrong secret answers 404 approval_link_not_found, the same answer as an unknown link. Not part of the key quota (no X-RateLimit-* headers); own rate limit, 429 rate_limit_exceeded with window approval_link.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["k"],"properties":{"k":{"type":"string","description":"The secret from the URL fragment (43 characters base64url). Never logged, never shown to any API key"}}},"example":{"k":"kQ3w9Zr1Lx8vT5nB2pH6mC4dF7sJ0aY9eG1uK3iO5tW"}}}},"responses":{"200":{"description":"Sent: { ok, data: { reissued: true, channel, expires_at } }","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"reissued":true,"channel":"email","expires_at":"2026-09-24T05:40:00.000Z"}}}}},"400":{"description":"invalid_request: the link is still valid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"invalid_request":{"value":{"error":{"code":"invalid_request","message":"This link is still valid; open it to decide.","expires_at":"2026-09-24T05:15:00.000Z","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"approval_link_not_found: unknown lid or wrong secret, the same answer for both (constant-time comparison; 10 wrong secrets revoke the link)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_not_found":{"value":{"error":{"code":"approval_link_not_found","message":"This approval link is not valid.","fix":"Open the link from the original notification again, or sign in at https://mindthread.tw/approve to see the requests waiting for you. 中文：請從原通知重新開啟連結，或登入 mindthread.tw/approve 查看待確認的請求。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"approval_link_used, or the request is no longer pending (approval_already_decided, approval_expired, approval_key_revoked, approval_permission_denied, approval_stale)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_used":{"value":{"error":{"code":"approval_link_used","message":"This approval link was already used.","fix":"Nothing to do: the request was already handled. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這條連結已使用過，請求已處理，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_already_decided":{"value":{"error":{"code":"approval_already_decided","message":"This request was already decided.","fix":"Nothing to do: see https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這個請求已經有人決定了，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"denied","decision":"deny","decision_via":"web","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_expired":{"value":{"error":{"code":"approval_expired","message":"This request expired (24 hours).","fix":"Nothing to do: see https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這個請求已經有人決定了，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"expired","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_key_revoked":{"value":{"error":{"code":"approval_key_revoked","message":"The API key that sent this request has been disabled, so it can no longer be approved.","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"cancelled","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":"key_disabled_self","result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_permission_denied":{"value":{"error":{"code":"approval_permission_denied","message":"The owner set this permission to deny for the key that sent this request, so the request was cancelled and can no longer be approved.","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"cancelled","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":"permission_set_to_deny","result_summary":null,"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}},"approval_stale":{"value":{"error":{"code":"approval_stale","message":"The settings this request touches changed after the owner was asked, so the version you would approve no longer exists. Nothing ran.","fix":"Ask the AI assistant to read the current settings again and resend the request; you will get a new link. 中文：你要核准的版本已不存在，請 AI 助手重讀設定後重送。","stale_reason":"base_changed","changed":["content_rules"],"current_etag":"g1.77aa0c12e4d3b2a1.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","approval":{"id":"apr_3Hn8VqLm2sKd7wPz1xRa","status":"failed","decision":null,"decision_via":null,"decided_at":null,"expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":false,"http_status":409},"action":{"summary":"放寬 @ultraprobe.tw 的護欄：放寬字數上限","account_username":"ultraprobe.tw"},"result":{"error":{"code":"approval_base_changed"}}},"request_id":"req_mf1x2y3z4abcd"}}}}}}},"410":{"description":"approval_link_revoked: a revoked or superseded link cannot be reissued, nor a link whose channel was removed or no longer receives links","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_revoked":{"value":{"error":{"code":"approval_link_revoked","message":"This approval link is no longer valid.","fix":"The request was decided through another link or the link was withdrawn. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for its state. 中文：這條連結已作廢（可能已用別的連結決定），狀態請見 /approve 頁。","reason":"channel_removed","request_id":"req_mf1x2y3z4abcd"}}}}}}},"429":{"description":"rate_limit_exceeded with window approval_link (20 requests a minute per link, 60 per IP, 200 an hour per owner; not the key quota, no X-RateLimit-* headers); here also after 3 resends, or within 60 seconds of the last one","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"rate_limit_exceeded":{"value":{"error":{"code":"rate_limit_exceeded","message":"This link was already resent 3 times; decide at /approve/{id} signed in.","window":"approval_link","retry_after_seconds":3600,"request_id":"req_mf1x2y3z4abcd"}}}}}}},"503":{"description":"approval_links_disabled: the global kill flag is off (web_fallback is /approve) or the owner turned links off (web_fallback is /approve/{id})","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_links_disabled":{"value":{"error":{"code":"approval_links_disabled","message":"Approval links are turned off right now.","fix":"Decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：連結核准目前關閉，請登入後到 /approve 頁決定。","web_fallback":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"link"}},"/a/{lid}/deny-all":{"post":{"summary":"Deny every pending request of the key that sent this one (t0: always allowed from a link, also during a channel cooldown)","operationId":"approvalLinkDenyAll","x-audience":"human","security":[],"parameters":[{"name":"lid","in":"path","required":true,"schema":{"type":"string","pattern":"^al_[0-9A-Za-z]{20}$"},"description":"al_ followed by 20 characters: the lookup key of the link (not secret). The secret k travels only in the URL fragment and in the POST body"}],"description":"Fail-safe against approval floods: denies this approval and every other pending approval of the same key (up to 50; decision deny, decision_via link, nothing runs, each one emits approval.decided). Works on any link that is still valid, needs no step-up, and needs the csrf from view. The key stays active; to stop the key, the owner revokes it in Settings. For humans (x-audience human). An API key is ignored here entirely: Authorization: Bearer mt_… neither authenticates nor is recorded, and a missing or wrong secret answers 404 approval_link_not_found, the same answer as an unknown link. Not part of the key quota (no X-RateLimit-* headers); own rate limit, 429 rate_limit_exceeded with window approval_link.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["k","csrf"],"properties":{"k":{"type":"string","description":"The secret from the URL fragment (43 characters base64url). Never logged, never shown to any API key"},"csrf":{"type":"string","description":"The csrf value POST /a/{lid}/view returned; checked together with the __Host-mt_al cookie, Origin https://mindthread.tw and Sec-Fetch-Site same-origin when the browser sends it"}}},"example":{"k":"kQ3w9Zr1Lx8vT5nB2pH6mC4dF7sJ0aY9eG1uK3iO5tW","csrf":"c1.9f3a2b7c4d1e8f60a5b2c9d7e4f1a3b8"}}}},"responses":{"200":{"description":"Denied: { ok, data: { denied_count, denied_approval_ids, key_id } }","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"denied_count":2,"denied_approval_ids":["apr_7QxK2mZ9pLr4tWv8aB1c","apr_3Hn8VqLm2sKd7wPz1xRa"],"key_id":"K9f2abc"}}}}},"403":{"description":"csrf_failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"csrf_failed":{"value":{"error":{"code":"csrf_failed","message":"This request did not come from the approval page.","fix":"Reload the approval page and try again. 中文：請重新整理此頁再試。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"approval_link_not_found: unknown lid or wrong secret, the same answer for both (constant-time comparison; 10 wrong secrets revoke the link)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_not_found":{"value":{"error":{"code":"approval_link_not_found","message":"This approval link is not valid.","fix":"Open the link from the original notification again, or sign in at https://mindthread.tw/approve to see the requests waiting for you. 中文：請從原通知重新開啟連結，或登入 mindthread.tw/approve 查看待確認的請求。","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"The link is used","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_used":{"value":{"error":{"code":"approval_link_used","message":"This approval link was already used.","fix":"Nothing to do: the request was already handled. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for the result. 中文：這條連結已使用過，請求已處理，結果請見 /approve 頁。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}}}}}},"410":{"description":"The link expired or was revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_link_expired":{"value":{"error":{"code":"approval_link_expired","message":"This approval link has expired; the request itself may still be waiting.","fix":"Press \"resend the link\" to get a new one on the same channel, or decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：按「重新寄送連結」，或登入後到 /approve 頁決定。","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"pending","expires_at":"2026-09-25T05:05:00.000Z"},"reissue_available":true,"request_id":"req_mf1x2y3z4abcd"}}},"approval_link_revoked":{"value":{"error":{"code":"approval_link_revoked","message":"This approval link is no longer valid.","fix":"The request was decided through another link or the link was withdrawn. See https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c for its state. 中文：這條連結已作廢（可能已用別的連結決定），狀態請見 /approve 頁。","reason":"superseded","approval":{"id":"apr_7QxK2mZ9pLr4tWv8aB1c","status":"executed","decision":"once","decision_via":"link","decided_at":"2026-09-24T05:08:10.000Z","expires_at":"2026-09-25T05:05:00.000Z","cancel_reason":null,"result_summary":{"ok":true,"http_status":200},"action":{"summary":"立刻發文到 @ultraprobe.tw：「今天聊聊…」","account_username":"ultraprobe.tw"}},"request_id":"req_mf1x2y3z4abcd"}}}}}}},"429":{"description":"rate_limit_exceeded with window approval_link (20 requests a minute per link, 60 per IP, 200 an hour per owner; not the key quota, no X-RateLimit-* headers)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"rate_limit_exceeded":{"value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests. Retry after 60 seconds.","window":"approval_link","retry_after_seconds":60,"request_id":"req_mf1x2y3z4abcd"}}}}}}},"503":{"description":"approval_links_disabled: the global kill flag is off (web_fallback is /approve) or the owner turned links off (web_fallback is /approve/{id})","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalLinkError"},"examples":{"approval_links_disabled":{"value":{"error":{"code":"approval_links_disabled","message":"Approval links are turned off right now.","fix":"Decide at https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c signed in. 中文：連結核准目前關閉，請登入後到 /approve 頁決定。","web_fallback":"https://mindthread.tw/approve/apr_7QxK2mZ9pLr4tWv8aB1c","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"link"}},"/notification-channels":{"get":{"summary":"Owner lists the channels that can receive approval links (web app session only)","operationId":"listNotificationChannels","x-audience":"human","security":[{"firebaseIdToken":[]}],"description":"Firebase ID token of the account owner. An API key gets 401 session_required; a team member 403 owner_only. The first read creates the account's own email channel (nch_email_primary) and, while the web app has a push subscription, nch_push_primary, both verified and with approval_links off. Limits: 3 channels per type (the sign-in email counts), 6 in total. 1.10.0 types: email and web_push; LINE follows.","responses":{"200":{"description":"Channels: { ok, data: { channels: NotificationChannel[], limits { perType, total } } }","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"channels":{"type":"array","items":{"$ref":"#/components/schemas/NotificationChannel"}},"limits":{"type":"object","properties":{"perType":{"type":"integer"},"total":{"type":"integer"}}}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"channels":[{"channel_id":"nch_email_primary","type":"email","masked_address":"m***@gmail.com","verified":true,"approval_links":true,"link_only_allowed":false,"agent_readable":false,"cooldown_until":null,"primary":true,"created_at":"2026-09-28T04:00:00.000Z","last_delivery_at":"2026-09-28T05:05:02.000Z","last_error":null},{"channel_id":"nch_push_primary","type":"web_push","masked_address":null,"verified":true,"approval_links":true,"link_only_allowed":true,"agent_readable":false,"cooldown_until":null,"primary":true,"created_at":"2026-09-28T04:00:00.000Z","last_delivery_at":null,"last_error":null},{"channel_id":"nch_8Kq2VmL9tRw3","type":"email","masked_address":"w***@company.tw","verified":false,"approval_links":false,"link_only_allowed":false,"agent_readable":false,"cooldown_until":null,"primary":false,"created_at":"2026-09-28T04:00:00.000Z","last_delivery_at":null,"last_error":null}],"limits":{"perType":3,"total":6}}}}}},"401":{"description":"session_required (an API key; these endpoints are for the signed-in owner) or unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"},"post":{"summary":"Owner adds another email address as a channel (verified with a 6-digit code); web push is registered automatically, LINE follows","operationId":"createNotificationChannel","x-audience":"human","security":[{"firebaseIdToken":[]}],"description":"Body { type: \"email\", address }: a 6-digit code is sent to the address and the channel counts as verified after POST /notification-channels/{id}/verify. Needs a sign-in within the last 24 hours (401 reauth_required). type web_push answers 400 invalid_channel: the push subscription is registered automatically when the owner turns notifications on in the web app and then appears in the list as nch_push_primary. type line answers 400 invalid_channel in 1.10.0 (LINE follows; the enum keeps the value). A malformed or already registered address also answers 400 invalid_channel. 3 email channels including the sign-in email and 6 channels in total (409 channel_limit). Every channel added here starts with approval_links off; once verified it is in a 24-hour cooldown (cooldown_until) during which it only receives links that can deny, and every other channel is told that a new channel was added.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["type","address"],"properties":{"type":{"type":"string","enum":["email","line","telegram","web_push"],"description":"email in 1.10.0 (web_push is automatic, line follows)"},"address":{"type":"string","description":"The email address to verify"}}},"example":{"type":"email","address":"work@company.tw"}}}},"responses":{"201":{"description":"Created: { ok, data: { channel: NotificationChannel, verify { method: \"email_code\", masked, expires_at, attempts_left, instructions } } }","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"channel":{"$ref":"#/components/schemas/NotificationChannel"},"verify":{"type":"object","properties":{"method":{"type":"string","enum":["email_code"]},"masked":{"type":"string"},"expires_at":{"type":"string","format":"date-time"},"attempts_left":{"type":"integer"},"instructions":{"type":"string"}}}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"channel":{"channel_id":"nch_8Kq2VmL9tRw3","type":"email","masked_address":"w***@company.tw","verified":false,"approval_links":false,"link_only_allowed":false,"agent_readable":false,"cooldown_until":null,"primary":false,"created_at":"2026-09-28T04:00:00.000Z","last_delivery_at":null,"last_error":null},"verify":{"method":"email_code","masked":"w***@company.tw","expires_at":"2026-09-28T04:10:00.000Z","attempts_left":5,"instructions":"我們寄了一組 6 位數驗證碼到這個信箱，10 分鐘內有效。輸入後這個信箱就會成為你的核准管道，24 小時內收到的連結只能按拒絕。"}}}}}},"400":{"description":"invalid_channel: type line (not available), type web_push (automatic), an unknown type, a malformed address or an address that is already a channel. type telegram answers 201 with verify { method: telegram_bind, bind_url (t.me deep link, 10 minutes, single use) }; the bot then sends a 6-digit code in Telegram that the owner enters at POST /notification-channels/{id}/verify","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"invalid_channel_line":{"value":{"error":{"code":"invalid_channel","message":"LINE is not available. Use telegram, email or web push.","type":"line","request_id":"req_mf1x2y3z4abcd"}}},"invalid_channel_web_push":{"value":{"error":{"code":"invalid_channel","message":"Web push is registered automatically when you turn on notifications in the app; it then appears in the channel list.","type":"web_push","request_id":"req_mf1x2y3z4abcd"}}},"invalid_channel_address":{"value":{"error":{"code":"invalid_channel","message":"address must be a valid email address","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"session_required, unauthorized or reauth_required (adding a channel needs a sign-in within 24 hours that was not revoked; error.widened names the fields)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}},"reauth_required":{"value":{"error":{"code":"reauth_required","message":"This change needs a sign-in within the last 24 hours. Sign in again and retry.","reason":"sign_in_too_old","widened":["approval_links"],"request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"channel_limit: 3 per type or 6 in total (error.limit)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"channel_limit":{"value":{"error":{"code":"channel_limit","message":"At most 3 email channels (including your sign-in email).","limit":3,"type":"email","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/notification-channels/{id}/verify":{"post":{"summary":"Owner enters the 6-digit code that was sent to a new email channel","operationId":"verifyNotificationChannel","x-audience":"human","security":[{"firebaseIdToken":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"channel_id from POST /notification-channels"}],"description":"The code is valid 10 minutes; 5 wrong attempts use it up (400 channel_verification_failed with attempts_left, then attempts_left 0), and an expired or used-up code answers 410 channel_verification_expired: remove the channel and add it again. On success the channel is verified, its 24-hour cooldown starts (cooldown_until), every other channel is told, and approval_links stays off until the owner turns it on with PATCH. An already verified channel answers 200 with already_verified: true.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["code"],"properties":{"code":{"type":"string","description":"6 digits"}}},"example":{"code":"482913"}}}},"responses":{"200":{"description":"Verified: { ok, data: { channel: NotificationChannel, already_verified? } }","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"channel":{"$ref":"#/components/schemas/NotificationChannel"},"already_verified":{"type":"boolean"}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"channel":{"channel_id":"nch_8Kq2VmL9tRw3","type":"email","masked_address":"w***@company.tw","verified":true,"approval_links":false,"link_only_allowed":false,"agent_readable":false,"cooldown_until":"2026-09-29T04:05:00.000Z","primary":false,"created_at":"2026-09-28T04:00:00.000Z","last_delivery_at":null,"last_error":null}}}}}},"400":{"description":"channel_verification_failed (attempts_left)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"channel_verification_failed":{"value":{"error":{"code":"channel_verification_failed","message":"The code is not right.","attempts_left":4,"request_id":"req_mf1x2y3z4abcd"}}},"channel_verification_failed_used_up":{"value":{"error":{"code":"channel_verification_failed","message":"Too many wrong codes. Remove this channel and add it again.","attempts_left":0,"request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"session_required (an API key; these endpoints are for the signed-in owner) or unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"channel_not_found: not one of this owner's channels (existence is not revealed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"channel_not_found":{"value":{"error":{"code":"channel_not_found","message":"Channel not found","request_id":"req_mf1x2y3z4abcd"}}}}}}},"410":{"description":"channel_verification_expired: the code expired (10 minutes)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"channel_verification_expired":{"value":{"error":{"code":"channel_verification_expired","message":"The verification code expired (10 minutes). Remove this channel and add it again to get a new code.","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/notification-channels/{id}":{"patch":{"summary":"Owner switches approval_links, link_only_allowed or agent_readable on a channel","operationId":"updateNotificationChannel","x-audience":"human","security":[{"firebaseIdToken":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"channel_id"}],"description":"Send only the switches to change (booleans; 400 invalid_request otherwise, 400 nothing_to_update when none). approval_links true needs a verified channel (409 channel_not_verified). Loosening (approval_links on, link_only_allowed on, agent_readable off) needs a sign-in within 24 hours (401 reauth_required; error.widened names the switches); tightening never does. agent_readable on forces link_only_allowed off, and link_only_allowed cannot be turned on while agent_readable is on (400 invalid_request). Turning approval_links off revokes the links already sent to this channel (revoked_links).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":[],"properties":{"approval_links":{"type":"boolean"},"link_only_allowed":{"type":"boolean"},"agent_readable":{"type":"boolean"}}},"example":{"approval_links":true}}}},"responses":{"200":{"description":"Saved: { ok, data: { channel: NotificationChannel, changes, revoked_links } }","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"channel":{"$ref":"#/components/schemas/NotificationChannel"},"changes":{"type":"array","items":{"type":"string"}},"revoked_links":{"type":"integer"}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"channel":{"channel_id":"nch_8Kq2VmL9tRw3","type":"email","masked_address":"w***@company.tw","verified":true,"approval_links":true,"link_only_allowed":false,"agent_readable":false,"cooldown_until":"2026-09-29T04:05:00.000Z","primary":false,"created_at":"2026-09-28T04:00:00.000Z","last_delivery_at":null,"last_error":null},"changes":["approval_links"],"revoked_links":0}}}}},"400":{"description":"invalid_request (a switch is not a boolean, or link_only_allowed with agent_readable on) or nothing_to_update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"invalid_request":{"value":{"error":{"code":"invalid_request","message":"A channel an AI assistant can read cannot be link-only: turn agent_readable off first.","request_id":"req_mf1x2y3z4abcd"}}},"nothing_to_update":{"value":{"error":{"code":"nothing_to_update","message":"Send at least one of approval_links, link_only_allowed, agent_readable","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"session_required, unauthorized or reauth_required (loosening a switch needs a sign-in within 24 hours that was not revoked; error.widened names the fields)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}},"reauth_required":{"value":{"error":{"code":"reauth_required","message":"This change needs a sign-in within the last 24 hours. Sign in again and retry.","reason":"sign_in_too_old","widened":["approval_links"],"request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"channel_not_found: not one of this owner's channels (existence is not revealed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"channel_not_found":{"value":{"error":{"code":"channel_not_found","message":"Channel not found","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"channel_not_verified: approval_links cannot be turned on before the channel is verified","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"channel_not_verified":{"value":{"error":{"code":"channel_not_verified","message":"Verify this channel before it can receive approval links.","channel_id":"nch_8Kq2VmL9tRw3","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"},"delete":{"summary":"Owner removes an added channel; its active links are revoked (channel_removed)","operationId":"deleteNotificationChannel","x-audience":"human","security":[{"firebaseIdToken":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"channel_id"}],"description":"Removes the channel and revokes every active link that was sent to it (the approvals stay pending and can still be decided on the web or through another channel). Every remaining channel is told. The two primary channels (sign-in email, push subscription) cannot be removed: 400 invalid_channel; turn approval_links off instead.","responses":{"200":{"description":"Deleted: { ok, data: { deleted: true, channel_id, revoked_links } }","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"deleted":true,"channel_id":"nch_8Kq2VmL9tRw3","revoked_links":1}}}}},"400":{"description":"invalid_channel: a primary channel","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"invalid_channel":{"value":{"error":{"code":"invalid_channel","message":"Your sign-in email and this device's push are primary channels and cannot be removed; turn approval_links off instead.","channel_id":"nch_email_primary","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"session_required (an API key; these endpoints are for the signed-in owner) or unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"channel_not_found: not one of this owner's channels (existence is not revealed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"channel_not_found":{"value":{"error":{"code":"channel_not_found","message":"Channel not found","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/approval-settings":{"get":{"summary":"Owner reads how approvals may be confirmed from notifications: links on or off, TTLs, tiers, phrase","operationId":"getApprovalSettings","x-audience":"human","security":[{"firebaseIdToken":[]}],"description":"Firebase ID token of the account owner (API key: 401 session_required; team member: 403 owner_only). tiers.defaults is the server table for the permissions it lists, tiers.unlisted (t3) what every other permission gets, tiers.floors the strictest the owner may relax to (the same table in 1.10.0), tiers.ttl and tiers.phrase the accepted ranges; channels_ready counts the verified channels with approval_links on.","responses":{"200":{"description":"Settings: { ok, data: { settings: ApprovalSettings, tiers { defaults, floors, unlisted, ttl, phrase }, channels_ready } }","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"settings":{"$ref":"#/components/schemas/ApprovalSettings"},"tiers":{"type":"object","description":"defaults: permission name to tier as the server computes it (only the permissions the table lists; unlisted says what every other permission gets: t3). floors: the strictest the owner may relax to, the same table in 1.10.0. ttl and phrase: the accepted ranges","properties":{"defaults":{"type":"object","additionalProperties":{"type":"string","enum":["t1","t2","t3"]}},"floors":{"type":"object","additionalProperties":{"type":"string","enum":["t1","t2","t3"]}},"unlisted":{"type":"string","const":"t3"},"ttl":{"type":"object","properties":{"min":{"type":"integer"},"max":{"type":"integer"},"default":{"type":"integer"},"testMin":{"type":"integer"}}},"phrase":{"type":"object","properties":{"min":{"type":"integer"},"max":{"type":"integer"}}}}},"channels_ready":{"type":"integer","description":"Verified channels with approval_links on (the channels a link would be sent to). links_enabled needs at least one (409 no_verified_channel)"}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"settings":{"links_enabled":true,"link_ttl_seconds":600,"test_link_ttl_seconds":60,"tier_overrides":{"content:publish_now":"t2"},"test_mode_step_up":"off","anti_phishing_phrase":"藍色鯨魚","email_digest":true,"updated_at":"2026-09-28T04:00:00.000Z"},"tiers":{"defaults":{"patrol:reply_send":"t1","content:publish_now":"t1","patrol:cloud_enable":"t2","patrol:browser_command":"t2","content:schedule":"t2","accounts:guardrails":"t3","accounts:connect":"t3"},"floors":{"patrol:reply_send":"t1","content:publish_now":"t1","patrol:cloud_enable":"t2","patrol:browser_command":"t2","content:schedule":"t2","accounts:guardrails":"t3","accounts:connect":"t3"},"unlisted":"t3","ttl":{"min":300,"max":900,"default":600,"testMin":60},"phrase":{"min":2,"max":16}},"channels_ready":2}}}}},"401":{"description":"session_required (an API key; these endpoints are for the signed-in owner) or unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"},"patch":{"summary":"Owner changes the approval link settings (turn links on, TTLs, stricter tiers, test-mode step-up, anti-phishing phrase)","operationId":"updateApprovalSettings","x-audience":"human","security":[{"firebaseIdToken":[]}],"description":"Send only the fields to change (400 nothing_to_update when none; 400 invalid_request for a wrong type or an unknown tier value). links_enabled true needs at least one verified channel with approval_links on (409 no_verified_channel). tier_overrides may only tighten: a tier below the floor answers 400 tier_below_floor (scope, floor, requested); null removes an override. link_ttl_seconds 300 to 900 and test_link_ttl_seconds 60 to 900 (400 invalid_ttl with min and max); anti_phishing_phrase 2 to 16 characters or an empty string to clear (400 invalid_phrase). Loosening (turning links on, raising a TTL, lowering or removing an override, test_mode_step_up back to off) needs a sign-in within 24 hours (401 reauth_required; error.widened names the fields). Answers the saved settings with changes, widened and channels_ready (no tiers: read GET for the table).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","minProperties":1,"properties":{"links_enabled":{"type":"boolean"},"link_ttl_seconds":{"type":"integer","minimum":300,"maximum":900},"test_link_ttl_seconds":{"type":"integer","minimum":60,"maximum":900},"tier_overrides":{"type":"object","additionalProperties":{"type":["string","null"],"enum":["t1","t2","t3",null]},"description":"Only the permissions to change; null removes that override"},"test_mode_step_up":{"type":"string","enum":["off","mirror_live"]},"anti_phishing_phrase":{"type":"string","maxLength":16,"description":"2 to 16 characters, or an empty string to clear"},"email_digest":{"type":"boolean"}}},"example":{"links_enabled":true,"test_link_ttl_seconds":60,"tier_overrides":{"content:publish_now":"t2"},"anti_phishing_phrase":"藍色鯨魚"}}}},"responses":{"200":{"description":"Saved: { ok, data: { settings: ApprovalSettings, changes, widened, channels_ready } }","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"settings":{"$ref":"#/components/schemas/ApprovalSettings"},"changes":{"type":"array","items":{"type":"string"}},"widened":{"type":"array","items":{"type":"string"}},"channels_ready":{"type":"integer","description":"Verified channels with approval_links on (the channels a link would be sent to). links_enabled needs at least one (409 no_verified_channel)"}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"settings":{"links_enabled":true,"link_ttl_seconds":600,"test_link_ttl_seconds":60,"tier_overrides":{"content:publish_now":"t2"},"test_mode_step_up":"off","anti_phishing_phrase":"藍色鯨魚","email_digest":true,"updated_at":"2026-09-28T04:00:00.000Z"},"changes":["linksEnabled","testLinkTtlSeconds","tierOverrides","antiPhishingPhrase"],"widened":["links_enabled"],"channels_ready":2}}}}},"400":{"description":"tier_below_floor, invalid_ttl, invalid_phrase, invalid_request or nothing_to_update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"tier_below_floor":{"value":{"error":{"code":"tier_below_floor","message":"accounts:guardrails cannot be set below its floor t3","scope":"accounts:guardrails","floor":"t3","requested":"t1","request_id":"req_mf1x2y3z4abcd"}}},"invalid_ttl":{"value":{"error":{"code":"invalid_ttl","message":"link_ttl_seconds must be an integer between 300 and 900 seconds","min":300,"max":900,"request_id":"req_mf1x2y3z4abcd"}}},"invalid_phrase":{"value":{"error":{"code":"invalid_phrase","message":"anti_phishing_phrase must be 2 to 16 characters (or empty to clear it)","min":2,"max":16,"request_id":"req_mf1x2y3z4abcd"}}},"invalid_request":{"value":{"error":{"code":"invalid_request","message":"test_mode_step_up must be 'off' or 'mirror_live'","request_id":"req_mf1x2y3z4abcd"}}},"nothing_to_update":{"value":{"error":{"code":"nothing_to_update","message":"Send at least one of links_enabled, link_ttl_seconds, test_link_ttl_seconds, tier_overrides, test_mode_step_up, anti_phishing_phrase, email_digest","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"session_required, unauthorized or reauth_required (loosening a setting needs a sign-in within 24 hours that was not revoked; error.widened names the fields)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}},"reauth_required":{"value":{"error":{"code":"reauth_required","message":"This change needs a sign-in within the last 24 hours. Sign in again and retry.","reason":"sign_in_too_old","widened":["approval_links"],"request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"no_verified_channel: links_enabled needs a verified channel with approval_links on","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"no_verified_channel":{"value":{"error":{"code":"no_verified_channel","message":"Turn approval_links on for at least one verified channel before enabling links.","channels_ready":0,"request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/approvals/{id}/links/revoke":{"post":{"summary":"Owner withdraws every active link of one approval (for example after forwarding a notification by mistake)","operationId":"revokeApprovalLinks","x-audience":"human","security":[{"firebaseIdToken":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Approval id (apr_…)"}],"description":"Firebase ID token of the account owner (API key: 401 session_required; team member: 403 owner_only; another member's approval 404 approval_not_found). Every active link of the approval becomes revoked (reason owner_revoked); the approval itself stays pending and can still be decided at /approve/{id}. There is no body.","responses":{"200":{"description":"Revoked: { ok, data: { revoked_count, approval_id } }","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"revoked_count":2,"approval_id":"apr_7QxK2mZ9pLr4tWv8aB1c"}}}}},"401":{"description":"session_required (an API key; these endpoints are for the signed-in owner) or unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"session_required":{"value":{"error":{"code":"session_required","message":"This endpoint is for the MindThread web app session.","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Sign in to MindThread to manage approval channels","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"owner_only (a team member) or workspace_revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"owner_only":{"value":{"error":{"code":"owner_only","message":"Only the account owner can manage approval channels and settings. Team members cannot.","request_id":"req_mf1x2y3z4abcd"}}},"workspace_revoked":{"value":{"error":{"code":"workspace_revoked","message":"You are no longer a member of this workspace","request_id":"req_mf1x2y3z4abcd"}}}}}}},"404":{"description":"approval_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"approval_not_found":{"value":{"error":{"code":"approval_not_found","message":"Approval not found","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"session"}},"/views":{"post":{"summary":"Web app only: record what the signed-in owner was shown (1.18.0)","operationId":"recordViews","description":"Session-only (Firebase sign-in); API keys get 401 session_required. Body { items: [{ kind: \"library\" | \"post\", id, own_edit? }] } (up to 60). The server reads the current content itself, returns changed_since_last_viewed per item against the previous viewing record, then records the current version as viewed by the owner. own_edit:true records the owner's own web edit without a warning.","responses":{"200":{"description":"Per-item results"},"401":{"description":"session_required"}},"x-scope":"session"}},"/patrol/cloud/pending/approve":{"post":{"summary":"Batch approve drafted replies (up to 50; per-account daily cap; flagged drafts stay individual)","operationId":"approvePendingRepliesBatch","description":"Send either ids (1-50 pending ids) or account_id with all: true (the account's pending drafts, oldest first, up to 50). Drafts with needs_individual true (flags political, self_harm, pii, promo, flagged) are skipped with reason needs_individual and stay pending; approve them one at a time with POST /patrol/cloud/pending/{id}/approve. Per account the batch sends at most left_today (daily cap minus replies already sent today); the rest are skipped with reason daily_cap and stay pending. Other skip reasons: not_found, forbidden, not_pending, discovered_item, expired, time_budget (the request ran out of time before trying them; they stay pending, call again). Each approved draft goes through the same send path as the single approve: it uses haixun points and the site-wide fuse exactly like an automatic reply; failed[] lists drafts that were tried and not sent (codes as in the single approve: daily_cap, global_cap, no_points, backoff, discover_mode, publish_failed, in_progress); a batch stops early on global_cap or no_points, and stops trying an account after daily_cap or backoff. Needs patrol:reply_send set to allow: in ask mode this endpoint returns 403 approval_not_supported (one confirmation cannot cover 50 replies the owner could not read one by one).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":50,"description":"Pending ids"},"account_id":{"type":"string","description":"Account id; use with all: true"},"all":{"type":"boolean","description":"Approve every pending draft of account_id (oldest first, up to 50)"}}}}}},"responses":{"200":{"description":"Batch result","content":{"application/json":{"example":{"ok":true,"data":{"approved":[{"id":"p1","account_id":"acc1","reply_id":"1809..."},{"id":"p2","account_id":"acc1","reply_id":"1810..."}],"failed":[],"skipped":[{"id":"p3","account_id":"acc1","reason":"needs_individual","flags":["political"]}],"remaining":0,"cap_left":{"acc1":4},"counts":{"approved":2,"failed":0,"skipped":1}}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"invalid_body","message":"Send either ids (1-50 pending ids) or account_id with all: true","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_not_supported (permission is ask: this endpoint never waits for approval), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"invalid_body","message":"Send either ids (1-50 pending ids) or account_id with all: true","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"patrol:reply_send","x-approval":"not_supported"}},"/patrol/cloud/library/import":{"post":{"summary":"Import fixed replies into the cloud patrol reply library (up to 2,000; replace or append; dry_run previews)","operationId":"importCloudPatrolReplies","description":"Each line is trimmed; blank lines are ignored; exact duplicates (within this import, and against the existing library when appending) are removed; replies longer than the account reply length limit (reply_max) are removed; replies that fail content rules, the self-harm filter, the fact bank (managed accounts; detail names the number) or the reply quality checks are removed; beyond 2,000 in total the rest are removed. The order is kept. Every removed line is returned with its 1-based line number. mode replace (default) replaces the library, restarts from the first reply and clears the usage log; append adds after the existing replies and keeps the position. At most 10,000 lines per request. Importing does not turn patrol on or change reply_mode: set reply_mode with PUT /patrol/cloud.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["account_id","replies"],"properties":{"account_id":{"type":"string"},"replies":{"type":"array","items":{"type":"string"},"maxItems":10000},"mode":{"type":"string","enum":["replace","append"],"default":"replace"},"dry_run":{"type":"boolean","description":"true = preview only, nothing is written"}}}}}},"responses":{"200":{"description":"Import result","content":{"application/json":{"example":{"ok":true,"data":{"mode":"replace","reply_max":50,"accepted":17,"total_after":17,"preview":["這個整理很實用，收藏了"],"empty_lines":0,"rejected":{"duplicates":[{"line":7,"text":"同意，我自己也是這樣做"}],"too_long":[{"line":12,"text":"...","length":83}],"blocked":[],"over_limit":[]},"library":{"total":17,"used":0,"remaining":17,"cursor":0,"next":1,"exhausted":false},"dry_run":false}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"invalid_replies","message":"replies must be an array of strings","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"invalid_replies","message":"replies must be an array of strings","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write"}},"/patrol/cloud/library/export":{"get":{"summary":"Remaining replies in the cloud patrol reply library (consume: unused ones; rotate: all)","operationId":"exportCloudPatrolReplies","parameters":[{"name":"account_id","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Remaining replies","content":{"application/json":{"example":{"ok":true,"data":{"account_id":"acc_123","reply_mode":"consume","count":15,"replies":["這個整理很實用，收藏了"]}}}}},"403":{"description":"insufficient_scope (permission is deny), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"invalid_replies","message":"replies must be an array of strings","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"read"}},"/accounts/{account_id}/top-posts":{"get":{"summary":"Best posts of an account this member connected, ranked by engagement or one metric","operationId":"getTopPosts","description":"Only Threads accounts this member connected: Meta's Threads API returns insights for the authorized user's own posts only, so other people's accounts cannot be read. Metrics come from MindThread's cache, refreshed by a background job that runs every 30 minutes and cycles through accounts; metrics_fetched_at shows when each post was last read. Posts MindThread has not fetched yet are not included. mt_test_ keys return three simulated posts (data_source: mock).","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"1-50, default 20","schema":{"type":"integer","minimum":1,"maximum":50}},{"name":"metric","in":"query","description":"Ranking metric, default engagement","schema":{"type":"string","enum":["engagement","views","likes","replies","reposts","quotes"]}},{"name":"days","in":"query","description":"Only posts published in the last N days (1-365); omit for every fetched post","schema":{"type":"integer","minimum":1,"maximum":365}}],"responses":{"200":{"description":"Ranked posts","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"account_id":{"type":"string"},"username":{"type":"string"},"metric":{"type":"string"},"days":{"type":["integer","null"]},"count":{"type":"integer"},"posts":{"type":"array","items":{"type":"object","properties":{"rank":{"type":"integer"},"post_id":{"type":"string","description":"Threads media id"},"text":{"type":"string"},"published_at":{"type":["string","null"],"format":"date-time"},"views":{"type":"integer"},"likes":{"type":"integer"},"replies":{"type":"integer"},"reposts":{"type":"integer"},"quotes":{"type":"integer"},"engagement":{"type":"integer","description":"likes + replies + reposts + quotes"},"engagement_rate":{"type":["number","null"],"description":"engagement / views (null when views is 0)"},"metrics_fetched_at":{"type":["string","null"],"format":"date-time","description":"When MindThread last read this post's insights"}}}},"source":{"type":"string","enum":["insights_cache","mock"]},"posts_considered":{"type":"integer"},"limits":{"type":"array","items":{"type":"string"}}}}}},"example":{"ok":true,"data":{"account_id":"a1","username":"shop_a","metric":"engagement","days":90,"count":1,"posts":[{"rank":1,"post_id":"18073613831722491","text":"客戶不是被說服的，是被理解的。","published_at":"2026-10-20T01:30:00.000Z","views":4200,"likes":180,"replies":36,"reposts":12,"quotes":0,"engagement":228,"engagement_rate":0.0543,"metrics_fetched_at":"2026-11-04T05:30:00.000Z"}],"source":"insights_cache","posts_considered":412,"limits":["Only Threads accounts this member connected: Meta's Threads API returns insights for the authorized user's own posts only, so other people's accounts cannot be read.","Metrics come from MindThread's cache, refreshed by a background job that runs every 30 minutes and cycles through accounts; metrics_fetched_at shows when each post was last read. Posts MindThread has not fetched yet are not included."]}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"invalid_metric","message":"metric must be one of engagement, views, likes, replies, reposts, quotes","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"account_not_found","message":"Account a9 not found. Only accounts connected to this MindThread member can be read (list_accounts).","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"read"}},"/brand-docs":{"get":{"summary":"List brand documents (metadata only, newest first)","operationId":"listBrandDocs","responses":{"200":{"description":"Documents","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"docs":{"type":"array","items":{"type":"object","properties":{"doc_id":{"type":"string"},"title":{"type":"string"},"language":{"type":"string","description":"BCP 47 tag, default zh-TW"},"account_id":{"type":["string","null"]},"version":{"type":"integer"},"chars":{"type":"integer"},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"}}}},"max_docs":{"type":"integer"}}}}},"example":{"ok":true,"data":{"docs":[{"doc_id":"brand","title":"品牌文件","language":"zh-TW","account_id":null,"version":3,"chars":1840,"created_at":"2026-11-04T06:00:00.000Z","updated_at":"2026-11-04T06:30:00.000Z"}],"max_docs":50}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/brand-docs/{doc_id}":{"get":{"summary":"Read one brand document (latest, or ?version=N for one of the last kept versions)","operationId":"getBrandDoc","parameters":[{"name":"doc_id","in":"path","required":true,"description":"1-40 characters of a-z, 0-9, _ or -. Suggested: brand (brand document), content (content document from top posts), content_map (content map).","schema":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,39}$"}},{"name":"version","in":"query","description":"An earlier version (the last 20 are kept)","schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"Document","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"doc_id":{"type":"string"},"title":{"type":"string"},"language":{"type":"string","description":"BCP 47 tag, default zh-TW"},"account_id":{"type":["string","null"]},"version":{"type":"integer"},"chars":{"type":"integer"},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"},"content":{"type":"string"}}}}},"example":{"ok":true,"data":{"doc_id":"brand","title":"品牌文件","language":"zh-TW","account_id":null,"version":3,"chars":1840,"created_at":"2026-11-04T06:00:00.000Z","updated_at":"2026-11-04T06:30:00.000Z","content":"# 品牌文件\n## 我幫助誰\n…"}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"invalid_version","message":"version must be an integer ≥ 1","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"brand_doc_not_found","message":"No document brand yet. Save one with save_brand_doc (PUT /brand-docs/brand).","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"read"},"put":{"summary":"Save a brand document (the whole content; creates a new version)","operationId":"saveBrandDoc","description":"Writes the whole document (Markdown or plain text, up to 50,000 characters). Pass base_version (the version you read; 0 when creating) so a concurrent edit answers 409 version_conflict instead of being overwritten. Up to 50 documents per member; the last 20 versions of each are kept. title and language keep their previous values when omitted (language defaults to zh-TW). account_id optionally ties the document to one connected account. mt_test_ keys save to a sandbox copy that only mt_test_ keys read (sandbox: true).","parameters":[{"name":"doc_id","in":"path","required":true,"description":"1-40 characters of a-z, 0-9, _ or -. Suggested: brand (brand document), content (content document from top posts), content_map (content map).","schema":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,39}$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["content"],"properties":{"content":{"type":"string","maxLength":50000},"title":{"type":"string","maxLength":100},"language":{"type":"string","description":"BCP 47 tag such as zh-TW, en, ja"},"account_id":{"type":"string","description":"Optional connected account this document belongs to"},"base_version":{"type":"integer","minimum":0,"description":"Version you read (0 = must not exist yet)"}}}}}},"responses":{"200":{"description":"Saved","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"doc_id":{"type":"string"},"title":{"type":"string"},"language":{"type":"string","description":"BCP 47 tag, default zh-TW"},"account_id":{"type":["string","null"]},"version":{"type":"integer"},"chars":{"type":"integer"},"created_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":["string","null"],"format":"date-time"}}}}},"example":{"ok":true,"data":{"doc_id":"brand","title":"品牌文件","language":"zh-TW","account_id":null,"version":3,"chars":1840,"created_at":"2026-11-04T06:00:00.000Z","updated_at":"2026-11-04T06:30:00.000Z"}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"content_too_large","message":"content must be at most 50000 characters","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"account_not_found","message":"Account a9 is not connected to this member","request_id":"req_mf1x2y3z4abcd"}}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"version_conflict","message":"The document is at version 4, not 3. Read it again (get_brand_doc) and merge before saving.","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write"}},"/me":{"get":{"summary":"Who am I: plan, key identity (data.key), remaining units in this key's pool, haixun points, connected accounts","operationId":"getMe","responses":{"200":{"description":"Profile","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/Key"},"actor":{"$ref":"#/components/schemas/Actor"},"actor_id":{"type":"string","description":"api:<key_id>"}}}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"plan":"pro","test_mode":false,"actor":{"type":"key","key_id":"K9f2abc","label":"OpenClaw Agent"},"actor_id":"api:K9f2abc","key":{"id":"K9f2abc","label":"OpenClaw Agent","prefix":"mt_live","last4":"8f2a","kind":"live","status":"active","legacy":false,"scopes_enforced":true,"scopes":{"read":"allow","content:write":"allow","content:schedule":"allow","content:publish_now":"ask","patrol:reply_send":"ask","patrol:cloud_enable":"ask","patrol:browser_command":"ask","accounts:connect":"ask","accounts:guardrails":"ask","webhooks:write":"allow"},"agent_name":null,"agent_url":null,"created_at":"2026-09-24T01:00:00.000Z","last_used_at":"2026-09-24T03:12:45.000Z"},"api":{"pool":"live","pooled_by":"key","daily_limit":1000,"used_today":12,"remaining_today":988,"per_minute":120,"reset_at":"2026-09-24T16:00:00.000Z","resets":"daily at 00:00 Asia/Taipei"},"haixun_points":{"daily_cap":500,"used_today":37},"accounts":{"total":3,"connected":3}}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"self"}},"/keys/current/disable":{"post":{"summary":"Kill switch: permanently disable the API key making this call","operationId":"disableCurrentKey","description":"No body. Always allowed for a valid key (live, test or legacy): consumes no quota, is not subject to the per-minute limit and sends no X-RateLimit-* headers. Writes the same revoked flag as revoking in Settings, so Settings shows the key as revoked and the owner gets a notification. There is no re-enable: create a new key instead. The next request with this key returns 401 key_disabled (promised within 5 seconds); requests already in progress are not interrupted. Disabling stops API requests only; webhooks, queued posts and cloud patrol settings created with this key keep running. Review them in Settings. Calling it again therefore returns 401 key_disabled; treat 200 and 401 key_disabled alike as \"stopped\". Only the calling key can be disabled; other keys are managed by the human in Settings. On a mt_test_ key this is the one real write, so the response says persisted:true. The 200 also lists the approvals this key was still waiting on, now cancelled: cancelled_approvals (a count; null only if that step failed, and such an approval can still never be approved: decide answers 409 approval_key_revoked) and cancelled_approval_ids (up to 50). The disabled key cannot read them any more; for a live key, another live key of the same member sees each one as status cancelled with cancel_reason key_disabled_self in GET /events?types=approval.decided, and the owner sees them on /approve. A test key's approvals are sandbox events (1.8.2) that no other key reads, so rely on cancelled_approval_ids there.","responses":{"200":{"description":"Disabled: { key_id, status, disabled_at, cancelled_approvals, cancelled_approval_ids }","content":{"application/json":{"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"key_id":"K9f2abc","status":"disabled","disabled_at":"2026-09-24T05:00:00.000Z","cancelled_approvals":1,"cancelled_approval_ids":["apr_7QxK2mZ9pLr4tWv8aB1c"]},"actor":{"type":"key","key_id":"K9f2abc"}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"self"}},"/keys/current/usage":{"get":{"summary":"Usage and call records of the key making this call (summary plus recent calls with cursor paging)","operationId":"getKeyUsage","description":"Any valid key reads its own records only: there is no key id parameter, and another key's records, labels and the member id are never returned. Needs no permission (like GET /me), consumes no daily quota; at most 10 requests per minute per key on this endpoint, on top of the usual per-minute limit (429 rate_limit_exceeded with window minute and limit 10). days 1..30, limit 1..100, cursor = next_cursor of the previous page; days=1 is today since 00:00 Asia/Taipei; limit defaults to 50. Coverage (data.note): Only this key's records. Coverage: every request this key made after the server identified it and answered, success or error, including requests refused for permission (403), quota (429) or a bad request (400). Not recorded: 401 unauthorized, 401 key_disabled, answers given before the key is checked (405 method_not_allowed, 401 session_required), and the validation run before an approval is created. 429 answers and refusals made before the quota check (400 invalid_idempotency_key, 403 scope_unmapped) are recorded about once per key per minute on each server, so those counts are a lower bound. Requests the server ran after the owner confirmed an approval appear under this key with request_id apr_exec_<approval id> and units 0. units: daily-quota units the request consumed (0 for GET /approvals/{id}, this endpoint and POST /keys/current/disable). Records are written after the answer is sent, best effort: one can occasionally be missing, so summary and recent may differ slightly. summary counts start with version 1.8.2; recent covers the requested window, at most the last 30 days (units is null on records written before 1.8.2).","parameters":[{"name":"days","in":"query","required":false,"description":"1 to 30 (default 1 = today, Asia/Taipei)","schema":{"type":"integer","minimum":1,"maximum":30,"default":1}},{"name":"limit","in":"query","required":false,"description":"Records per page, 1 to 100 (default 50)","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"cursor","in":"query","required":false,"description":"next_cursor from the previous page","schema":{"type":"string"}}],"responses":{"200":{"description":"Usage of this key","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KeyUsage"}}}]},"example":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"key_id":"K9f2abc","kind":"test","window":{"days":1,"since":"2026-09-23T16:00:00.000Z","until":"2026-09-24T03:12:45.000Z","timezone":"Asia/Taipei"},"summary":{"calls":3,"units":2,"errors":1,"by_endpoint":[{"endpoint":"POST /content/publish","calls":2,"units":2,"errors":1},{"endpoint":"GET /keys/current/usage","calls":1,"units":0,"errors":0}]},"recent":[{"request_id":"req_mf1x2y3z4abcd","endpoint":"POST /content/publish","status":200,"units":1,"at":"2026-09-24T03:12:40.000Z"},{"request_id":"req_mf1x2y3z4abce","endpoint":"POST /content/publish","status":403,"units":1,"at":"2026-09-24T03:10:02.000Z"}],"next_cursor":null,"has_more":false,"note":"Only this key's records. Coverage: every request this key made after the server identified it and answered, success or error, including requests refused for permission (403), quota (429) or a bad request (400). Not recorded: 401 unauthorized, 401 key_disabled, answers given before the key is checked (405 method_not_allowed, 401 session_required), and the validation run before an approval is created. 429 answers and refusals made before the quota check (400 invalid_idempotency_key, 403 scope_unmapped) are recorded about once per key per minute on each server, so those counts are a lower bound. Requests the server ran after the owner confirmed an approval appear under this key with request_id apr_exec_<approval id> and units 0. units: daily-quota units the request consumed (0 for GET /approvals/{id}, this endpoint and POST /keys/current/disable). Records are written after the answer is sent, best effort: one can occasionally be missing, so summary and recent may differ slightly. summary counts start with version 1.8.2; recent covers the requested window, at most the last 30 days (units is null on records written before 1.8.2)."},"test_mode":true,"data_source":"live_readonly"}}}},"400":{"description":"Bad parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"invalid_days":{"value":{"error":{"code":"invalid_days","message":"days must be an integer from 1 to 30 (1 = today since 00:00 Asia/Taipei)","request_id":"req_mf1x2y3z4abcd"}}},"invalid_limit":{"value":{"error":{"code":"invalid_limit","message":"limit must be an integer from 1 to 100","request_id":"req_mf1x2y3z4abcd"}}},"invalid_cursor":{"value":{"error":{"code":"invalid_cursor","message":"cursor must be the next_cursor value from the previous page","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"429":{"description":"Per-minute limit (at most 10 requests per minute per key on this endpoint, on top of the usual per-minute limit)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"rate_limit_exceeded":{"value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests to this endpoint (10/minute per key). Retry after 20 seconds.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"503":{"description":"The records cannot be queried yet (retry later)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"usage_index_building":{"value":{"error":{"code":"usage_index_building","message":"Usage records cannot be queried yet (the database index is still being built). Retry in a few minutes.","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"self"}},"/events":{"get":{"summary":"Event feed for agents without a public endpoint (newest first, last 7 days)","operationId":"listEvents","description":"Same events as webhooks (post.published, post.failed, reply.sent, patrol.reply, patrol.pending, token.expiring, usage.threshold, approval.decided). Covers the last 7 days. Poll with since=<latest_at from the previous response>; latest_at moves past events you did not ask for (types), so polling never sticks. Live keys see the member's live events and never a sandbox event; for a live approval created by another key, approval.decided shows only approval_id, status, decision and cancel_reason. Test keys (1.8.2) see only their own sandbox events: in the sandbox, publishing now (POST /content/publish or POST /content/generate-and-schedule with publish_now, POST /content/publish-thread, POST /experiments) records post.published, approving a pending cloud reply records patrol.reply, and an approval this key created records approval.decided when it is decided, cancelled or expires; other sandbox writes record no event, and an empty list says so in data.note. Test-key answers carry data_source: sandbox, and each event's data follows SandboxEventData. Sandbox events are never delivered to webhooks and never shown to live keys. From 1.8.2, publishing now with a live key through POST /content/publish or POST /content/generate-and-schedule (publish_now) also emits post.published or post.failed (source api_publish or api_generate_and_schedule); webhook deliveries can repeat, so dedupe by post_id.","parameters":[{"name":"since","in":"query","required":false,"description":"ISO 8601; only events after this","schema":{"type":"string"}},{"name":"types","in":"query","required":false,"description":"Comma-separated event names","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"1-200 (default 50)","schema":{"type":"integer"}}],"responses":{"200":{"description":"Events","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"type":"object","required":["events","count","latest_at","known_types","note"],"properties":{"events":{"type":"array","description":"Newest first","items":{"type":"object","required":["id","event","at","data"],"properties":{"id":{"type":"string"},"event":{"type":"string","enum":["post.published","post.failed","reply.sent","patrol.reply","patrol.pending","token.expiring","usage.threshold","approval.decided"]},"at":{"type":"string","format":"date-time"},"data":{"description":"Event payload (same as the webhook data). With a mt_test_ key every event is a sandbox event: SandboxEventData.","anyOf":[{"$ref":"#/components/schemas/SandboxEventData"},{"type":"object"}]}}}},"count":{"type":"integer"},"latest_at":{"type":["string","null"],"format":"date-time"},"known_types":{"type":"array","items":{"type":"string"}},"note":{"type":"string"}}}}}]},"examples":{"live":{"value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"events":[{"id":"e1","event":"patrol.pending","at":"2026-09-06T03:00:00.000Z","data":{"account_id":"utOWPxV1FLEeLK36xygM","pending_id":"p1","reply":"..."}}],"count":1,"latest_at":"2026-09-06T03:00:00.000Z","known_types":["post.published","post.failed","reply.sent","patrol.reply","patrol.pending","token.expiring","usage.threshold","approval.decided"],"note":"Newest first. …"}}},"test_key":{"value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"events":[{"id":"e2","event":"post.published","at":"2026-09-24T03:12:40.000Z","data":{"post_id":"test_post_1758683560000","threads_post_id":null,"kind":"text","content":"…","account_id":"utOW1","account_ids":["utOW1"],"source":"api_publish","test_mode":true,"key_id":"K9f2abc","persisted":false,"request_id":"req_mf1x2y3z4abcd"}}],"count":1,"latest_at":"2026-09-24T03:12:40.000Z","known_types":["post.published","post.failed","reply.sent","patrol.reply","patrol.pending","token.expiring","usage.threshold","approval.decided"],"note":"Test key: real sandbox events of this key only; nothing reached Threads. Events from sandbox writes carry test_mode:true, key_id, persisted:false and request_id in data. In the sandbox, publishing now (POST /content/publish or POST /content/generate-and-schedule with publish_now, POST /content/publish-thread, POST /experiments) records post.published, approving a pending cloud reply records patrol.reply, and an approval this key created records approval.decided when it is decided, cancelled or expires. Other sandbox writes record no event. Live events are not shown to test keys. Sandbox events are never delivered to webhooks and never shown to live keys. Covers the last 7 days."},"test_mode":true,"data_source":"sandbox"}},"test_key_empty":{"value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"events":[],"count":0,"latest_at":null,"known_types":["post.published","post.failed","reply.sent","patrol.reply","patrol.pending","token.expiring","usage.threshold","approval.decided"],"note":"Test key: this key has no sandbox events in the window (the last 7 days). In the sandbox, publishing now (POST /content/publish or POST /content/generate-and-schedule with publish_now, POST /content/publish-thread, POST /experiments) records post.published, approving a pending cloud reply records patrol.reply, and an approval this key created records approval.decided when it is decided, cancelled or expires. Other sandbox writes record no event, and live events are never shown to test keys."},"test_mode":true,"data_source":"sandbox"}}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"503":{"description":"The events cannot be queried yet (retry later)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"events_index_building":{"value":{"error":{"code":"events_index_building","message":"Events cannot be queried yet (the database index is still being built). Retry in a few minutes.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"504":{"description":"Stopped after 25 seconds (2026-10-15): nothing was changed; retry after the Retry-After header (30 seconds)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"timeout":{"value":{"error":{"code":"timeout","message":"The request took longer than 25 seconds and was stopped. Nothing was changed. Retry in 30 seconds.","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"read"}},"/accounts":{"get":{"summary":"List connected Threads accounts (use `id` as account_id elsewhere)","operationId":"listAccounts","description":"Note the field names: the handle comes back as `threads_username` WITH the leading @, and counts live under `stats`. Match on `threads_username`, never on `display_name`.","responses":{"200":{"description":"Accounts","content":{"application/json":{"example":{"ok":true,"data":{"accounts":[{"id":"utOWPxV1FLEeLK36xygM","threads_username":"@mindthread_offical","display_name":"MindThread","avatar_url":"https://...","status":"active","has_system_prompt":true,"stats":{"followers":139,"total_views":864,"total_likes":0,"total_replies":0,"total_posts":10},"connected_at":"2026-08-05T02:22:00.000Z"}]}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"504":{"description":"Stopped after 25 seconds (2026-10-15): nothing was changed; retry after the Retry-After header (30 seconds). error.code is timeout.","content":{"application/json":{"examples":{"timeout":{"value":{"error":{"code":"timeout","message":"The request took longer than 25 seconds and was stopped. Nothing was changed. Retry in 30 seconds.","retry_after_seconds":30}}}}}}}},"x-scope":"read"}},"/accounts/{account_id}/settings":{"get":{"summary":"Read account settings and data.guardrails (etag, last_change, pending, enforced_on, not_enforced_on)","operationId":"getAccountSettings","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Settings plus data.guardrails (GuardrailsState)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"guardrails":{"$ref":"#/components/schemas/GuardrailsState"}}}}}]}}}},"403":{"description":"insufficient_scope (permission is deny), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}}},"x-scope":"read","description":"From 1.9.0, GET /accounts/{id}/settings returns data.guardrails: etag (an opaque version of the five guardrails: content_rules, review_before_publish, auto_reply_enabled, video_autopilot, enabled), covers, last_change, pending, enforced_on and not_enforced_on. Shared policy, minimal version: the guardrails on the account are the active policy for every key and automation on it; a pending settings approval is the desired (proposed) change; the owner confirming it applies it. There is no separate policy object or proposal endpoint yet."},"patch":{"summary":"Update account settings (send only the fields to change)","operationId":"patchAccountSettings","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"persona":{"type":"string","description":"Brand persona used by all AI generation for this account (up to 4000 chars)"},"schedule_times":{"type":"string","description":"Comma-separated HH:MM in the account time_zone (returned by GET settings; Asia/Taipei unless the member picked another posting time zone in the dashboard), up to 8, e.g. \"09:00,12:30,21:00\". Queued library items publish at these times in order."},"random_schedule":{"type":"boolean","description":"true = ignore schedule_times and pick random_per_day random times every day inside random_window (account time_zone), skipping random_exclude"},"random_per_day":{"type":"integer","minimum":1,"maximum":30,"description":"Random posts per day, 1 to 30 (the plan daily limit still applies; a window too short for the 45-minute minimum gap posts fewer)"},"random_window":{"type":"string","example":"09:00-22:00","description":"\"HH:MM-HH:MM\" in the account time_zone, start before end; \"00:00-23:59\" = the whole day. Default 09:00-22:00"},"random_exclude":{"oneOf":[{"type":"array","items":{"type":"string"},"maxItems":3},{"type":"string"}],"example":["17:00-18:00"],"description":"Up to 3 ranges random times never fall into, e.g. [\"17:00-18:00\"] (or \"17:00-18:00,20:00-20:30\"). No range may cross midnight (split 23:00-01:00 into 23:00-23:59 and 00:00-01:00); ranges must not overlap; [] clears. Excluding the whole random_window is rejected."},"review_before_publish":{"type":"boolean","description":"true = AI-generated library items land in drafts and wait for POST /library/{id}/approve"},"auto_reply_enabled":{"type":"boolean","description":"AI auto-reply to comments on this account's own posts"},"auto_thread":{"type":"boolean","description":"Split >500-char content into a thread automatically (default true)"},"auto_link_to_comment":{"type":"boolean","description":"Move links in the body to the first comment"},"enabled":{"type":"boolean","description":"Master switch for automation on this account"},"video_autopilot":{"type":"boolean","description":"Daily auto-generated short video into the library (off by default; measured 1/3 the views of text posts on a small account, so keep it off unless video is your format). Paid plans only (Connect, Starter, Pro, Business; not during the free trial): up to 2 videos per account per rolling 7 days. Until the owner has approved one video, new videos land in the library as drafts and are published only after the owner queues them; after that they are queued directly. On other plans the value is stored and no video is generated."},"content_rules":{"type":"object","description":"Structured rules the platform enforces in code (generate, POST /library, PATCH /library/{id}, POST /content/publish), unlike the free-text persona which is only a prompt. { max_chars, min_chars, forbid_cta, forbid_hashtags, banned_phrases[], facts[], enforce }. enforce=warn (default) returns the content with rule_violations attached; enforce=block returns 422 instead and generation retries up to 3 model calls server-side before giving up. Send null to clear.","properties":{"max_chars":{"type":"integer","description":"1-5000"},"min_chars":{"type":"integer","description":"0-5000"},"forbid_cta":{"type":"boolean","description":"Reject calls to action (留言告訴我 / 私訊我 / follow me / link in bio ...)"},"forbid_hashtags":{"type":"boolean","description":"Reject hashtags"},"banned_phrases":{"type":"array","description":"Literal strings that must not appear, e.g. a competitor name","items":{"type":"string"}},"facts":{"type":"array","description":"Up to 50 plain-language facts, e.g. \"一天發 5 篇的帳號，平均 38 次瀏覽\". When set, every number in generated or submitted text must appear in one of these (commas ignored; 0-3 and dates/times exempt), Chinese quantity words like 一百多倍 / 三成 must appear verbatim in a fact, and a number the last 5 queued/published posts already used is a repeated_fact violation. This is the structural fix for models inventing, deriving or recycling statistics.","items":{"type":"string"}},"forbid_causal_claims":{"type":"boolean","description":"Reject cause/effect claims between numbers (有直接關係 / 越…越… / 導致 / 證明了) → unsupported_claim"},"judge_claims":{"type":"boolean","description":"Ask the model to review the text for relationships or conclusions the facts do not state (one extra flash call, only when the mechanical rules pass) → unsupported_claim"},"one_fact_per_post":{"type":"boolean","description":"Numbers in one post must all come from a single fact → multiple_facts"},"mention_limits":{"type":"array","description":"Per-phrase mention caps, e.g. [{\"phrase\":\"MindThread\",\"max\":1}] → mention_limit","items":{"type":"object","properties":{"phrase":{"type":"string"},"max":{"type":"integer"}}}},"enforce":{"type":"string","description":"warn | block"}}},"if_match":{"type":"string","description":"guardrails.etag from GET settings (1.9.0, optional). Compared only on the guardrails this body sends"},"reason":{"type":"string","maxLength":200,"description":"Why (1.9.0, optional): stored in the revision as plain text, links removed; only your key reads it back"},"dry_run":{"type":"boolean","description":"true = preview only (1.9.0): needs read, creates no approval, writes nothing; at most 10 a minute per key"}},"required":[]}}}},"responses":{"200":{"description":"Updated settings plus data.guardrails { etag, revision_id } (SettingsWriteResult; revision_id null when no guardrail changed or on a test key); with dry_run:true, SettingsDryRun","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SuccessEnvelope"},{"type":"object","properties":{"data":{"oneOf":[{"$ref":"#/components/schemas/SettingsWriteResult"},{"$ref":"#/components/schemas/SettingsDryRun"}]}}}]},"examples":{"applied":{"value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","data":{"account_id":"utOW1","content_rules":{"max_chars":220,"min_chars":80,"forbid_cta":true,"forbid_hashtags":true,"banned_phrases":["保證獲利","競品A"],"enforce":"block","facts":["客戶 120 位"],"forbid_causal_claims":false,"one_fact_per_post":false,"mention_limits":[],"judge_claims":false},"review_before_publish":true,"guardrails":{"etag":"g1.77aa0c12e4d3b2a1.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","revision_id":"grv_4f1c2a9e0b7d3e55"}}}},"dry_run":{"value":{"ok":true,"request_id":"req_mf1x2y3z4abcd","persisted":false,"data":{"dry_run":true,"account_id":"utOW1","changed":["content_rules"],"loosened":["banned_phrases_removed"],"tightened":[],"required_scope":"accounts:guardrails","your_mode":"ask","outcome":"approval_required","etag_now":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","etag_after":"g1.77aa0c12e4d3b2a1.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","impact":{"queued_checked":12,"queued_not_checked":0,"violating":0,"newly_violating":0,"would_be_held":0,"samples":[],"not_checked":["scheduled_posts","judge_claims","repeated_fact"]}}}}}}}},"400":{"description":"Validation (1.9.0 adds invalid_if_match, invalid_reason, invalid_dry_run)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"invalid_if_match":{"value":{"error":{"code":"invalid_if_match","message":"if_match must be the guardrails.etag from GET /accounts/{id}/settings (g1. followed by five 16-character parts)","request_id":"req_mf1x2y3z4abcd"}}},"invalid_reason":{"value":{"error":{"code":"invalid_reason","message":"reason must be a string of up to 200 characters","request_id":"req_mf1x2y3z4abcd"}}},"invalid_dry_run":{"value":{"error":{"code":"invalid_dry_run","message":"dry_run must be boolean","request_id":"req_mf1x2y3z4abcd"}}},"nothing_to_update":{"value":{"error":{"code":"nothing_to_update","message":"Provide at least one of: persona, schedule_times, ...","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"409":{"description":"approval_base_changed: only while the server runs a confirmed approval (recorded in the approval result)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"approval_base_changed":{"value":{"error":{"code":"approval_base_changed","message":"The account settings this approval touches changed after the owner was asked, so nothing was written. Read GET /accounts/{id}/settings again and resend.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"412":{"description":"guardrails_changed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GuardrailsChangedError"}}}}},"x-scope":"content:write","x-scope-alt":{"scope":"accounts:guardrails","when":"the PATCH loosens a guardrail (see x-scopes); with dry_run:true the whole request needs only read (1.9.0)"},"description":"content_rules is replaced as a whole: rules left out of the object are removed. PATCH /accounts/{id}/settings now really replaces content_rules as a whole on live keys, as documented: before 1.8.3 a live write merged the object key by key, so rules left out of the body silently stayed. A facts change counts as loosening (accounts:guardrails) when a fact is new ignoring spaces, when the set of numbers the facts allow grows (a space inside 101563 allows 10 and 1563), or when a new Chinese quantity phrase appears. A settings approval (PATCH /accounts/{id}/settings waiting for the owner) now shows the owner every field the body touches as current and proposed value, using the value the server would actually write, including fields that are not guardrails such as persona and schedule_times; content_rules is itemized down to the added and removed facts and banned phrases and the enforce change. A fact that differs only in spaces is listed too, with the numbers the change newly allows. The comparison is capped at 60,000 characters: long current values are shortened (truncated:true), and a request whose comparison still does not fit answers 413 approval_payload_too_large. Such an approval also records the current value of every field the body touches. If any of those fields changes before the request runs, it is not run: the approval turns failed with result.error.code approval_base_changed as soon as it is read, listed or decided (deciding answers 409 approval_base_changed, checked in the same transaction, and always is not applied), or right before it runs. Changes to fields the body does not touch do not matter. Read the settings again and resend: the same body then gets a new approval. Settings approvals created before 1.8.3 have no recorded values and end the same way when read, listed or decided. PATCH /accounts/{id}/settings accepts an optional if_match with that etag. It is compared only on the guardrails the body sends, content_rules as one part and each of the four switches on its own, so a change to another part does not refuse the request. If a sent part changed since you read it, the answer is 412 guardrails_changed with current_etag, changed, current (the five current values) and last_change, and nothing is written: read again, apply your change to the current content_rules (it is replaced as a whole) and resend. Without if_match the last writer wins, as before, and every change is recorded. dry_run:true only previews: it needs the read permission, creates no approval and writes nothing, and each key can dry-run at most 10 times a minute (429 rate_limit_exceeded). It answers changed, loosened, tightened, required_scope, your_mode, outcome (apply, approval_required or denied), etag_now and impact: how many of the first 200 queued library items, in publishing order, the new content_rules would newly flag, checked with the fixed rules only (no judge_claims, no scheduled posts). Loosening is now decided field by field from one comparison table that every content_rules field must be declared in: a difference that is not proven stricter counts as loosening, and a change that loosens one rule and tightens another counts as loosening. The first facts list on an account that had none is not loosening, because numbers were not checked before; the revision records it as facts_created. The same comparison decides the permission, the approval preview, and loosened and tightened in revisions and dry runs. Writes are transactional: a settings approval that runs after the owner confirmed checks its recorded values again in the same transaction as the write, and a request that became loosening after the permission check (the guardrails changed in between) answers 412 guardrails_changed instead of writing. When a guardrail is loosened without the owner pressing allow (the key has accounts:guardrails on allow, or it is a legacy key), the owner gets an in-app notification (no email); more loosening by the same key on the same account within the same 30 minutes updates that notification instead of adding another. content_rules can only be changed through PATCH /accounts/{id}/settings: the web app's direct database writes can no longer change it (the web app never wrote it), and an account that has had content_rules cannot be deleted and created again under the same id from the web app, so every change is recorded.","x-scope-dry-run":"read"}},"/accounts/{account_id}/material":{"get":{"summary":"Read the account material digest (who / sells / claims / experiences / faq / numbers / voice) that every generation path appends to the persona","operationId":"getAccountMaterial","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Material","content":{"application/json":{"example":{"ok":true,"data":{"has_material":true,"digest":"是誰：…\n核心主張：…","digest_at":"2026-09-07T00:00:00.000Z","stats":{"topPosts":20,"pageChars":4554,"knowledgeChars":0,"notesChars":0}}}}}},"403":{"description":"insufficient_scope (permission is deny), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"read"},"post":{"summary":"Build (or rebuild) the material from your own site pages, uploaded knowledge files, notes and the account's top posts. Counts as 1 AI generation. Numbers and experiences are only taken from pages/notes, never from old posts.","operationId":"buildAccountMaterial","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"urls":{"type":"array","description":"Up to 8 https:// pages: homepage, product, pricing, blog posts. Omit to reuse the previous sources.","items":{"type":"string"}},"notes":{"type":"string","description":"Real experiences, cases, FAQs the site does not say (≤6000 chars). This is the best place for the facts only you know."},"dry":{"type":"boolean","description":"true = return the digest without saving"}},"required":[]}}}},"responses":{"200":{"description":"Built material (same shape as GET, plus dry/saved)","content":{"application/json":{}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"429":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write"},"delete":{"summary":"Remove the material; generation falls back to persona only","operationId":"deleteAccountMaterial","parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Removed","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}}},"x-scope":"content:write"}},"/content/generate":{"post":{"summary":"Generate 1-5 posts with a proven formula and the account persona (does not publish)","operationId":"generateContent","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"topic":{"type":"string","description":"What to write about"},"account_id":{"type":"string","description":"Use this account's persona"},"formula":{"type":"string","description":"auto | curiosity_hook | ... (GET /formulas)"},"count":{"type":"integer","description":"1-5"},"quality":{"type":"string","description":"fast | standard | premium (paid plans)"},"context":{"type":"string","description":"Optional reference material (up to 8000 chars)"},"idempotency_key":{"type":"string","description":"Optional"}},"required":["topic"]}}}},"description":"The account persona takes precedence over the formula template: where they conflict, the account wins. If the account has content_rules, generated text is checked against them; a violating batch is regenerated once, and whatever comes back carries rule_violations so you can see what is still off (or a 422 when enforce=block).","responses":{"200":{"description":"Generated posts","content":{"application/json":{"example":{"ok":true,"data":{"contents":[{"text":"...","formula_used":"curiosity_hook","char_count":148,"rule_violations":[]}]},"usage":{"ai_generations_used":1,"credits_used":1},"content_rules":{"max_chars":220,"min_chars":80,"forbid_cta":true,"forbid_hashtags":true,"banned_phrases":[],"enforce":"warn"},"regenerated_for_rules":false,"quality_requested":"standard","quality_used":"standard","model_used":"gemini-2.5-flash"}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"422":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"429":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write"}},"/content/generate-and-schedule":{"post":{"summary":"Generate one post and publish now or schedule it","operationId":"generateAndSchedule","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"topic":{"type":"string","description":"Topic"},"account_id":{"type":"string","description":"Target account"},"publish_now":{"type":"boolean","description":"Publish immediately (mutually exclusive with publish_at)"},"publish_at":{"type":"string","description":"ISO 8601 with offset (if not publish_now). Canonical name on every scheduling endpoint"},"schedule_at":{"type":"string","description":"Deprecated alias of publish_at","deprecated":true},"formula":{"type":"string","description":"auto or a formula id"},"quality":{"type":"string","description":"fast | standard | premium"},"context":{"type":"string","description":"Optional reference material"},"idempotency_key":{"type":"string","description":"Optional"}},"required":["topic","account_id"]}}}},"responses":{"200":{"description":"Post created","content":{"application/json":{}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_not_supported (permission is ask: this endpoint never waits for approval)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"422":{"description":"content_rules_violated: the account has enforce:block and the text breaks its content rules; nothing was written, scheduled or published","content":{"application/json":{"example":{"error":{"code":"content_rules_violated","message":"Violates this account's content rules (enforce=block)","violations":[{"rule":"banned_phrase","detail":"含禁用詞「保證獲利」"}],"guardrails_etag":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:schedule","x-scope-alt":{"scope":"content:publish_now","when":"publish_now is truthy, or publish_at is less than 30 minutes away"},"x-approval":"not_supported","description":"Checks the generated text against the account's content_rules (1.8.3). /content/generate-and-schedule and /content/generate-thread now put the rules in the prompt and regenerate a violating draft (up to 3 model calls with enforce:block, 2 with warn), like /content/generate; model_calls says how many were made. Test keys get the same 422: /content/schedule and /content/publish-thread check the submitted text, and the two generating paths check their mock text, which contains the topic, so a banned phrase in the topic rehearses the refusal. The mock text is checked only against banned_phrases, forbid_cta and forbid_hashtags, because length and number rules need real text: a test key can still rehearse a successful call, and an ask permission on /content/generate-thread still creates its approval. The 200 carries data.content.rule_violations and data.content.model_calls. Posts scheduled through the API are checked again right before they publish, against the rules in force at that moment: with enforce:block a violating post is not published but moved to draft with held_reason and rule_violations (GET /schedules?status=draft), the owner is notified in the web app, and post.failed with error content_rules_violated is emitted; with warn it publishes and the violations are recorded. The 200 carries data.warnings[] (components.schemas.PostWarning), empty when nothing looks off; warnings never block (1.17.0)."}},"/content/generate-thread":{"post":{"summary":"Generate a multi-part thread (2-10 parts)","operationId":"generateThread","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"topic":{"type":"string","description":"Topic"},"thread_count":{"type":"integer","description":"2-10"},"account_id":{"type":"string","description":"Persona source"},"formula":{"type":"string","description":"auto or id"},"context":{"type":"string","description":"Optional"}},"required":["topic"]}}}},"responses":{"200":{"description":"Thread parts","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"422":{"description":"content_rules_violated: the account has enforce:block and the text breaks its content rules; nothing was written, scheduled or published","content":{"application/json":{"example":{"error":{"code":"content_rules_violated","message":"Violates this account's content rules (enforce=block)","violations":[{"index":1,"rule_violations":[]},{"index":2,"rule_violations":[{"rule":"cta","detail":"命中行動呼籲句式 留言(告訴|跟|讓|給)我"}]}],"guardrails_etag":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write","description":"When account_id is yours, checks every generated part against its content_rules (1.8.3); an unknown account_id is still ignored. /content/generate-and-schedule and /content/generate-thread now put the rules in the prompt and regenerate a violating draft (up to 3 model calls with enforce:block, 2 with warn), like /content/generate; model_calls says how many were made. Test keys get the same 422: /content/schedule and /content/publish-thread check the submitted text, and the two generating paths check their mock text, which contains the topic, so a banned phrase in the topic rehearses the refusal. The mock text is checked only against banned_phrases, forbid_cta and forbid_hashtags, because length and number rules need real text: a test key can still rehearse a successful call, and an ask permission on /content/generate-thread still creates its approval. Each thread_parts item carries rule_violations; data.model_calls says how many model calls were made."}},"/content/publish-thread":{"post":{"summary":"Publish a thread (array of 2-10 texts) now","operationId":"publishThread","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_id":{"type":"string","description":"Target account"},"thread_parts":{"type":"array","description":"2-10 texts","items":{"type":"string"}},"idempotency_key":{"type":"string","description":"Optional"}},"required":["account_id","thread_parts"]}}}},"responses":{"200":{"description":"Published","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"422":{"description":"content_rules_violated: the account has enforce:block and the text breaks its content rules; nothing was written, scheduled or published","content":{"application/json":{"example":{"error":{"code":"content_rules_violated","message":"Violates this account's content rules (enforce=block)","violations":[{"index":0,"rule_violations":[{"rule":"banned_phrase","detail":"含禁用詞「保證獲利」"}]},{"index":1,"rule_violations":[]}],"guardrails_etag":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:publish_now","description":"Checks every part against the account's content_rules (1.8.3); with enforce:block one violating part stops the whole thread (nothing is published). Test keys get the same 422: /content/schedule and /content/publish-thread check the submitted text, and the two generating paths check their mock text, which contains the topic, so a banned phrase in the topic rehearses the refusal. The mock text is checked only against banned_phrases, forbid_cta and forbid_hashtags, because length and number rules need real text: a test key can still rehearse a successful call, and an ask permission on /content/generate-thread still creates its approval. The 200 carries data.rule_violations as [{ index, rule_violations }]."}},"/content/schedule":{"post":{"summary":"Schedule an existing text (≤500 chars) at a time or at the next optimal slot","operationId":"scheduleContent","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_id":{"type":"string","description":"Target account"},"text":{"type":"string","description":"Post text"},"publish_at":{"type":"string","description":"ISO 8601 with offset. Canonical name on every scheduling endpoint; mutually exclusive with auto_optimize_time"},"schedule_at":{"type":"string","description":"Deprecated alias of publish_at","deprecated":true},"auto_optimize_time":{"type":"boolean","description":"Pick the next best slot instead of publish_at"},"idempotency_key":{"type":"string","description":"Optional"}},"required":["account_id","text"]}}}},"responses":{"200":{"description":"Scheduled","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"422":{"description":"content_rules_violated: the account has enforce:block and the text breaks its content rules; nothing was written, scheduled or published","content":{"application/json":{"example":{"error":{"code":"content_rules_violated","message":"Violates this account's content rules (enforce=block)","violations":[{"rule":"banned_phrase","detail":"含禁用詞「保證獲利」"}],"guardrails_etag":"g1.3f2a9c0144be7d10.8b7d1e22c9a0f311.aa01bc34d2e5f607.0f9e8d7c6b5a4938.11223344556677aa","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:schedule","x-scope-alt":{"scope":"content:publish_now","when":"publish_at is less than 30 minutes away (or in the past)"},"description":"Checks the account's content_rules before scheduling (1.8.3). Test keys get the same 422: /content/schedule and /content/publish-thread check the submitted text, and the two generating paths check their mock text, which contains the topic, so a banned phrase in the topic rehearses the refusal. The mock text is checked only against banned_phrases, forbid_cta and forbid_hashtags, because length and number rules need real text: a test key can still rehearse a successful call, and an ask permission on /content/generate-thread still creates its approval. The 200 carries data.rule_violations. Posts scheduled through the API are checked again right before they publish, against the rules in force at that moment: with enforce:block a violating post is not published but moved to draft with held_reason and rule_violations (GET /schedules?status=draft), the owner is notified in the web app, and post.failed with error content_rules_violated is emitted; with warn it publishes and the violations are recorded. The 200 carries data.warnings[] (components.schemas.PostWarning), empty when nothing looks off; warnings never block (1.17.0)."}},"/content/publish":{"post":{"summary":"Publish or schedule text with images (1 image, 2-10 = carousel) or a video","operationId":"publishContent","description":"The most complete publish endpoint. Media URLs must be public https (Meta fetches them). Over 500 chars auto-splits into a thread with the media on the first post. Scheduled posts go out within 5 minutes of publish_at via the same pipeline the web app uses; cancel with DELETE /schedules/{id}. From 1.8.3 the 200 carries data.post.rule_violations on live keys too (it used to be only on test keys), and topic_tag is checked against banned_phrases. Matching ignores invisible format characters such as zero-width spaces, compares banned_phrases and mention_limits after Unicode NFKC and case folding, and skips a number written next to - : / only when it is part of a date, time or range such as 2026-09-25, 12:30 or 5-10 (so 100000/month now counts). A topic_tag is checked against banned_phrases too; forbid_hashtags covers #hashtags in the text, and on an account with it on, posts from the API and the library go out without a Threads topic tag (topic_tag comes back null). Stored banned phrases are normalized the same way and capped at 100 characters, and invisible characters are removed from facts. Every path checks the fixed rules (max_chars, min_chars, forbid_cta, forbid_hashtags, banned_phrases, facts, forbid_causal_claims, one_fact_per_post, mention_limits). The model review (judge_claims) and the recently used numbers check (repeated_fact) run only on POST /content/generate, POST /library and PATCH /library/{id}; every other path, including the check right before a scheduled post publishes, runs the fixed rules only. The 200 carries data.warnings[] (components.schemas.PostWarning), empty when nothing looks off; warnings never block (1.17.0).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_id":{"type":"string","description":"Target account"},"text":{"type":"string","description":"Caption / post text (optional when media is given)"},"media_urls":{"type":"array","description":"Public https image URLs; 1 = single image, 2-10 = carousel","items":{"type":"string"}},"video_url":{"type":"string","description":"Public https MP4/MOV (H264/HEVC, ≤5 min, ≤1GB); cannot combine with media_urls"},"publish_now":{"type":"boolean","description":"Publish immediately"},"publish_at":{"type":"string","description":"ISO 8601 (if not publish_now)"},"auto_thread":{"type":"boolean","description":"default true"},"topic_tag":{"type":"string","description":"Optional Threads topic tag (the official topic_tag parameter, one per post). Plain words only, e.g. 感情 / 職場 / Threads 新手: 1-50 chars, no #, no punctuation (Threads rejects \".\" and \"&\"), no line breaks or emoji. Sanitized server-side; if Threads still rejects it the post is retried once WITHOUT the tag and the response carries topic_tag_dropped: true instead of failing.","maxLength":50},"idempotency_key":{"type":"string","description":"Optional"}},"required":["account_id"]}}}},"responses":{"200":{"description":"Published or scheduled","content":{"application/json":{"example":{"ok":true,"data":{"post":{"id":"abc","kind":"carousel","status":"published","threads_post_id":"1809...","topic_tag":"感情"},"warnings":[{"code":"off_hours","message":"Scheduled for 03:00 (Asia/Taipei), outside this account's usual posting hours (9:00, 12:00-13:00, 21:00, based on the last 60 days of posts). Make sure this time is intended.","message_zh":"排在 03:00（Asia/Taipei）發出，這個帳號平常在 9 點、12 點到 13 點、21 點發文（依近 60 天的發文紀錄）。確定要在這個時間發嗎？","detail":{"publish_at":"2026-10-27T19:00:00.000Z","local_time":"03:00","time_zone":"Asia/Taipei","usual_hours":[9,12,13,21],"usual_source":"history+schedule","posts_considered":58}}]}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"502":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:schedule","x-scope-alt":{"scope":"content:publish_now","when":"publish_now === true, or publish_at is less than 30 minutes away"}}},"/schedules":{"get":{"summary":"List scheduled posts","operationId":"listSchedules","parameters":[{"name":"account_id","in":"query","required":false,"description":"Filter by account","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"Only posts with this status, for example draft (held by content rules or reclaimed after an unfinished run) or published; without it you get scheduled, pending and publishing. The filter applies to the latest 100 posts of the member","schema":{"type":"string"}}],"responses":{"200":{"description":"Schedules","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read","description":"Default filter: scheduled, pending and publishing; pass status=draft to see drafts. Items carry held_reason and rule_violations (1.8.3): Posts scheduled through the API are checked again right before they publish, against the rules in force at that moment: with enforce:block a violating post is not published but moved to draft with held_reason and rule_violations (GET /schedules?status=draft), the owner is notified in the web app, and post.failed with error content_rules_violated is emitted; with warn it publishes and the violations are recorded. Items held by content_rules at publish time carry held_guardrails_etag next to held_reason (1.9.0): 422 content_rules_violated now carries guardrails_etag, the version of the rules that refused the text; a scheduled API post held at publish time carries held_guardrails_etag next to held_reason (GET /schedules) and guardrails_etag in post.failed, and a queued library item held at publish time carries held_guardrails_etag next to held_reason (GET /library). An item with held_reason publish_result_unknown (reclaimed: true) was being published when the run was cut off and may already be on Threads: ask the owner to check Threads; only the owner can queue or reschedule it again, in the web app (1.9.1). Scheduled, pending and draft posts carry warnings[] with changed_since_last_viewed when the text, media or publish time differs from the last viewed version (1.18.0); reading them here records them as read through the API (mt_test_ keys do not record)."}},"/schedules/{id}":{"delete":{"summary":"Cancel a scheduled post (moves it to draft)","operationId":"cancelSchedule","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Cancelled","content":{"application/json":{}}},"400":{"description":"cannot_cancel (the post already published or failed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"cannot_cancel":{"value":{"error":{"code":"cannot_cancel","message":"Cannot cancel a post with status \"published\"","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"publishing_in_progress (1.9.1)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"publishing_in_progress":{"value":{"error":{"code":"publishing_in_progress","message":"This post is being published right now and can no longer be cancelled; check GET /schedules in a minute","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"content:schedule","description":"A post that is being published (status publishing) can no longer be cancelled: 409 publishing_in_progress (1.9.1; it used to be 400 cannot_cancel)."}},"/library":{"get":{"summary":"List library items for an account by status; queued items carry position and next_publish_at","operationId":"listLibrary","parameters":[{"name":"account_id","in":"query","required":true,"description":"Account","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"queued | draft | published | failed | archived (default queued)","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"max 200","schema":{"type":"integer"}}],"responses":{"200":{"description":"Items","content":{"application/json":{"example":{"ok":true,"data":{"account_id":"utOWPxV1FLEeLK36xygM","status":"queued","count":2,"schedule_times":"12:30,16:30","items":[{"id":"a","text":"...","position":1,"next_publish_at":"2026-09-06T04:30:00.000Z","source":"api_v1","ai_generated":false}]}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read","description":"Items held by content_rules at publish time carry held_guardrails_etag next to held_reason (1.9.0): 422 content_rules_violated now carries guardrails_etag, the version of the rules that refused the text; a scheduled API post held at publish time carries held_guardrails_etag next to held_reason (GET /schedules) and guardrails_etag in post.failed, and a queued library item held at publish time carries held_guardrails_etag next to held_reason (GET /library). An item with held_reason publish_result_unknown (reclaimed: true) was being published when the run was cut off and may already be on Threads: ask the owner to check Threads; only the owner can queue or reschedule it again, in the web app (1.9.1). Queued and draft items carry warnings[] (1.17.0): stale_time_reference when the text says 昨天 / 上週 / yesterday and similar and it will publish on a later day than created_at (next_publish_at for queued items, now for drafts). Queued and draft items also carry changed_since_last_viewed (1.18.0); reading them here records them as read through the API (mt_test_ keys do not record)."},"post":{"summary":"Add up to 20 items to the library (queued = publish in order at schedule_times; draft = wait for approval). Content rules apply: warn attaches rule_violations per item, block rejects the whole batch with 422. media_urls must be public https (max 10 per item); anything else rejects the batch with 400 invalid_media_urls rather than silently dropping the image.","operationId":"addLibrary","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_id":{"type":"string","description":"Account"},"status":{"type":"string","description":"queued (default) | draft"},"items":{"type":"array","description":"Items","items":{"type":"object","properties":{"text":{"type":"string"},"media_urls":{"type":"array","items":{"type":"string"}}}}},"idempotency_key":{"type":"string","description":"Optional"}},"required":["account_id","items"]}}}},"responses":{"200":{"description":"Added","content":{"application/json":{"example":{"ok":true,"data":{"added":3,"ids":["a","b","c"],"items":[{"id":"a","rule_violations":[]}]}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"422":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write","x-scope-alt":{"scope":"content:schedule","when":"status is not 'draft' (items are queued and publish automatically)"}}},"/library/{id}":{"delete":{"summary":"Delete a queued, draft or archived item","operationId":"deleteLibrary","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write"},"patch":{"summary":"Archive / restore, edit the text, or move an item in the queue","operationId":"patchLibrary","description":"status: archived | draft | queued (archived items never publish and can be restored). text: replace the content (content rules apply; block → 422). position: first | last, or order: number to place it in the publish queue. Published items cannot be changed. An item that is being published (status publishing) cannot be changed: 409 publishing_in_progress. Setting status queued on an item with held_reason publish_result_unknown (reclaimed: true, also after it was archived) answers 409 publish_result_unknown: the owner checks Threads and re-queues it in the web app. When the status changes between the read and the write, nothing is written and it answers 409 status_changed: read it again and retry (1.9.1). When the item ends up queued (already queued, or this call queues it), data.warnings[] carries changed_since_last_viewed if the content differs from the last viewed version (1.18.0). Editing the text is not viewing it: the owner has not seen your edit until the web app shows it.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","description":"archived | draft | queued"},"text":{"type":"string","description":"New text (≤2000 chars)"},"position":{"type":"string","description":"first | last"},"order":{"type":"integer","description":"Explicit order value"}},"required":[]}}}},"responses":{"200":{"description":"Updated item","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"already_published, publishing_in_progress, publish_result_unknown or status_changed (the last three from 1.9.1)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"already_published":{"value":{"error":{"code":"already_published","message":"Published items cannot be changed","request_id":"req_mf1x2y3z4abcd"}}},"publishing_in_progress":{"value":{"error":{"code":"publishing_in_progress","message":"This item is being published right now; read it again in a minute","request_id":"req_mf1x2y3z4abcd"}}},"publish_result_unknown":{"value":{"error":{"code":"publish_result_unknown","message":"This draft was being published when the run was cut off, so it may already be on Threads. Ask the account owner to check Threads, then re-queue it in the web app (Library → Drafts) only if it was not posted, or delete it.","request_id":"req_mf1x2y3z4abcd"}}},"status_changed":{"value":{"error":{"code":"status_changed","message":"Item status changed to queued while updating; read it again and retry","request_id":"req_mf1x2y3z4abcd"}}}}}}},"422":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write","x-scope-alt":{"scope":"content:schedule","when":"status is 'queued', or text changes on an item that is already queued"}}},"/library/{id}/approve":{"post":{"summary":"Approve a draft → queued (also satisfies review_before_publish)","operationId":"approveLibrary","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Queued","content":{"application/json":{"example":{"ok":true,"data":{"id":"lib_abc","status":"queued","warnings":[{"code":"changed_since_last_viewed","message":"Changed since the account owner last viewed it (10/25 14:02, Asia/Taipei): 1 sentence removed, 1 added. Review the difference before it goes out.","message_zh":"你上次在 10/25 14:02 看過之後，這篇被改過：刪掉 1 句、加了 1 句。放行前看一下差異。","detail":{"viewed_at":"2026-10-25T06:02:00.000Z","viewed_by":"member","removed":["名額有限。"],"added":["名額已滿，請改報下一梯。"],"removed_count":1,"added_count":1,"media_changed":false,"time_changed":false,"previous_text":"新制下週上路。名額有限。","current_text":"新制下週上路。名額已滿，請改報下一梯。","library_id":"lib_abc"}}]}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"not_a_draft, publishing_in_progress or publish_result_unknown (the last two from 1.9.1)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"},"examples":{"not_a_draft":{"value":{"error":{"code":"not_a_draft","message":"Item is queued, only drafts can be approved","request_id":"req_mf1x2y3z4abcd"}}},"publishing_in_progress":{"value":{"error":{"code":"publishing_in_progress","message":"This item is being published right now; read it again in a minute","request_id":"req_mf1x2y3z4abcd"}}},"publish_result_unknown":{"value":{"error":{"code":"publish_result_unknown","message":"This draft was being published when the run was cut off, so it may already be on Threads. Ask the account owner to check Threads, then re-queue it in the web app (Library → Drafts) only if it was not posted, or delete it.","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"content:schedule","description":"A draft with held_reason publish_result_unknown (reclaimed: true) was being published when the run was cut off and may already be on Threads. Approving it answers 409 publish_result_unknown: the owner checks Threads and re-queues it in the web app. An item being published answers 409 publishing_in_progress (1.9.1). Returns warnings[] with changed_since_last_viewed (1.18.0, never blocks) when the content differs from the last version the account owner saw on the web, or, if the owner never saw it, from the last version read through the API."}},"/library/bulk":{"post":{"summary":"Archive, delete, approve or queue up to 50 items in one call","operationId":"bulkLibrary","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","description":"archive | delete | approve | queue"},"ids":{"type":"array","description":"Up to 50 library item ids","items":{"type":"string"}}},"required":["action","ids"]}}}},"responses":{"200":{"description":"Per-item results","content":{"application/json":{"example":{"ok":true,"data":{"action":"archive","requested":13,"done":13,"results":[{"id":"a","ok":true,"status":"archived"}]}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}}},"x-scope":"content:write","x-scope-alt":{"scope":"content:schedule","when":"action is 'approve' or 'queue'"},"description":"Per-item errors include publishing_in_progress (archive, approve or queue on an item being published) and publish_result_unknown (approve or queue on an item that may already be on Threads, and queue also after it was archived; the owner re-queues it in the web app after checking) (1.9.1). For approve and queue, each queued result carries warnings[] with changed_since_last_viewed when its content differs from the last viewed version (1.18.0)."}},"/patrol/cloud":{"get":{"summary":"Read cloud patrol config and status for an account","operationId":"getCloudPatrol","parameters":[{"name":"account_id","in":"query","required":true,"description":"Account","schema":{"type":"string"}}],"responses":{"200":{"description":"Config","content":{"application/json":{"example":{"ok":true,"data":{"enabled":true,"keywords":["理財","存股"],"daily_cap":10,"replies_today":4,"review_before_reply":false,"last_scan_note":"ok","min_interval_min":15,"est_max_today":10,"cadence":{"enabled_configs":25,"accounts_per_tick":12,"cron_min":15,"window_hours":14},"today":{"scans":20,"sent":4,"no_candidates":6,"no_match":9,"quality_blocked":1,"budget_cut":0},"keyword_hint":true}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"},"put":{"summary":"Create or update cloud patrol: keywords (1-10, \"#tag\" = topic-tag search), persona, daily_cap (reply mode: ≤50 free/trial, ≤80 paid, ≤150 with add-on; discover mode: default = your plan's daily haixun points, can only be set lower), enabled, review_before_reply, min_interval_min (15/30/60/120, slower only), mode (reply | discover), reply_max (20-200 characters per reply, null = default)","operationId":"putCloudPatrol","description":"mode \"discover\" (2026-10-18) only finds posts: the keyword search runs every 15 minutes around the clock (no reply-hours window), no AI model is called (no screening, no relevance or sensitivity judgment, no drafting), no language filter and nothing is ever posted. Each round looks at the newest 25 posts per keyword from the last 24h and lists every new one (no 1-per-round limit); each newly listed post uses 1 haixun point from the same daily pool as replies, a post already listed for this account is never charged twice (deduplicated by post id), and listing stops for the day when the points run out. Listed posts appear in GET /patrol/cloud/pending as type \"discovered\" with permalink, posted_at, author, text and found_at, draft null, kept 7 days, and a patrol.pending event fires with type \"discovered\" and draft null. In discover mode daily_cap defaults to your plan's daily haixun points (shown as hard_cap on GET) and can only be set lower; send daily_cap: null to go back to the default. Turning discover on (enabled true with mode discover) needs only content:write and never asks the key owner, because nothing can be posted; turning reply mode on, or switching a running discover config back to reply, still needs patrol:cloud_enable. Discover keeps running when the site-wide reply fuse is hit (that fuse only stops replies). Discovered items cannot be approved (409 discovered_item); open permalink and reply on Threads yourself, or reject to dismiss. mode \"reply\" (default, unchanged): Cloud patrol searches Threads for the keywords every 15 minutes (an entry starting with \"#\" searches posts carrying that topic tag instead of free text, e.g. \"#育兒\"), lets the AI judge which fresh posts are worth a supportive, on-topic reply in the account persona, and replies through the official API. 1 haixun point per delivered reply. Sensitive topics are skipped; canned openers and duplicates are blocked server-side. With review_before_reply=true nothing is sent: drafts wait in GET /patrol/cloud/pending (a patrol.pending event fires) until you approve or reject them; unapproved drafts expire after 24h.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_id":{"type":"string","description":"Account"},"keywords":{"type":"array","description":"1-10 entries, each up to 30 chars. Plain text = keyword search; prefix \"#\" = topic-tag search (posts tagged with that topic, usually more on-topic), e.g. [\"理財\", \"#存股\"]","items":{"type":"string"}},"persona":{"type":"string","description":"Reply persona (optional, falls back to account persona)"},"daily_cap":{"type":"integer","description":"reply mode: 1-50 free/trial, up to 80 paid, up to 150 with add-on. discover mode: 1 to your plan's daily haixun points (default), or null for the default"},"enabled":{"type":"boolean","description":"Start / stop"},"review_before_reply":{"type":"boolean","description":"Hold every drafted reply for approval instead of sending (governance mode). The same switch is on the web: Patrol > Cloud patrol > Review before posting (also step 3 of patrol onboarding); both write the same field"},"min_interval_min":{"type":"integer","description":"Minimum minutes between two replies from this account: 15 (system pace, default), 30, 60 or 120. Can only slow an account down; there is no faster option because every reply is published through the platform app. The effective pace is reported back as est_max_today / cadence on GET."},"reply_max":{"type":"integer","minimum":20,"maximum":200,"description":"Maximum characters per reply (20-200), or null for the default for the account language (50 for Chinese without account material, 150 with material). A persona that asks for a length is followed up to this limit; also limits rotate_replies and the imported library. When reply_max is not set and the cloud patrol persona states a reply length (e.g. 50-100 字, under 25 words), that length clamped to 20-200 is the limit. GET returns reply_max (in effect), reply_max_custom, reply_max_default, reply_max_persona and reply_max_source (custom, persona or default)."},"mode":{"type":"string","enum":["reply","discover"],"description":"\"reply\" (default): AI judges posts and drafts/posts replies. \"discover\": only list matching posts (no AI, nothing posted; 1 haixun point per newly listed post)"},"reply_mode":{"type":"string","enum":["ai","rotate","consume"],"description":"\"ai\" (default; configs without this field are ai): AI writes each reply in the persona. \"rotate\": the AI still decides which posts to reply to, but the reply text is the next fixed reply in order, posted word for word, starting over after the last one; the index advances after each sent or pending reply. \"consume\" (1.20.0): like rotate, but each reply is used once; when all are used the account stops replying (last_scan_note library_exhausted). Fixed replies come from rotate_replies (up to 10) or, when one exists, the imported reply library (up to 2,000, POST /patrol/cloud/library/import). They skip the duplicate-reply check but still pass content rules, the self-harm filter, the reply quality checks and the fact bank (managed accounts); in rotate mode a blocked reply is skipped and the index does not advance, in consume mode it is marked used (outcome blocked) so one bad line never stalls the account. Repeating the same replies raises the risk of Threads treating them as spam; that risk is yours."},"rotate_replies":{"type":"array","description":"1-10 fixed replies for reply_mode \"rotate\" (blank lines dropped; each within the account reply length limit; 400 invalid_rotate_reply names which reply failed and why). Changing them resets rotate_index to 0. GET returns reply_mode, rotate_replies, rotate_index and next_rotate_reply (1-based).","items":{"type":"string"}}},"required":["account_id"]}}}},"responses":{"200":{"description":"Config","content":{"application/json":{}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}}},"x-scope":"content:write","x-scope-alt":{"scope":"patrol:cloud_enable","when":"the resulting config has enabled === true and mode is not \"discover\" (discover only lists posts and never posts, so it needs only content:write)"}},"post":{"summary":"Same as PUT /patrol/cloud (kept for older clients)","operationId":"setCloudPatrolPost","description":"Identical body and behaviour to PUT /patrol/cloud.","responses":{"200":{"description":"Saved"},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}}},"x-scope":"content:write","x-scope-alt":{"scope":"patrol:cloud_enable","when":"the resulting config has enabled === true and mode is not \"discover\" (discover only lists posts and never posts, so it needs only content:write)"}}},"/patrol/cloud/log":{"get":{"summary":"Replies sent by cloud patrol (last 1-7 days)","operationId":"cloudPatrolLog","parameters":[{"name":"account_id","in":"query","required":true,"description":"Account","schema":{"type":"string"}},{"name":"days","in":"query","required":false,"description":"1-7 (default 2)","schema":{"type":"integer"}}],"responses":{"200":{"description":"Entries","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/patrol/cloud/stats":{"get":{"summary":"Effectiveness of cloud patrol replies: views, likes, top replies (1-14 days)","operationId":"cloudPatrolStats","parameters":[{"name":"account_id","in":"query","required":true,"description":"Account","schema":{"type":"string"}},{"name":"days","in":"query","required":false,"description":"1-14 (default 7)","schema":{"type":"integer"}}],"responses":{"200":{"description":"Stats","content":{"application/json":{"example":{"ok":true,"data":{"total":{"replies":35,"views":6800,"likes":21,"avg_views_per_reply":194},"top":[]}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/patrol/cloud/keyword-suggestions":{"get":{"summary":"AI keyword suggestions for cloud patrol (diagnoses first; suggestions only, never changes keywords)","operationId":"cloudPatrolKeywordSuggestions","description":"Same engine as the web app button. Diagnoses what is actually blocking the account (auth, points, daily cap, keywords, language; repeats = find-posts-only mode where search works but found posts are mostly already listed or older than 24 h). Only when keywords are the problem does it ask the AI for candidates, test-search each one with the account's own Threads connection and keep 5-8 with evidence (recent posts found, a judged sample, two example posts). Runs at most once per account per 24 hours (repeat calls return the saved result with cached:true at no AI cost); a repeat within 2 minutes of a failed run returns 429 too_soon. At most 3 AI calls per run, counted in the cloud patrol AI budget; when that budget is used up the result has incomplete:\"budget\". Needs content:write. Test keys return only saved results and never run the AI. To use a suggestion, PUT /patrol/cloud with the full keywords array; keywords from the latest suggestion list are recorded as AI-suggested.","parameters":[{"name":"account_id","in":"query","required":true,"description":"Account","schema":{"type":"string"}}],"responses":{"200":{"description":"Diagnosis and suggestions","content":{"application/json":{"example":{"ok":true,"data":{"account_id":"acc_123","cached":false,"diagnosis":{"kind":"keywords","keywords_are_the_problem":true,"dead_keywords":["brand name"]},"suggestions":[{"keyword":"失眠","why":"customers describe the need this way","found_recent":18,"fresh_candidates":9,"sample_judged":{"worth":2,"checked":2},"examples":[]}],"next_available_at":"2026-10-04T05:00:00.000Z"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}}},"x-scope":"content:write"}},"/patrol/cloud/pending":{"get":{"summary":"Drafted replies waiting for approval (review_before_reply mode) and posts found in discover mode","operationId":"cloudPatrolPending","description":"Each item has type \"reply\" (an AI-drafted reply, draft = reply text, expires 24h after drafting) or \"discovered\" (mode discover: a post found by keyword search with no AI; draft null, approve null, kept 7 days; after that a daily sweep moves it to status expired, so it no longer appears under status=pending). Every item carries permalink (the Threads URL of the post) and posted_at (ISO time the post was published); items saved before 2026-10-18 return null for both. The same fields are in the patrol.pending webhook / event payload (type, permalink, posted_at, draft). Paging (2026-10-18): items are ordered newest first (created_at, then id); a page has at most limit items (1-100, default 100). When more exist, next_cursor is set and has_more is true: pass cursor=<next_cursor> to get the next, older page; next_cursor is null on the last page. Without cursor and limit you get the newest 100, as before. A malformed cursor returns 400 invalid_cursor. Batch approve (1.19.0): every item has flags[] and needs_individual (true when flagged: political, self_harm, pii, promo or flagged; those are never batch-approved), and the response has daily_cap and left_today (how many more replies this account can send today, the most a batch sends for it). Batch with POST /patrol/cloud/pending/approve.","parameters":[{"name":"account_id","in":"query","required":true,"description":"Account","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"pending (default) | sent | rejected | expired","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"1-100 (default 100)","schema":{"type":"integer"}},{"name":"cursor","in":"query","required":false,"description":"next_cursor from the previous page (omit for the newest items)","schema":{"type":"string"}}],"responses":{"200":{"description":"Pending items","content":{"application/json":{"example":{"ok":true,"data":{"mode":"reply","review_before_reply":true,"count":2,"next_cursor":"MjAyNi0xMC0xOFQwOToxNTowMC4wMDBafGRpc2NfYWNjXzE3OQ","has_more":true,"items":[{"id":"p1","type":"reply","keyword":"漲粉","post_author":"someone","post":"...","permalink":"https://www.threads.com/@someone/post/ABC","posted_at":"2026-09-07T01:00:00.000Z","draft":"...","reply":"...","expires_at":"2026-09-08T03:00:00.000Z","approve":"POST /api/v1/patrol/cloud/pending/p1/approve"},{"id":"disc_acc_179","type":"discovered","keyword":"スレッズ 予約投稿","post_author":"someone_jp","post":"...","permalink":"https://www.threads.com/@someone_jp/post/DEF","posted_at":"2026-10-18T09:00:00.000Z","found_at":"2026-10-18T09:15:00.000Z","draft":null,"reply":null,"expires_at":"2026-10-25T09:15:00.000Z","approve":null}]}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/patrol/cloud/pending/{id}/approve":{"post":{"summary":"Approve a drafted reply and send it now (optionally with an edited reply)","operationId":"approvePendingReply","description":"Items of type \"discovered\" have no draft and are never posted: approving one returns 409 discovered_item, and while the account is in mode discover nothing can be sent (409 discover_mode). Edited text goes through the same quality gates as generated replies (hashtags stripped, trimmed at a sentence boundary, six auto-reply checks). Sending consumes 1 haixun point and the global fuse, exactly like an automatic reply.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reply":{"type":"string","description":"Optional replacement text"}}}}}},"responses":{"200":{"description":"Sent","content":{"application/json":{"example":{"ok":true,"data":{"id":"p1","status":"sent","reply_id":"1809...","edited":false}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"422":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"429":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"502":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"patrol:reply_send"}},"/patrol/cloud/pending/{id}/reject":{"post":{"summary":"Reject a drafted reply (never sent; the post is not proposed again)","operationId":"rejectPendingReply","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","description":"Optional note, ≤200 chars"}}}}}},"responses":{"200":{"description":"Rejected","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write"}},"/patrol/browser/stats":{"get":{"summary":"Views and likes earned by browser-patrol replies (1-30 days), per connected account","operationId":"browserPatrolStats","description":"Browser patrol has no reply ids, so replies are matched back to Threads by the logged-in account plus text; only matched replies count and matched/logged is the match rate. Accounts the browser is logged into but which are not connected to MindThread come back with unmeasurable_reason instead of zeros. Refreshed every 6 hours; data from 2026-09-03.","parameters":[{"name":"days","in":"query","required":false,"description":"1-30 (default 7)","schema":{"type":"integer"}}],"responses":{"200":{"description":"Stats","content":{"application/json":{"example":{"ok":true,"data":{"days":7,"total":{"logged":30,"matched":29,"measured":29,"views":41280,"likes":52,"avg_views_per_reply":1423},"accounts":[]}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/analytics/insights":{"get":{"summary":"Account-level insights (views, likes, replies, followers)","operationId":"analyticsInsights","description":"Mind the scopes, they differ inside one payload: `total_posts` and `breakdown` cover the requested period, while `total_views`, `total_interactions` and `breakdown.total_followers` are account lifetime totals. `views_scope` and `posts_scope` say so explicitly. Dividing lifetime views by period posts gives a number that means nothing.","parameters":[{"name":"account_id","in":"query","required":true,"description":"Account id from GET /accounts. Required. Pass the literal \"all\" only when you intentionally want the organization-wide aggregate (response then has scope: organization and accounts_included). Omitting it returns 400 missing_account_id.","schema":{"type":"string"}},{"name":"period","in":"query","required":false,"description":"e.g. 7d, 30d (default 30d)","schema":{"type":"string"}}],"responses":{"200":{"description":"Insights","content":{"application/json":{"example":{"ok":true,"data":{"account_id":"utOWPxV1FLEeLK36xygM","scope":"account","period":"30d","total_posts":62,"total_views":864,"total_interactions":41,"avg_engagement_rate":0.0474,"views_scope":"account_lifetime","posts_scope":"last_30d","best_formula":"curiosity_hook","best_time_slots":["12:00","16:00"],"optimization_suggestions":["..."],"breakdown":{"published":62,"failed":1,"scheduled":13,"total_followers":139,"total_likes":33,"total_replies":8}}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/broadcasts":{"get":{"summary":"List your 20 most recent broadcasts","operationId":"listBroadcasts","responses":{"200":{"description":"Broadcasts","content":{"application/json":{"example":{"ok":true,"data":{"broadcasts":[{"id":"bc1","status":"pending","created_at":"2026-10-03T01:00:00.000Z","decide_after":"2026-10-03T01:47:00.000Z","finished_at":null,"window_min":45,"account_count":3,"member_count":3,"content_preview":"...","result":{"reason":null,"winner_post_id":null,"winner_username":null,"winner_views_at_window":null,"deleted":0,"delete_failed":0}}]}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"},"post":{"summary":"Broadcast the same plain text to 2-20 of your Threads accounts; with keep_best, keep only the most-viewed post after 45 minutes and delete the rest (Business plan)","operationId":"createBroadcast","description":"Check GET /me data.features.broadcast.available first. Send account_ids (2-20 ids from GET /accounts) or preset_id (a saved group from GET /broadcast-presets), not both. text is plain text, 1-500 characters (no media, no thread splitting). keep_best defaults to true: about 45-50 minutes after the LAST post goes out, MindThread compares views and deletes every post except the winner from Threads (cannot be undone); the owner gets a notification. keep_best:false just posts to every account. All-or-nothing checks before anything is posted: every account must be yours, a Threads account, connected, and pass its own content_rules (enforce=block → 422 content_rules_violated). Posts go out one account at a time (about 3-10 seconds each); if the request runs out of time the remaining accounts come back status:skipped with error.code time_budget. Always send idempotency_key: a retry with the same key returns the first result (409 broadcast_in_progress while it is still running; 409 broadcast_result_unknown means do not resend, read GET /broadcasts and ask the human). Only a key created by the account owner can broadcast (403 owner_key_required). One broadcast per member at a time (409 broadcast_busy, retry after 60 seconds) and at most 50 broadcasts per day through the API (429 broadcast_daily_limit). If this key needs the owner's confirmation (approval_required), send account_ids, not preset_id.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"account_ids":{"type":"array","description":"2-20 of your account ids","items":{"type":"string"}},"preset_id":{"type":"string","description":"A saved group id from GET /broadcast-presets (instead of account_ids)"},"text":{"type":"string","description":"Plain text, 1-500 characters"},"keep_best":{"type":"boolean","description":"Default true: keep only the most-viewed post after the window, delete the others"},"topic_tag":{"type":"string","description":"Optional Threads topic tag (plain words, max 50 characters)"},"idempotency_key":{"type":"string","description":"Strongly recommended: a unique string per broadcast"}},"required":["text"]}}}},"responses":{"200":{"description":"Broadcast result per account","content":{"application/json":{"example":{"ok":true,"data":{"broadcast":{"id":"bc1","keep_best":true,"window_min":45,"decide_after":"2026-10-03T01:47:00.000Z","accounts":[{"account_id":"a1","username":"shop_a","status":"published","post_id":"p1","threads_post_id":"1789","in_comparison":true,"topic_tag":null},{"account_id":"a2","username":"shop_b","status":"failed","post_id":"p2","threads_post_id":null,"in_comparison":false,"error":{"code":"publish_failed","message":"..."}}],"published":1,"failed":1,"skipped":0,"duplicates_removed":0,"rule_violations":[],"status_url":"/api/v1/broadcasts/bc1","cancel":"POST /api/v1/broadcasts/bc1/cancel"}}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"422":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"429":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"503":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:publish_now"}},"/broadcasts/{id}":{"get":{"summary":"One broadcast: members, view snapshots, winner, deletions, anything you must delete by hand","operationId":"getBroadcast","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Broadcast","content":{"application/json":{}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"read"}},"/broadcasts/{id}/cancel":{"post":{"summary":"Cancel the comparison: every post of this broadcast stays on Threads","operationId":"cancelBroadcast","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Cancelled","content":{"application/json":{"example":{"ok":true,"data":{"broadcast":{"id":"bc1","status":"skipped","cancelled":true}}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"content:write"}},"/broadcast-presets":{"get":{"summary":"Saved account groups from the web app (use id as preset_id)","operationId":"listBroadcastPresets","responses":{"200":{"description":"Presets","content":{"application/json":{"example":{"ok":true,"data":{"presets":[{"id":"g1abc","name":"Food","account_ids":["a1","a2"]}]}}}}},"401":{"description":"key_disabled (this key was disabled: stop, do not retry) or unauthorized (missing or wrong key)","content":{"application/json":{"examples":{"key_disabled":{"value":{"error":{"code":"key_disabled","message":"This API key has been disabled","key_id":"K9f2abc","disabled_at":"2026-09-24T05:00:00.000Z","request_id":"req_mf1x2y3z4abcd"}}},"unauthorized":{"value":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/experiments":{"get":{"summary":"List A/B experiments","operationId":"listExperiments","responses":{"200":{"description":"Experiments","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"},"post":{"summary":"Create an A/B experiment across formulas","operationId":"createExperiment","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"topic":{"type":"string","description":"Topic"},"formulas":{"type":"array","description":"Formula ids","items":{"type":"string"}},"account_id":{"type":"string","description":"Account"}},"required":["topic","account_id"]}}}},"responses":{"200":{"description":"Experiment","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}}},"x-scope":"content:publish_now"}},"/webhooks":{"get":{"summary":"List webhooks (mt_test_ keys see the live list read-only, marked data_source: live_readonly)","operationId":"listWebhooks","responses":{"200":{"description":"Webhooks","content":{"application/json":{"example":{"ok":true,"data":{"webhooks":[{"id":"wh1","url":"https://example.com/hook","events":["post.published"],"active":true,"fail_count":0,"created_at":"2026-09-06T03:00:00.000Z"}]}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"},"post":{"summary":"Register an HTTPS webhook (events: post.published, post.failed, reply.sent, patrol.reply, patrol.pending, token.expiring, usage.threshold, approval.decided)","operationId":"createWebhook","description":"The event list here is generated from the same constant the server validates against. Unknown names return 400 invalid_events with `invalid[]` and `valid_events[]`. Each delivery is a POST whose body is { id, event, timestamp, data }: id (1.9.0) is the id GET /events gives the same event and stays the same when a delivery is retried, so dedupe by id.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","description":"https endpoint"},"events":{"type":"array","description":"Event names","items":{"type":"string","enum":["post.published","post.failed","reply.sent","patrol.reply","patrol.pending","token.expiring","usage.threshold","approval.decided"]}},"secret":{"type":"string","description":"Optional HMAC-SHA256 secret (signature in X-MindThread-Signature)"}},"required":["url","events"]}}}},"responses":{"201":{"description":"Webhook","content":{"application/json":{"example":{"ok":true,"data":{"id":"wh1","url":"https://example.com/hook","events":["patrol.pending"],"active":true}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}}},"x-scope":"webhooks:write"}},"/webhooks/{id}":{"delete":{"summary":"Delete a webhook","operationId":"deleteWebhook","description":"mt_test_ keys may delete only their own mock ids (test_wh_*); a live id returns 403 test_mode_forbidden_live_mutation.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"example":{"ok":true,"data":{"id":"wh1","deleted":true}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"webhooks:write"}},"/accounts/connect-link":{"post":{"summary":"Get a Threads OAuth link that connects a new account to this member (hand it to the human to click)","operationId":"connectLink","description":"Lets an agent onboard from zero: no web session needed. The link is HMAC-signed, valid 45 minutes, and the connected account shows up in GET /accounts. A mt_test_ key gets a mock link (mock:true, persisted:false) that connects nothing.","responses":{"200":{"description":"Link","content":{"application/json":{"example":{"ok":true,"data":{"oauth_url":"https://www.threads.net/oauth/authorize?...","expires_in_minutes":45}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}}},"x-scope":"accounts:connect"}},"/patrol/browser":{"get":{"summary":"Browser patrol (extension) profiles and every machine's status: heartbeat, extension version, logged-in Threads account, running","operationId":"listBrowserPatrol","description":"Browser patrol runs in the user's own Chrome through the MindThread extension, outside the official API. It is a disclosed platform-ToS grey area; the account risk sits with the user. The API only reads status and sends remote commands; content is generated per post server-side.","responses":{"200":{"description":"Profiles","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/patrol/browser/{profile_id}":{"get":{"summary":"One browser patrol profile with its machines and recent command results","operationId":"getBrowserPatrol","parameters":[{"name":"profile_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Profile","content":{"application/json":{}}},"403":{"description":"insufficient_scope (permission is deny), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}}},"x-scope":"read"}},"/patrol/browser/{profile_id}/commands":{"post":{"summary":"Send a remote command to one machine (cid): start, stop, reload, resync, clearDedup, clearBreaker, setAnchor, diag","operationId":"browserPatrolCommand","description":"Picked up on the machine's next heartbeat (about 1-2 minutes; the Threads tab must be open, background is fine) and expires after 10 minutes. Only machines seen within 10 minutes and running extension 0.19.3+ accept commands (409 machine_offline / extension_outdated otherwise): pick a machine with online:true and supports_remote_commands:true from GET /patrol/browser. Poll GET /patrol/browser/{profile_id} → recent_commands for done / ok / result.","parameters":[{"name":"profile_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"cid":{"type":"string","description":"Machine id from GET /patrol/browser"},"type":{"type":"string","description":"start | stop | reload | resync | clearDedup | clearBreaker | setAnchor | diag"},"url":{"type":"string","description":"For setAnchor: site-relative search page, e.g. /search?q=keyword&filter=recent"}},"required":["cid","type"]}}}},"responses":{"200":{"description":"Queued","content":{"application/json":{"example":{"ok":true,"data":{"id":"cmd","status":"queued"}}}}},"400":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"404":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}},"409":{"description":"Error","content":{"application/json":{"example":{"error":{"code":"forbidden","message":"Account does not belong to you","request_id":"req_mf1x2y3z4abcd"}}}}}},"x-scope":"patrol:browser_command"}},"/accounts/settings":{"get":{"summary":"All connected Threads accounts with their bulk settings and status chips","operationId":"listAccountSettings","description":"Same data as the web app's bulk settings sheet. data.columns describes every column (type, options, min/max, sensitive). Sorted by username; limit 1-100 (default 100) and cursor (data.next_cursor) for more.","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"cursor","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Accounts","content":{"application/json":{"example":{"ok":true,"data":{"accounts":[{"account_id":"a1","username":"shop_a","needs_reauth":false,"settings":{"mode":"autopilot","autoPost":"on","reviewBeforePublish":false,"scheduleTimes":"10:30,19:30","maxRepliesPerPost":3},"status":[]}],"total":1,"next_cursor":null,"columns":[{"key":"mode","label":"運作模式","type":"enum","sensitive":true,"options":["autopilot","reply-only","patrol-only","paused"]}],"sensitive_columns":["mode","autoPost","reviewBeforePublish"],"video_open":true,"rules_url":"https://mindthread.tw/accounts/bulk/rules","max_accounts_per_request":100,"revert_window_hours":24}}}}},"400":{"description":"Error","content":{"application/json":{"examples":{"invalid_limit":{"value":{"error":{"code":"invalid_limit","message":"limit must be an integer from 1 to 100","request_id":"req_mf1x2y3z4abcd"}}},"invalid_cursor":{"value":{"error":{"code":"invalid_cursor","message":"cursor must be the next_cursor value from a previous page","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/accounts/settings/export.csv":{"get":{"summary":"Download the settings as CSV (same file as the web app download)","operationId":"exportAccountSettingsCsv","description":"UTF-8 with BOM, CRLF. The first line is a # link to the rules page and is skipped on upload. Cells starting with = + - @ are prefixed with an apostrophe (CSV injection guard).","responses":{"200":{"description":"CSV","content":{"text/csv":{"schema":{"type":"string"}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/accounts/settings/preview":{"post":{"summary":"Preview a batch of settings changes (writes nothing)","operationId":"previewAccountSettings","description":"Send exactly one of changes or csv. Rows that are not yours, unknown columns, out-of-range values and cells changed since base come back as row errors. apply_changes (with base) and preview_id can be sent to apply as they are; preview_id is valid for 15 minutes and is required on apply from Claude and ChatGPT directory connections.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"changes":{"type":"array","maxItems":100,"items":{"type":"object","required":["account_id","set"],"properties":{"account_id":{"type":"string","description":"An account id from GET /accounts/settings"},"set":{"type":"object","description":"column key → new value. Keys and allowed values: data.columns of GET /accounts/settings, or https://mindthread.tw/accounts/bulk/rules. Values may also be the text the web sheet shows (開／關, 全自動, 09:30,21:00).","additionalProperties":true},"base":{"type":"object","description":"column key → the value you read. A cell changed since then is refused for that account (row error) instead of overwritten. preview returns apply_changes with base filled in.","additionalProperties":true}}},"description":"Up to 100 accounts, one entry per account"},"csv":{"type":"string","description":"Instead of changes: the CSV text in the web download format (first column 帳號, then 帳號編號 and the column labels; empty cells are left alone; UTF-8; up to 1 MB). Counts toward the 30 uploads a day shared with the web app."}}},"examples":{"changes":{"value":{"changes":[{"account_id":"a1","set":{"scheduleTimes":"09:30,21:00","maxRepliesPerPost":5}}]}},"csv":{"value":{"csv":"帳號,帳號編號,每篇回覆上限\r\nshop_a,a1,5\r\n"}}}}}},"responses":{"200":{"description":"Per-cell preview","content":{"application/json":{"example":{"ok":true,"data":{"rows":[{"account_id":"a1","username":"shop_a","changes":[{"column":"scheduleTimes","label":"發文時段","from":"10:30,19:30","to":"09:30,21:00","from_text":"10:30,19:30","to_text":"09:30,21:00","sensitive":false}],"warnings":[]}],"sensitive":false,"changed_accounts":1,"error_rows":0,"apply_changes":[{"account_id":"a1","set":{"scheduleTimes":"09:30,21:00"},"base":{"scheduleTimes":"10:30,19:30"}}],"row_errors":[],"notices":[],"rows_read":null,"preview_id":"bp1.mg8x1k2a.AbCdEfGhIjKlMnOpQrStUvWxYz012345","preview_expires_at":"2026-10-11T05:15:00.000Z","confirm_sensitive_required":false}}}}},"400":{"description":"Error","content":{"application/json":{"examples":{"invalid_input":{"value":{"error":{"code":"invalid_input","message":"Send exactly one of changes (array), csv (UTF-8 text) or a multipart CSV upload to /accounts/settings/import","request_id":"req_mf1x2y3z4abcd"}}},"column_not_available":{"value":{"error":{"code":"column_not_available","message":"videoAutopilot cannot be changed through this connection; change it on the MindThread website","columns":["videoAutopilot"],"account_ids":["a1"],"request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"429":{"description":"Error","content":{"application/json":{"examples":{"daily_limit":{"value":{"error":{"code":"daily_limit","message":"今天上傳已經 30 次了，明天再試，或直接在總表上改","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"read"}},"/accounts/settings/import":{"post":{"summary":"Upload a CSV and preview it (multipart/form-data, field file)","operationId":"importAccountSettingsCsv","description":"Same parser and limits as the web upload: UTF-8 only (Big5, UTF-16 and xlsx are refused with a hint), 1 MB, 30 uploads a day per member, rows matched by 帳號編號, empty cells are left alone, a bad cell skips its whole row. Also accepts text/csv or application/octet-stream (the body is the file) and application/json { csv }. Answers like preview, plus row_errors (line, account_id, reasons), notices and rows_read; nothing is written.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"}},"required":["file"]}},"text/csv":{"schema":{"type":"string"}}}},"responses":{"200":{"description":"Preview of the uploaded file","content":{"application/json":{"example":{"ok":true,"data":{"rows":[{"account_id":"a1","username":"shop_a","changes":[{"column":"scheduleTimes","label":"發文時段","from":"10:30,19:30","to":"09:30,21:00","from_text":"10:30,19:30","to_text":"09:30,21:00","sensitive":false}],"warnings":[]}],"sensitive":false,"changed_accounts":1,"error_rows":0,"apply_changes":[{"account_id":"a1","set":{"scheduleTimes":"09:30,21:00"},"base":{"scheduleTimes":"10:30,19:30"}}],"row_errors":[{"line":4,"account_id":"a9","username":"shop_x","reasons":["找不到這個帳號編號，或不是你的帳號"]}],"notices":[],"rows_read":2,"preview_id":"bp1.mg8x1k2a.AbCdEfGhIjKlMnOpQrStUvWxYz012345"}}}}},"400":{"description":"Error","content":{"application/json":{"examples":{"invalid_csv":{"value":{"error":{"code":"invalid_csv","message":"這個檔案不是 UTF-8 編碼：請在 Excel 選「另存新檔」→「CSV UTF-8（逗號分隔）」再上傳","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"413":{"description":"Error","content":{"application/json":{"examples":{"csv_too_large":{"value":{"error":{"code":"csv_too_large","message":"The upload is over 1 MB","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"read"}},"/accounts/settings/apply":{"post":{"summary":"Apply a batch of settings changes (idempotent, revertible for 24 hours)","operationId":"applyAccountSettings","description":"Send an Idempotency-Key header (8-200 characters of letters, digits, _ . : -). Send exactly one of changes or csv. Each account is written in its own transaction and the response lists every row; batch_id goes to GET /accounts/settings/batches/{batch_id} and to revert. Changes to mode, autoPost or reviewBeforePublish need confirm_sensitive:true, which also switches the permission to accounts:guardrails (with that permission set to ask, the owner confirms first). preview_id from preview is checked when sent and required from directory connections. mt_test_ keys validate only (persisted:false, batch_id null).","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":200}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"changes":{"type":"array","maxItems":100,"items":{"type":"object","required":["account_id","set"],"properties":{"account_id":{"type":"string","description":"An account id from GET /accounts/settings"},"set":{"type":"object","description":"column key → new value. Keys and allowed values: data.columns of GET /accounts/settings, or https://mindthread.tw/accounts/bulk/rules. Values may also be the text the web sheet shows (開／關, 全自動, 09:30,21:00).","additionalProperties":true},"base":{"type":"object","description":"column key → the value you read. A cell changed since then is refused for that account (row error) instead of overwritten. preview returns apply_changes with base filled in.","additionalProperties":true}}},"description":"Up to 100 accounts, one entry per account"},"csv":{"type":"string","description":"Instead of changes: the CSV text in the web download format (first column 帳號, then 帳號編號 and the column labels; empty cells are left alone; UTF-8; up to 1 MB). Counts toward the 30 uploads a day shared with the web app."},"confirm_sensitive":{"type":"boolean","description":"true when the batch changes mode, autoPost or reviewBeforePublish"},"preview_id":{"type":"string","description":"From preview (15 minutes); required from Claude and ChatGPT directory connections"},"reason":{"type":"string","maxLength":200,"description":"Stored with the batch"},"idempotency_key":{"type":"string","description":"Instead of the Idempotency-Key header (MCP)"}}},"examples":{"schedule":{"summary":"Change posting times on two accounts","value":{"changes":[{"account_id":"a1","set":{"scheduleTimes":"09:30,21:00"},"base":{"scheduleTimes":"10:30,19:30"}},{"account_id":"a2","set":{"scheduleTimes":"09:30,21:00"}}],"preview_id":"bp1.mg8x1k2a.AbCdEfGhIjKlMnOpQrStUvWxYz012345","reason":"move to morning and night"}},"sensitive_confirm":{"summary":"Pause accounts (sensitive column): needs confirm_sensitive","value":{"changes":[{"account_id":"a1","set":{"mode":"paused"}}],"confirm_sensitive":true}}}}}},"responses":{"200":{"description":"Batch result. A retry with the same Idempotency-Key and body returns this same body with idempotent_replay:true and header Idempotent-Replayed: true; nothing is written twice.","content":{"application/json":{"examples":{"applied":{"value":{"ok":true,"data":{"batch_id":"Qx7rB2kLmN4pT8vW1yZa","persisted":true,"applied":2,"results":[{"account_id":"a1","username":"shop_a","ok":true,"changed":1},{"account_id":"a2","username":"shop_b","ok":false,"error":"發文時段在你載入之後被改過，請重新整理再改"}],"outcome":{"ok":1,"same":0,"failed":1},"row_errors":[],"resolved_batches":[],"revert_deadline":"2026-10-12T05:00:00.000Z"}}},"idempotent_retry":{"value":{"ok":true,"data":{"batch_id":"Qx7rB2kLmN4pT8vW1yZa","persisted":true,"applied":2,"results":[],"outcome":{"ok":1,"same":0,"failed":1},"idempotent_replay":true}}}}}}},"400":{"description":"Error","content":{"application/json":{"examples":{"idempotency_key_required":{"value":{"error":{"code":"idempotency_key_required","message":"apply needs an Idempotency-Key header (or idempotency_key in the body)","request_id":"req_mf1x2y3z4abcd"}}},"confirm_sensitive_required":{"value":{"error":{"code":"confirm_sensitive_required","message":"These changes affect posting right away (run mode, auto-posting or review before publish). Show them to the user, then send the same request with confirm_sensitive: true.","columns":["mode"],"request_id":"req_mf1x2y3z4abcd"}}},"preview_required":{"value":{"error":{"code":"preview_required","message":"preview_id is required for this connection","request_id":"req_mf1x2y3z4abcd"}}}}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask), or this endpoint’s own 403","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"},{"$ref":"#/components/schemas/ErrorEnvelope"}]}}}},"409":{"description":"Error","content":{"application/json":{"examples":{"idempotency_in_progress":{"value":{"error":{"code":"idempotency_in_progress","message":"A request with this Idempotency-Key is still being applied.","request_id":"req_mf1x2y3z4abcd"}}},"idempotency_result_unknown":{"value":{"error":{"code":"idempotency_result_unknown","message":"An earlier request with this Idempotency-Key stopped before it reported a result.","request_id":"req_mf1x2y3z4abcd"}}},"preview_mismatch":{"value":{"error":{"code":"preview_mismatch","message":"preview_id does not match these changes.","request_id":"req_mf1x2y3z4abcd"}}},"preview_expired":{"value":{"error":{"code":"preview_expired","message":"preview_id expired (15 minutes). Preview again.","request_id":"req_mf1x2y3z4abcd"}}}}}}},"422":{"description":"Error","content":{"application/json":{"examples":{"idempotency_key_reused":{"value":{"error":{"code":"idempotency_key_reused","message":"This Idempotency-Key was already used with a different request body.","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"content:write","x-scope-alt":{"scope":"accounts:guardrails","when":"confirm_sensitive is true (the batch changes run mode, auto-posting or review before publish) (1.16.0)"}}},"/accounts/settings/batches":{"get":{"summary":"Recent settings batches (web app, API and MCP)","operationId":"listAccountSettingsBatches","responses":{"200":{"description":"Batches","content":{"application/json":{"example":{"ok":true,"data":{"batches":[{"batch_id":"Qx7rB2kLmN4pT8vW1yZa","created_at":"2026-10-11T05:00:00.000Z","status":"applied","applied":2,"ok":1,"same":0,"failed":1,"can_revert":true,"reverted_at":null}],"attention_batch_id":"Qx7rB2kLmN4pT8vW1yZa"}}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}}},"x-scope":"read"}},"/accounts/settings/batches/{batch_id}":{"get":{"summary":"One batch with its per-row results","operationId":"getAccountSettingsBatch","parameters":[{"name":"batch_id","in":"path","required":true,"description":"batch_id from apply","schema":{"type":"string"}}],"responses":{"200":{"description":"Batch","content":{"application/json":{"example":{"ok":true,"data":{"batch_id":"Qx7rB2kLmN4pT8vW1yZa","created_at":"2026-10-11T05:00:00.000Z","status":"applied","source":"api","reason":"move to morning and night","requested":2,"applied":1,"ok":1,"same":0,"failed":1,"retry_of":null,"can_revert":true,"revert_deadline":"2026-10-12T05:00:00.000Z","reverted_at":null,"revert_skipped":[],"rows":[{"account_id":"a1","username":"shop_a","status":"ok","stage":"apply","changed":1},{"account_id":"a2","username":"shop_b","status":"fail","stage":"apply","reason":"發文時段在你載入之後被改過，請重新整理再改","set":{"scheduleTimes":"09:30,21:00"}}]}}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"404":{"description":"Error","content":{"application/json":{"examples":{"not_found":{"value":{"error":{"code":"not_found","message":"找不到這次批次設定","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"read"}},"/accounts/settings/batches/{batch_id}/revert":{"post":{"summary":"Undo a batch (24 hours; accounts changed again are skipped)","operationId":"revertAccountSettingsBatch","parameters":[{"name":"batch_id","in":"path","required":true,"description":"batch_id from apply","schema":{"type":"string"}}],"responses":{"200":{"description":"Reverted","content":{"application/json":{"example":{"ok":true,"data":{"batch_id":"Qx7rB2kLmN4pT8vW1yZa","reverted":1,"skipped":[{"account_id":"a3","username":"shop_c","reason":"批次之後又被改過（發文時段）"}]}}}}},"401":{"description":"key_disabled or unauthorized","content":{"application/json":{"example":{"error":{"code":"unauthorized","message":"Invalid API token","request_id":"req_mf1x2y3z4abcd"}}}}},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"404":{"description":"Error","content":{"application/json":{"examples":{"not_found":{"value":{"error":{"code":"not_found","message":"找不到這次批次設定","request_id":"req_mf1x2y3z4abcd"}}}}}}},"409":{"description":"Error","content":{"application/json":{"examples":{"conflict":{"value":{"error":{"code":"conflict","message":"這次批次設定已經復原過了","request_id":"req_mf1x2y3z4abcd"}}}}}}},"410":{"description":"Error","content":{"application/json":{"examples":{"revert_window_passed":{"value":{"error":{"code":"revert_window_passed","message":"已經超過 24 小時，不能一鍵復原","request_id":"req_mf1x2y3z4abcd"}}}}}}}},"x-scope":"content:write"}},"/formulas":{"get":{"summary":"List content formulas (public, no auth)","operationId":"listFormulas","security":[],"responses":{"200":{"description":"Formulas","content":{"application/json":{"example":{"ok":true,"data":{"formulas":[{"id":"curiosity_hook","description":"..."}]}}}}}},"x-scope":"public"}},"/openapi.json":{"get":{"summary":"This document","operationId":"openapi","security":[],"responses":{"200":{"description":"OpenAPI 3.1","content":{"application/json":{}}}},"x-scope":"public"}},"/experiments/{id}":{"get":{"summary":"One A/B experiment with its variants and, once measured, the winner","operationId":"getExperiment","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Experiment"},"403":{"description":"insufficient_scope (permission is deny)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"}]}}}},"404":{"description":"experiment_not_found"}},"x-scope":"read"}},"/experiments/{id}/cancel":{"post":{"summary":"Cancel an active experiment (published variants stay on Threads)","operationId":"cancelExperiment","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Cancelled"},"403":{"description":"insufficient_scope (permission is deny), approval_required (permission is ask)","headers":{"X-Required-Scope":{"$ref":"#/components/headers/X-Required-Scope"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/InsufficientScopeError"},{"$ref":"#/components/schemas/ApprovalRequiredError"}]}}}},"404":{"description":"experiment_not_found"}},"x-scope":"content:write"}}},"x-scopes":{"modes":{"allow":"runs directly","ask":"returns 403 approval_required and asks the owner (read cannot be ask)","deny":"returns 403 insufficient_scope; nobody is asked"},"defaults":"New live keys: standard. New test keys: open. Keys created by team members: standard or stricter. Legacy keys (created before permissions existed): allow everything.","editing":"The owner changes an existing key in place with PATCH /keys/{id} (web app session only; 1.8.1): a preset or single permissions. A legacy key starts from standard and stops being legacy. Widening needs a sign-in within 24 hours. Team members change only keys they created, to standard or stricter. Setting a permission to deny cancels that key's pending approvals for it, and such an approval can no longer be approved. insufficient_scope.fix points the owner there; no new key is needed.","publish_now":"content:publish_now covers publish_now, publish-thread, POST /experiments (variants publish at once) and any publish_at less than 30 minutes away (or in the past) on /content/publish, /content/schedule and /content/generate-and-schedule.","schedule":"content:schedule covers POST /library unless status is \"draft\" (queued items publish automatically), library approve / queue, PATCH /library/{id} to status queued or new text on a queued item, and cancelling a schedule.","not_supported":"POST /content/generate-and-schedule never waits for approval: when its permission is ask it answers 403 approval_not_supported. Generate with POST /content/generate, then publish the text with POST /content/publish.","guardrails":"PATCH /accounts/{id}/settings needs accounts:guardrails when it turns review_before_publish off, turns auto_reply_enabled / video_autopilot / enabled on, removes content_rules, moves enforce from block to warn, drops a banned phrase, clears facts, adds a fact the account did not have (or lets a new number through, such as a space inside a number), turns forbid_cta / forbid_hashtags / forbid_causal_claims / one_fact_per_post / judge_claims off, raises or removes max_chars, lowers or removes min_chars, or drops or raises a mention_limits entry. Tightening stays content:write. content_rules is replaced as a whole (on live keys too from 1.8.3). From 1.8.3 the owner sees every field the body touches as current and proposed value, and the approval fails with approval_base_changed if one of those fields changes before it runs. From 1.9.0 one comparison table decides this for every content_rules field (a difference that is not proven stricter counts as loosening), dry_run:true needs only read, and every change is a revision the owner can undo.","exempt":"GET /me, GET /keys/current/usage (own usage, 1.8.2), GET /approvals/{id} (own approvals) and POST /keys/current/disable are not subject to permissions.","scopes":[{"scope":"read","conservative":"allow","standard":"allow","open":"allow","grok":"read"},{"scope":"content:write","conservative":"allow","standard":"allow","open":"allow","grok":"generate, library (not approve), patrol (settings that do not enable)"},{"scope":"content:schedule","conservative":"ask","standard":"allow","open":"allow","grok":"schedule, library approve"},{"scope":"content:publish_now","conservative":"ask","standard":"ask","open":"allow","grok":"publish"},{"scope":"patrol:reply_send","conservative":"ask","standard":"ask","open":"allow","grok":"patrol (send a reply)"},{"scope":"patrol:cloud_enable","conservative":"ask","standard":"ask","open":"allow","grok":"patrol (enable)"},{"scope":"patrol:browser_command","conservative":"ask","standard":"ask","open":"allow","grok":"patrol (browser)"},{"scope":"accounts:connect","conservative":"ask","standard":"ask","open":"allow","grok":"admin (connect)"},{"scope":"accounts:guardrails","conservative":"ask","standard":"ask","open":"allow","grok":"admin (settings, content_rules)"},{"scope":"webhooks:write","conservative":"allow","standard":"allow","open":"allow","grok":"webhooks"}],"grok_acceptance":[{"item":"P2-1","verdict":"passes","grok":"Two keys show different ids","this_api":"GET /me data.key.id and the actor.key_id on write responses differ per key"},{"item":"P2-4","verdict":"passes","grok":"A key can disable itself","this_api":"POST /keys/current/disable, then 401 key_disabled on the next call"},{"item":"P2-3","verdict":"passes","grok":"Test keys do not trigger approval","this_api":"New test keys are open: nothing asks until the owner sets a permission to ask"},{"item":"P2-2","verdict":"passes","grok":"A denied permission is a hard refusal","this_api":"deny answers 403 insufficient_scope with X-Required-Scope"},{"item":"approval status code","verdict":"differs","grok":"409 or 202 approval_required","this_api":"403 approval_required","why":"Common HTTP clients and MCP pass 403 through without retrying, and every permission refusal shares one status"},{"item":"publish without permission","verdict":"differs","grok":"insufficient_scope","this_api":"A standard live key gets 403 approval_required; only publish_now=deny gives insufficient_scope","why":"Dangerous actions ask the owner instead of failing"},{"item":"approver","verdict":"differs","grok":"An approve scope and a governor API","this_api":"No approve scope, no governor API: only the signed-in owner approves at /approve/{id}; from 1.10.0 also from a one-time link sent to the owner's own channels","why":"in-channel approval keeps a human credential in the loop: owner channel link, session, passkey or an owner-registered attested client; never the API key"},{"item":"key admin","verdict":"differs","grok":"/keys/{id}/disable and /enable","this_api":"Not provided: a key disables only itself; other keys are managed in Settings; there is no re-enable","why":"A leaked key must not be able to switch other keys on or off"},{"item":"401 headers","verdict":"differs","grok":"X-RateLimit-* on every response","this_api":"A 401 carries no X-RateLimit-* headers","why":"No quota is checked before authentication succeeds"},{"item":"scopes shape","verdict":"differs","grok":"An array of scope names","this_api":"An object: permission name to allow | ask | deny","why":"Three states need a value per permission"},{"item":"/keys with an API key","verdict":"differs","grok":"404 or a key list","this_api":"401 session_required","why":"Key metadata for API callers is only on GET /me"},{"item":"P2-2b","verdict":"addressed","grok":"An existing key can change its permissions (the fix asked for a new key)","this_api":"1.8.1: the owner changes an existing key in place with PATCH /keys/{id} (web app session); insufficient_scope.fix points there"},{"item":"P2-4-E2E","verdict":"addressed","grok":"Prove end to end that disabling a key cancels its pending approvals","this_api":"1.8.1: POST /keys/current/disable answers cancelled_approvals and cancelled_approval_ids; each shows as cancelled (cancel_reason key_disabled_self) in approval.decided"},{"item":"P2-OBS","verdict":"addressed","grok":"r4 ticket P2-OBS: make events real instead of mock and add per-key usage (observability_audit was held at 4)","this_api":"1.8.2: GET /keys/current/usage (own key only: summary and recent calls with request_id, cursor paging); sandbox writes record real sandbox events that only that test key reads on GET /events; live keys and webhooks never see them"},{"item":"P2-4-E2E-LIVE","verdict":"addressed","grok":"r4 ticket P2-4-E2E-LIVE: with a disposable key, actually run disable, then cancelled_approvals and cancelled_approval_ids, then key_disabled (the contract shipped in 1.8.1)","this_api":"Run on production 2026-09-24 with a disposable test key: it created an ask approval, POST /keys/current/disable answered cancelled_approvals 1 with that approval id, and the next call got 401 key_disabled (agent-conformance-p2 --expect 1.8.1 --require-e2e). A second disposable test key was issued for the Grok suite to repeat it. Reading the cancellation from another key's event stream needs a live key, because from 1.8.2 a test key's approvals are sandbox events"},{"item":"P2-3b-A","verdict":"passes","grok":"Owner approves in-channel; key never sees the token","this_api":"One-time link to the owner's own channels (email, web push; LINE follows); decision_via: \"link\" on GET /approvals/{id} and approval.decided; the key view never carries the link"},{"item":"P2-5","verdict":"addressed","grok":"Shared policies per account: a desired and an active version, with policy.apply going through approvals","this_api":"1.9.0, minimal version: the guardrails on the account are the active policy (GET /accounts/{id}/settings data.guardrails with etag, last_change and pending), a pending settings approval is the desired change, and the owner confirming it applies it; every change is a revision (GET /accounts/{id}/guardrails/history) that the owner can undo (POST /accounts/{id}/guardrails/rollback, or the undo button on the web app page /accounts/{id}/guardrails)","why":"A separate policy object and proposal endpoints wait until more than one key really edits the same account; today the approval is the proposal"},{"item":"P2-OBS-FOLLOW","verdict":"addressed","grok":"P2-OBS-FOLLOW（可選）Events 跨 live／sandbox 操作手冊與 webhook 去重（post_id） (r5 ticket, in English: optional, an operating guide for events across live and sandbox, and webhook dedupe by post_id)","this_api":"1.9.0: live keys read live events and test keys only their own sandbox events; start the live cursor fresh after switching keys; webhooks are live only; every webhook body now carries id, the same id GET /events gives the event, so dedupe by id (post_id alone is not unique: one post can fail more than once); count equal to limit, or a types filter, can mean older events were skipped"},{"item":"P2-GOV-DOCS","verdict":"addressed","grok":"P2-GOV-DOCS 拋棄式 key 與 suite key 分帳／成員邊界說明（避免評測帳號錯位） (r5 ticket, in English: keep the disposable key and the suite key on separate books, and explain the member boundary, so evaluation accounts do not end up in the wrong place)","this_api":"1.9.0 docs: a key sees only its own member's accounts; create the suite key and the disposable key under the member being evaluated; each key has its own approvals and usage, so check a disposable key's results with that key; the suite key is never disabled, the disposable key is only for destructive checks"}]},"x-clients":[{"name":"mindthread-cli","version":"0.5.0","npm":"https://www.npmjs.com/package/mindthread-cli","repo":"https://github.com/ppcvote/mindthread-cli","docs":"https://github.com/ppcvote/mindthread-cli/blob/master/docs/agent-setup.md"},{"name":"mindthread-mcp","version":"0.2.1","npm":"https://www.npmjs.com/package/mindthread-mcp","repo":"https://github.com/ppcvote/mindthread-mcp"}],"x-changelog":{"1.22.0":"2026-11-04. Top posts and brand documents, so an agent can research, plan and schedule a Threads account in one conversation. GET /accounts/{id}/top-posts returns the best posts of an account this member connected, ranked by engagement (likes + replies + reposts + quotes) or by views, likes, replies, reposts or quotes, from MindThread's insights cache; other people's accounts cannot be read (the Threads API only returns the authorized user's own insights). GET /brand-docs, GET /brand-docs/{doc_id} and PUT /brand-docs/{doc_id} store brand, content and content-map documents (Markdown or plain text, up to 50,000 characters each, up to 50 documents, the last 20 versions kept, base_version guards against overwriting). MCP tools: get_top_posts, save_brand_doc, get_brand_doc (in both the full and the directory tool sets; full set 50 tools).","1.21.0":"2026-10-29. Random posting times in account settings. GET /accounts/{id}/settings now returns random_schedule, random_per_day, random_window and random_exclude, and PATCH accepts them (scope content:write, same as schedule_times). random_schedule=true ignores schedule_times and picks random_per_day times (1 to 30) each day inside random_window (\"HH:MM-HH:MM\" in the account time_zone, start before end; \"00:00-23:59\" is the whole day). New random_exclude: up to 3 ranges (\"17:00-18:00\", array or comma-separated string) that random times never fall into; each range must not cross midnight and ranges must not overlap (touching is fine); an empty array clears it. Times are drawn from the window minus the excluded ranges, so they always land outside them, the minimum 45-minute gap still holds, and accounts without random_exclude keep exactly the same daily times as before. Errors: 400 invalid_random_per_day, invalid_random_window, invalid_random_exclude (the message names the problem: too_many_ranges, invalid_range, overnight_range, empty_range, overlapping_ranges, covers_window). MCP update_account_settings takes the same four fields. Cloud patrol reply length limit (same day): PUT /patrol/cloud takes reply_max, the maximum characters per reply (a whole number from 20 to 200; null = back to the default), and GET returns reply_max (the limit in effect), reply_max_custom (what you set, or null) and reply_max_default (the default for the account language: 50 for Chinese without account material, 150 with material). When reply_max is set it wins over the default, a persona that asks for a length is followed up to that limit, and the same limit applies to fixed replies (rotate_replies) and the imported reply library; lowering it re-checks the existing rotate_replies and answers 400 if one is now too long. Error: 400 invalid_reply_max. MCP set_cloud_patrol takes reply_max.","1.20.0":"2026-10-29. Cloud patrol reply library. reply_mode now also takes \"consume\": each fixed reply is used once (it counts as used when it is posted or queued for review) and patrol stops replying for the account when all are used (last_scan_note library_exhausted; it never falls back to AI replies). Replies come from rotate_replies (up to 10) or an imported reply library of up to 2,000. New POST /patrol/cloud/library/import (content:write) takes replies (array of strings) and mode replace (default; restarts from the first reply and clears the usage log) or append; it trims, drops exact duplicates (within the import and against the library), replies over the account reply length limit and replies that fail content rules, the self-harm filter, the fact bank (managed accounts) or the reply quality checks, keeps the order, and returns the removed lines with reasons; dry_run: true only previews (test keys always preview). New GET /patrol/cloud/library/export returns the remaining replies (consume: unused ones; rotate: all). GET /patrol/cloud adds reply_library { source, total, used, remaining, cursor, next, exhausted } and replies_preview (the next N replies, ?preview=N, default 5, max 50). While a library exists, PUT /patrol/cloud rejects a non-empty rotate_replies with 400 library_in_use. MCP adds import_cloud_patrol_replies and export_cloud_patrol_replies (full tool set only; 47 tools).","1.19.0":"2026-10-27. Batch approve for cloud patrol drafts. New POST /patrol/cloud/pending/approve takes ids (1-50 pending ids) or account_id with all: true (that account's pending drafts, oldest first, up to 50; remaining tells how many were left for the next call). Per account a batch sends at most left_today (the daily cap minus replies already sent today, the same cap automatic replies use); the rest stay pending with reason daily_cap. Drafts flagged needs_individual are never batch-approved and stay pending for one-by-one approval: flags are political, self_harm, pii (phone, email, ID or card numbers in the post or draft), promo (links, guarantees, fake results or hard selling in the draft) and flagged (risk recorded when it was drafted). Each draft is sent through the same path as POST /patrol/cloud/pending/{id}/approve (points, fuses, dedup, logs, webhooks). Batch approve needs patrol:reply_send set to allow; with ask it returns 403 approval_not_supported and points to the single approve, which asks the owner for each draft with its full text. GET /patrol/cloud/pending now returns flags and needs_individual on every item, and daily_cap and left_today for the account. Approving the same draft from two requests at once now sends it once; the other request gets 409 in_progress. New MCP tool approve_pending_replies (not in the directory listing; 45 tools with an API key).","1.18.0":"2026-10-26. Changed since last viewed (warning code changed_since_last_viewed, never blocks). MindThread remembers, per library item and per scheduled post, the last version the account owner saw on the web (library, schedule list, compose edit of a scheduled post, /approve/{id}, the one-time link page) and the last version read through the API (GET /library, GET /schedules); writing content is not viewing. POST /library/{id}/approve, PATCH /library/{id} when the item ends up queued, and POST /library/bulk approve or queue return warnings[] when the content differs from that version (the owner's version is used when both exist, so an agent re-reading does not clear it). Approvals for library releases store it in preview.warnings and the owner sees a red and green sentence diff before deciding. GET /library (queued, draft) and GET /schedules (scheduled, pending, draft) attach the same warning. detail: viewed_at, viewed_by (member | api_key), removed[], added[] (up to 10 sentences each, 200 characters per sentence), removed_count, added_count, media_changed, time_changed, previous_text, current_text, library_id or post_id. Items with no viewing record (anything last seen before 1.18.0) get no warning. Each record keeps only the latest version per viewer and is deleted after 60 days without change. New web-only route POST /views (signed-in owner, not API keys) records what the web app displayed.","1.17.0":"2026-10-26. Warnings that never block. POST /content/publish, POST /content/schedule and POST /content/generate-and-schedule return data.warnings[] ({ code, message, message_zh, detail }), also on mt_test_ keys: off_hours when an explicit publish_at falls outside the account's usual posting hours in its audience time zone, stale_time_reference when the text says 昨天 / 上週 / 剛剛 / yesterday / last week and similar and will publish on a later day than it was written. GET /library items with status queued or draft carry warnings[] (stale_time_reference, measured from created_at to next_publish_at, or to now for drafts). Approvals for posts, schedules and library releases store the same list in preview.warnings, and the owner sees it on /approve/{id} and on the one-time link page; for publish_now approvals the page also checks the time between the request and the owner's decision. The web app compose page shows the same warnings when a time is picked. Publish-now requests have no warnings.","1.16.1":"2026-10-18. Cloud patrol discover mode: the description now matches what it does (each newly listed post uses 1 haixun point, never twice for the same post; daily_cap defaults to your plan's daily haixun points and can only be set lower). Turning discover on needs only content:write (no owner approval, since nothing can be posted); reply mode and switching back to reply still need patrol:cloud_enable. The site-wide reply fuse no longer stops discover. GET /patrol/cloud/pending takes limit (1-100) and cursor and returns next_cursor and has_more; without them you get the newest 100 as before.","1.16.0":"2026-10-11. Account settings in bulk: the same server code as the web app's bulk settings sheet (/accounts/bulk, its CSV upload and one-sentence edit) is now an API and MCP tools. GET /accounts/settings lists every connected Threads account with its bulk settings and status chips (limit up to 100, cursor). POST /accounts/settings/preview takes changes ([{ account_id, set, base? }]) or csv and returns per-cell old and new values, warnings and per-row errors, writes nothing, and returns apply_changes and a preview_id valid for 15 minutes. POST /accounts/settings/import takes a multipart CSV upload (field file, UTF-8, 1 MB) with the same parser as the web upload and answers like preview. POST /accounts/settings/apply needs an Idempotency-Key header (or idempotency_key in the body): the same key with the same body returns the first result (header Idempotent-Replayed: true, data.idempotent_replay), the same key with another body answers 422 idempotency_key_reused, a request still running answers 409 idempotency_in_progress and one that stopped before reporting answers 409 idempotency_result_unknown and is never rerun. Run mode, auto-posting and review before publish need confirm_sensitive:true (400 confirm_sensitive_required otherwise), and with confirm_sensitive:true the permission is accounts:guardrails instead of content:write. Each account is written in its own transaction; the response has a batch_id and a per-row result. GET /accounts/settings/batches, GET /accounts/settings/batches/{batch_id} (per-row results) and POST /accounts/settings/batches/{batch_id}/revert (24 hours, accounts changed again afterwards are skipped and listed). GET /accounts/settings/export.csv is the web app's download (UTF-8 with BOM). Connections from the Claude and ChatGPT directories need the preview_id on apply (preview_required, preview_mismatch, preview_expired) and cannot change videoAutopilot (column_not_available). Batches record source api or mcp. Per-key minute limits: listing and batches 30, preview 20, import, export, apply and revert 10. MCP tools list_account_settings, preview_account_settings, apply_account_settings, revert_account_settings_batch and get_account_settings_batch (44 tools; directory set 40). The rules page https://mindthread.tw/accounts/bulk/rules is the column reference. The per-route minute limit table (minuteCap) now applies to routes that use the daily quota as well.","1.15.0":"2026-10-04. MCP directory stage 3. Step-up: when an OAuth access token is refused a permission that signing in again can grant (any of scopes_supported), REST answers 403 insufficient_scope with WWW-Authenticate: Bearer error=\"insufficient_scope\", scope=\"<the permissions this token already has plus the missing one>\", error_description and resource_metadata. On POST /api/mcp the same case answers HTTP 403 with that header and a JSON-RPC error (code -32003, data.error insufficient_scope, data.required, data.scope); a ChatGPT connection gets an HTTP 200 tool result with isError:true and _meta[\"mcp/www_authenticate\"] instead. 401 challenges still carry no scope. API keys, patrol:cloud_enable and patrol:browser_command behave as before (a 200 tool result with isError). New GET /.well-known/openai-apps-challenge: the OpenAI domain verification token as plain text, 404 until it is configured. Docs fix: the 1.9.1 account availability note named MCP tools that never existed (publish_thread, generate_and_schedule); the MCP tool that publishes is publish.","1.14.0":"2026-10-04. OAuth 2.1 authorization server for MCP (stage 2). Discovery: GET /.well-known/oauth-authorization-server (RFC 8414) and a minimal /.well-known/openid-configuration; the protected resource metadata now points to a working authorization server. Endpoints: GET /api/v1/oauth/authorize (authorization code with PKCE S256 only; state required; resource must be https://mindthread.tw/api/mcp), POST /api/v1/oauth/token (form-encoded only; authorization_code and refresh_token; access tokens last 1 hour, refresh tokens 30 days and rotate on every use, reusing an old one revokes the whole chain), POST /api/v1/oauth/register (RFC 7591, public clients with token_endpoint_auth_method none; redirect URIs limited to supported AI assistant callbacks and loopback), POST /api/v1/oauth/revoke (RFC 7009). A client_id that is an https URL is read as a client metadata document. The owner approves on https://mindthread.tw/connect/authorize and picks a permission set; patrol:cloud_enable and patrol:browser_command are never granted to OAuth connections. An OAuth access token (mt_oat_) works wherever an API key works, limited to the scopes it was granted, and counts against the same daily quota as a key. OAuth connections do not count toward the 5-key limit and are listed under Settings, Connected AI assistants (GET/DELETE /api/v1/oauth/connections, web session only).","1.13.0":"2026-10-04. MCP for AI assistant directories, stage 1 (OAuth follows in a later release). POST /api/mcp: initialize, tools/list, ping and the tools get_playbook and list_formulas work without a key; any other tools/call without a valid key now answers HTTP 401 with WWW-Authenticate: Bearer resource_metadata=\"https://mindthread.tw/.well-known/oauth-protected-resource\" and a JSON-RPC error (code -32001, data.error unauthorized or key_disabled) instead of a 200 tool result with isError. On /api/mcp the key may also be sent as X-API-Key or X-Auth-Token. Every tool has title, annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) and securitySchemes. New tools bulk_archive_library, bulk_delete_library and bulk_queue_library split bulk_library by effect (39 tools with a key). A request without a key sees the directory set: 35 tools (no browser patrol tools, no bulk_library, update_account_settings without video_autopilot) and short instructions; ?toolset=full or ?toolset=directory picks one. A browser Origin outside the allowed list gets 403; MCP-Protocol-Version 2024-11-05, 2025-03-26, 2025-06-18 and 2025-11-25 are accepted, any other value gets 400. New GET /.well-known/oauth-protected-resource (RFC 9728).","1.12.0":"2026-10-03. Approval reminders and the daily digest. POST /approvals/{id}/remind (API key, only approvals this key created; exempt from permissions, per-minute limit, no daily quota) asks MindThread to remind the owner again by in-app bell, web push and email, all pointing to the web page /approve/{id} (no new one-time link). Limits: still pending with at least 10 minutes left, at least 30 minutes after the last notification, at most 3 reminders per approval; errors approval_not_pending and approval_expiring (409), remind_too_soon (429 with Retry-After) and remind_limit_reached (429). MindThread also reminds once automatically when an approval has waited 4 hours. Owners whose confirmation emails were skipped by the 10-minute email cooldown get one digest email at 8 pm Taipei time listing what still waits; approval_settings.email_digest (default true) turns it off, and Settings now has the switch. MCP tool count unchanged (36 tools).","1.11.0":"2026-10-03. Broadcasts (Business plan): POST /broadcasts publishes the same plain text to 2-20 of your own Threads accounts (account_ids, or preset_id from GET /broadcast-presets). With keep_best (default true) MindThread reads views about 45 minutes after the last post and keeps only the most-viewed one; the others are deleted from Threads. GET /broadcasts, GET /broadcasts/{id} (members, snapshots, winner, deletions), POST /broadcasts/{id}/cancel (keep every post). GET /me adds data.features.broadcast { available, reason, min_accounts, max_accounts, window_min, max_concurrent }. Permission: POST /broadcasts is content:publish_now; cancel is content:write; reads are read. Only a key created by the account owner can broadcast. idempotency_key makes a retried request return the first result instead of posting twice. MCP tool count unchanged (36 tools).","1.10.0":"2026-09-28. In-channel approval, Phase A. From 1.10.0 the owner can decide from the notification itself: a one-time link (https://mindthread.tw/a/{lid}, with the secret in the URL fragment, 10 minutes by default, single use, bound to the approval, the owner and the allowed decisions) is sent to the owner's verified channels (email and web push in 1.10.0; LINE follows) once the owner has turned approval links on in Settings. API keys never receive, see or need that link: keep handing human_url and human_message to the human as is, never ask the human to paste the link or any code to you, and never open it yourself. New read-only fields on Approval: tier (t1, t2 or t3), channels_notified (type and status per channel, never an address), decision_via (web, link, push, client_attested or null), decision_channel (email, line, web_push or null), decided_by ({ type: \"human\", role: \"owner\" } or null) and step_up ({ method: none | session | passkey | code } or null); settings approvals also carry guardrails_etag_at_request. approval.decided carries tier, decision_via, decision_channel, decided_by and step_up_method (the same method as a plain string). Approvals created before 1.10.0 carry null in these fields, except decided_by, which is derived from the decision and reads { type: \"human\", role: \"owner\" } whenever the owner decided; every decision made before 1.10.0 was made on the web. always (allow this permission from now on) is still decided only at /approve/{id}, signed in; a link can only allow once or deny. No behavior change for keys: approval_required stays HTTP 403 with the same shape, human_url still points to /approve/{id}, polling GET /approvals/{id} and approval.decided work as before; only the wording of human_message changes to name the channels the link reached. The link endpoints (POST /a/{lid}/view, /a/{lid}/decide, /a/{lid}/step-up/code, /a/{lid}/reissue and /a/{lid}/deny-all) and the owner settings endpoints (/notification-channels, /approval-settings and POST /approvals/{id}/links/revoke) are for humans: an API key gets 401 session_required on the settings endpoints, and the link endpoints ignore an API key entirely (a missing or wrong secret answers 404 approval_link_not_found, the same answer as an unknown link). MCP tool count unchanged (36 tools). Fixed 2026-09-29: approval ids are always apr_ plus 20 letters and digits (some earlier ids had 19); the link endpoints answer Cache-Control: no-store; a view of a link that is no longer active carries csrf null and sets no cookie, since nothing can be decided with it; an MCP tool called without a required argument that belongs in the path (for example get_approval without id) answers invalid_params instead of requesting a path with undefined in it; GuardrailRevision documents decision_via and step_up_method, and ChannelsNotifiedItem explains what sent means.","1.9.1":"2026-09-28. Publishing claims and unknown results, and account availability. From 1.9.1 the publisher marks a scheduled post or a queued library item as publishing right before it sends it to Threads, and records published, partial or failed when it is done. While an item is publishing it can no longer be changed: PATCH /library/{id} and POST /library/{id}/approve answer 409 publishing_in_progress, POST /library/bulk reports publishing_in_progress for that item on archive, approve and queue, and DELETE /schedules/{id} answers 409 publishing_in_progress. Read it again in a minute. PATCH /library/{id} writes in a transaction: when the item's status changes between the read and the write, nothing is written and it answers 409 status_changed (read the item again and retry), or 409 publishing_in_progress when the item became publishing. If a publishing run is cut off before it records the result, the item is moved to draft, usually 15 to 20 minutes later, and is never resent automatically, because it may already be on Threads. It then carries held_reason publish_result_unknown, ahead of any other held reason, and reclaimed: true (GET /library?status=draft, GET /schedules?status=draft), and the owner is notified in the web app. An API key cannot put such an item back in the queue: POST /library/{id}/approve and PATCH /library/{id} with status queued answer 409 publish_result_unknown, and POST /library/bulk reports publish_result_unknown for it on approve and queue. Archiving it first does not make it queueable. Ask the owner to check Threads: the owner re-queues it in the web app only if it was not posted, or deletes it. Behavior change: DELETE /schedules/{id} on a post that is being published used to answer 400 cannot_cancel and now answers 409 publishing_in_progress, and GET /schedules now reports a post whose publish result is unknown with held_reason publish_result_unknown and reclaimed: true instead of held_reason null. PATCH /library/{id}, POST /library/{id}/approve and POST /library/bulk can answer the new codes above. New error code 409 account_unavailable on POST /content/publish (publish_now), POST /content/publish-thread and POST /content/generate-and-schedule (publish_now): the account is blocked by the platform or its token is invalid or revoked, so nothing is published through it. token_error clears the moment the owner reconnects the account in the web app; blocked clears when the platform block clears (re-checked every 6 hours). Scheduling with publish_at is still accepted, but the scheduled post fails at publish time if the account is still unavailable. The MCP tool publish returns the same code as a tool result with isError:true.","1.9.0":"2026-09-25. Shared policy, minimal version (P2-5), and Grok r5 P2-OBS-FOLLOW and P2-GOV-DOCS. Shared policy, minimal version: the guardrails on the account are the active policy for every key and automation on it; a pending settings approval is the desired (proposed) change; the owner confirming it applies it. There is no separate policy object or proposal endpoint yet. From 1.9.0, GET /accounts/{id}/settings returns data.guardrails: etag (an opaque version of the five guardrails: content_rules, review_before_publish, auto_reply_enabled, video_autopilot, enabled), covers, last_change, pending, enforced_on and not_enforced_on. PATCH /accounts/{id}/settings accepts an optional if_match with that etag. It is compared only on the guardrails the body sends, content_rules as one part and each of the four switches on its own, so a change to another part does not refuse the request. If a sent part changed since you read it, the answer is 412 guardrails_changed with current_etag, changed, current (the five current values) and last_change, and nothing is written: read again, apply your change to the current content_rules (it is replaced as a whole) and resend. Without if_match the last writer wins, as before, and every change is recorded. dry_run:true only previews: it needs the read permission, creates no approval and writes nothing, and each key can dry-run at most 10 times a minute (429 rate_limit_exceeded). It answers changed, loosened, tightened, required_scope, your_mode, outcome (apply, approval_required or denied), etag_now and impact: how many of the first 200 queued library items, in publishing order, the new content_rules would newly flag, checked with the fixed rules only (no judge_claims, no scheduled posts). Every change to a guardrail made through the API, by an approval or by the system writes a revision that is never edited or deleted: GET /accounts/{id}/guardrails/history (read permission, newest first, limit up to 50, before=next_before for the next page) lists id, at, source (api, approval, rollback or system), actor, mine, changed_fields, loosened, tightened, gap_before, before, after and restore_body; approval_id, request_id and reason only on revisions your own key made. PATCH accepts reason (up to 200 characters, plain text, links removed) to explain a change. gap_before:true means the guardrails changed outside the record since the previous revision (in the web app, or before 1.9.0); those changes are not recorded by name yet. A system revision (actor type system) records the server pausing an account (its authorization failed, it is blocked or publishing keeps failing) or turning it back on after a reconnect or token refresh, with system_reason; it cannot be undone. Test keys read live revisions and write none. The owner can undo one revision: POST /accounts/{id}/guardrails/rollback { revision_id, if_match } (web app session only, x-audience human; an API key gets 401 session_required, a team member 403 owner_only; in the web app the owner presses the undo button in the change history on the page /accounts/{id}/guardrails). It restores the fields that revision changed to their previous values, only while they still hold the values that revision wrote; otherwise it answers 409 rollback_conflict with later_revision_id (the later revision that changed them) or changed_outside_record:true, and nothing changes. If those fields already hold their previous values, it answers 200 with already_rolled_back:true and writes nothing. An undo is recorded as a revision with source rollback. An undo that loosens a guardrail needs a sign-in within 24 hours (401 reauth_required). To undo through the API instead, send restore_body with if_match as a normal PATCH: loosening still needs the owner. Loosening is now decided field by field from one comparison table that every content_rules field must be declared in: a difference that is not proven stricter counts as loosening, and a change that loosens one rule and tightens another counts as loosening. The first facts list on an account that had none is not loosening, because numbers were not checked before; the revision records it as facts_created. The same comparison decides the permission, the approval preview, and loosened and tightened in revisions and dry runs. Writes are transactional: a settings approval that runs after the owner confirmed checks its recorded values again in the same transaction as the write, and a request that became loosening after the permission check (the guardrails changed in between) answers 412 guardrails_changed instead of writing. 422 content_rules_violated now carries guardrails_etag, the version of the rules that refused the text; a scheduled API post held at publish time carries held_guardrails_etag next to held_reason (GET /schedules) and guardrails_etag in post.failed, and a queued library item held at publish time carries held_guardrails_etag next to held_reason (GET /library). When a guardrail is loosened without the owner pressing allow (the key has accounts:guardrails on allow, or it is a legacy key), the owner gets an in-app notification (no email); more loosening by the same key on the same account within the same 30 minutes updates that notification instead of adding another. content_rules can only be changed through PATCH /accounts/{id}/settings: the web app's direct database writes can no longer change it (the web app never wrote it), and an account that has had content_rules cannot be deleted and created again under the same id from the web app, so every change is recorded. Event stream across live and sandbox: a mt_live_ key reads the member's live events on GET /events and never sandbox ones; a mt_test_ key reads only its own sandbox events. Build against a test key, then switch keys and start the live cursor fresh (omit since, or use the time you switched): a latest_at from one stream means nothing in the other, and the two are never merged. Webhooks carry live events only. From 1.9.0 every webhook body is { id, event, timestamp, data }, and id is the id GET /events gives the same event. A webhook delivery can repeat, so dedupe by id, on webhooks and on GET /events alike. post_id says which post an event is about, but one post can fail more than once, so do not dedupe by post_id alone. GET /events returns the newest events after since, up to limit (at most 200): when count equals limit, or when you filter by types, older events after since may have been skipped, so poll more often or with a larger limit. Key boundaries: a key only sees and acts on the Threads accounts of the member it belongs to (another member's account answers 403 forbidden). A key a team member creates in the owner's workspace belongs to the owner's member. For a third-party evaluation, create both the suite key and the disposable key under the same member as the accounts being evaluated, otherwise GET /accounts is empty and every account id is refused. The suite key is the long-lived key the evaluation runs everything with and is never disabled; a disposable key exists only for destructive checks such as POST /keys/current/disable and is thrown away afterwards. Each key reads only its own approvals and usage, so check a disposable key's results with that key before disabling it. For every value the API accepts, the comparison table gives the same loosening answer as 1.8.3, except that a phrase listed twice in mention_limits is now judged by its stricter entry, as enforcement does. New error codes: 412 guardrails_changed, 409 rollback_conflict, 404 revision_not_found, 400 invalid_if_match, invalid_reason and invalid_dry_run.","1.8.3":"2026-09-25. Fixes the three defects found while designing shared policies (P2-5). From 1.8.3, content_rules are checked on every API path that writes or schedules text: POST /content/generate, /content/publish, /content/schedule, /content/generate-and-schedule, /content/publish-thread, /content/generate-thread, /experiments, POST /library and PATCH /library/{id}. With enforce:block a violation answers 422 content_rules_violated and nothing is written, scheduled or published; with enforce:warn (the default) the request succeeds and carries rule_violations (/experiments does not report them). Every path checks the fixed rules (max_chars, min_chars, forbid_cta, forbid_hashtags, banned_phrases, facts, forbid_causal_claims, one_fact_per_post, mention_limits). The model review (judge_claims) and the recently used numbers check (repeated_fact) run only on POST /content/generate, POST /library and PATCH /library/{id}; every other path, including the check right before a scheduled post publishes, runs the fixed rules only. Matching ignores invisible format characters such as zero-width spaces, compares banned_phrases and mention_limits after Unicode NFKC and case folding, and skips a number written next to - : / only when it is part of a date, time or range such as 2026-09-25, 12:30 or 5-10 (so 100000/month now counts). A topic_tag is checked against banned_phrases too; forbid_hashtags covers #hashtags in the text, and on an account with it on, posts from the API and the library go out without a Threads topic tag (topic_tag comes back null). Stored banned phrases are normalized the same way and capped at 100 characters, and invisible characters are removed from facts. error.violations is RuleViolation[] ({ rule, detail }) for one text (/content/publish, /content/schedule, /content/generate-and-schedule, PATCH /library/{id}); one RuleViolation[] per post for /content/generate; [{ index, rule_violations }] for /library and /content/publish-thread (index counts from 0 in the request array) and for /content/generate-thread (index is the thread_parts[].index of the answer, from 1); [{ formula, rule_violations }] for /experiments. Test keys get the same 422: /content/schedule and /content/publish-thread check the submitted text, and the two generating paths check their mock text, which contains the topic, so a banned phrase in the topic rehearses the refusal. The mock text is checked only against banned_phrases, forbid_cta and forbid_hashtags, because length and number rules need real text: a test key can still rehearse a successful call, and an ask permission on /content/generate-thread still creates its approval. /content/generate-and-schedule and /content/generate-thread now put the rules in the prompt and regenerate a violating draft (up to 3 model calls with enforce:block, 2 with warn), like /content/generate; model_calls says how many were made. Posts scheduled through the API are checked again right before they publish, against the rules in force at that moment: with enforce:block a violating post is not published but moved to draft with held_reason and rule_violations (GET /schedules?status=draft), the owner is notified in the web app, and post.failed with error content_rules_violated is emitted; with warn it publishes and the violations are recorded. Not checked: posts written in the web app's compose page, cloud patrol replies, auto-replies to comments on the account's posts, and browser patrol (extension) replies and posts. Behavior change: scheduling or threading text that violates an enforce:block account through these paths used to succeed and now answers 422, and such a post already in the queue is held as a draft instead of published. Also a behavior change: PATCH /accounts/{id}/settings with a live key (legacy keys included) used to merge content_rules key by key and now replaces the object, so rules left out of the body are removed, and the stricter matching above can refuse text that used to pass. PATCH /accounts/{id}/settings now really replaces content_rules as a whole on live keys, as documented: before 1.8.3 a live write merged the object key by key, so rules left out of the body silently stayed. A settings approval (PATCH /accounts/{id}/settings waiting for the owner) now shows the owner every field the body touches as current and proposed value, using the value the server would actually write, including fields that are not guardrails such as persona and schedule_times; content_rules is itemized down to the added and removed facts and banned phrases and the enforce change. A fact that differs only in spaces is listed too, with the numbers the change newly allows. The comparison is capped at 60,000 characters: long current values are shortened (truncated:true), and a request whose comparison still does not fit answers 413 approval_payload_too_large. A facts change counts as loosening (accounts:guardrails) when a fact is new ignoring spaces, when the set of numbers the facts allow grows (a space inside 101563 allows 10 and 1563), or when a new Chinese quantity phrase appears. Such an approval also records the current value of every field the body touches. If any of those fields changes before the request runs, it is not run: the approval turns failed with result.error.code approval_base_changed as soon as it is read, listed or decided (deciding answers 409 approval_base_changed, checked in the same transaction, and always is not applied), or right before it runs. Changes to fields the body does not touch do not matter. Read the settings again and resend: the same body then gets a new approval. Settings approvals created before 1.8.3 have no recorded values and end the same way when read, listed or decided. GET /schedules items carry held_reason and rule_violations; POST /content/publish carries rule_violations on live keys too; a scheduled video from POST /content/publish now publishes as a video.","1.8.2":"2026-09-24. New GET /keys/current/usage: the calling key's own usage (summary { calls, units, errors, by_endpoint[] } and recent[] { request_id, endpoint, status, units, at } with cursor paging; days 1..30, limit 1..100, cursor = next_cursor of the previous page); no permission needed, no daily quota, at most 10 requests per minute per key on this endpoint, on top of the usual per-minute limit; MCP tool get_my_usage. Every request after the key is identified is now recorded, including 400, 403 and 429 refusals. 429 answers and refusals made before the quota check (400 invalid_idempotency_key, 403 scope_unmapped) are recorded about once per key per minute on each server, so those counts are a lower bound. Test keys: sandbox writes that publish now or approve a pending cloud reply record a real sandbox event (post.published or patrol.reply with test_mode:true, key_id, persisted:false, request_id), and GET /events with a test key returns only that key's sandbox events (including its approval.decided) instead of mock data, with data_source: sandbox and an explanatory note when empty. Sandbox events are never delivered to webhooks and never shown to live keys. From 1.8.2, publishing now with a live key through POST /content/publish or POST /content/generate-and-schedule (publish_now) also emits post.published or post.failed (source api_publish or api_generate_and_schedule); webhook deliveries can repeat, so dedupe by post_id. GET /events covers the last 7 days; latest_at moves past events you did not ask for (types), so polling never sticks. It answers 503 events_index_building while its index is being built. An unhandled server error now answers 500 server_error in the standard envelope. An X-Request-Id starting with apr_exec_ is replaced by a server-generated id.","1.8.1":"2026-09-24. New PATCH /keys/{id} for the owner (web app session, x-audience human): change an existing key's permissions, label, agent_name and agent_url in place; insufficient_scope.fix now says so instead of asking for a new key. Setting a permission to deny cancels that key's pending approvals for it. POST /keys/current/disable answers cancelled_approvals and cancelled_approval_ids. Cancelled approvals carry cancel_reason (GET /approvals/{id}, approval.decided). GET /me data.key.agent_name and agent_url show what the owner entered. /keys errors from the web app session use the standard error envelope. GET /keys items carry scopes_updated_at; PATCH takes it back as if_scopes_updated_at and answers 409 key_changed when the permissions changed meanwhile. Creating a live key wider than standard needs a sign-in within 24 hours (401 reauth_required). label and agent_name refuse invisible control characters (400 invalid_label, invalid_agent_name; POST /keys no longer cuts a label short). An approval whose permission is deny by now can no longer be approved: decide cancels it and answers 409 approval_permission_denied.","earlier":"https://mindthread.tw/developers (Changelog)"},"x-agent-playbook":{"when a call answers approval_required (same as the MCP instructions)":["give error.approval.human_url (or human_message) to the human as is; never open it yourself","do not resend the request: the same body returns the same approval while it is pending, which is also how you find a lost approval_id","poll GET /approvals/{id} about every 15 seconds (Retry-After) or watch GET /events types=approval.decided","executed: the normal response is in result.data; denied, expired, cancelled or failed: stop and ask the human","insufficient_scope or approval_not_supported: stop and tell the human (error.fix says what the owner can do)","from 1.10.0 the owner may decide from a one-time link in their own email or push notification: never ask the human to paste that link or a code to you; decision_via on GET /approvals/{id} tells you how they decided"],"promote a product through the API":["GET /me → confirm plan and quotas; GET /accounts → pick account_id","PATCH /accounts/{id}/settings → set persona (brand voice), schedule_times (e.g. 09:00,12:30,21:00), review_before_publish (true if the owner wants to approve AI drafts)","PATCH /accounts/{id}/settings content_rules → max_chars/min_chars, forbid_cta, forbid_hashtags, banned_phrases, facts (the only numbers the AI may use; the server also remembers which ones the last 5 posts used), forbid_causal_claims; enforce:block once the owner is happy. content_rules is replaced as a whole, so send the full object. Library items written by any other tool, and posts scheduled through the API (1.8.3), are checked again at publish time.","POST /library with 10-20 items (status queued) or POST /content/generate → POST /library; publishing happens automatically at schedule_times. GET /library shows position and next_publish_at; PATCH /library/{id} position:first to move one up","POST /content/publish with media_urls for product photos (2-10 images = carousel), publish_now or publish_at","PUT /patrol/cloud with 3-5 keywords and enabled:true → the account starts joining relevant conversations every 15 minutes; add review_before_reply:true to approve each drafted reply via GET /patrol/cloud/pending","Daily: GET /patrol/cloud/stats, GET /patrol/browser/stats and GET /analytics/insights → adjust keywords / persona / facts; GET /library?status=draft → approve or delete drafts (a draft with held_reason publish_result_unknown may already be on Threads: leave it to the owner); GET /events?since=… or a webhook for patrol.pending / post.failed"],"review checklist before queueing text (what the platform cannot judge for you)":["one idea per post; a number only if it is in facts; no causal claims the facts do not support","mention the product at most once and only after a concrete number or feature","views are impressions, not people; do not write \"N people saw this\"","no em dashes, no \"we\" when the persona is a single person, no hashtags, no canned CTA"]}}