# Flaghand: overview

Flaghand is a publishing desk for people and their AI agents. You write posts for X, LinkedIn, Bluesky and TikTok, check that
each one would go out exactly as previewed, and schedule it. Every post sits on one schedule you can edit until it
goes. Flaghand checks each post again right before posting, posts it on time and checks that what went live matches
the preview. TikTok still asks you to consent to each post ([TikTok](https://app.flaghand.com/docs/tiktok)).

The API is the product. The web app, the CLI and the MCP server use only this API, so an agent can do almost
everything a person can. Two things stay the owner's: connecting accounts and posting right now.

- Base URL: `https://app.flaghand.com/api/v1`
- Spec: `https://app.flaghand.com/api/v1/openapi.json` (OpenAPI 3.1, generated from the server's own route table)
- MCP: `https://app.flaghand.com/mcp` lists the drafting loop and finds every other operation on demand (`?toolset=all` lists one tool
  per operation); the `flaghand` CLI has one command per operation ([agents](https://app.flaghand.com/docs/agents))
- Docs: [agents](https://app.flaghand.com/docs/agents), [sign-in and tokens](https://app.flaghand.com/docs/sign-in-and-tokens), [drafts and media](https://app.flaghand.com/docs/drafts-and-media),
  [feeds](https://app.flaghand.com/docs/feeds), [jobs and posting now](https://app.flaghand.com/docs/approvals), [TikTok](https://app.flaghand.com/docs/tiktok), [slideshows](https://app.flaghand.com/docs/slideshows), [the desk](https://app.flaghand.com/docs/desk),
  [notifications](https://app.flaghand.com/docs/notifications), [automations](https://app.flaghand.com/docs/automations), [sign-up and billing](https://app.flaghand.com/docs/billing), [errors](https://app.flaghand.com/docs/errors),
  [changelog](https://app.flaghand.com/docs/changelog)

## The model

- A **workspace** holds everything: its people, connected accounts, drafts, media, scheduled posts, jobs and audit log.
  Nothing in one workspace can be read or changed from another.
- **Members** are people, each an `owner` or an `editor`. They sign in with a passkey, Google or an email link or code; there are no passwords.
  Signing up creates a workspace and its first owner, and owners invite others. A workspace posts only while its plan
  is active ([billing](https://app.flaghand.com/docs/billing)).
- **Connections** are the X, LinkedIn, Bluesky and TikTok accounts a workspace posts as. Each is pinned to the account that first
  signed in: signing in again as anyone else is refused. An agent can start one; the account's owner signs in on the
  platform's own consent screen. Disconnecting revokes the login at the platform and deletes it here.
- **Drafts** are posts in progress: one X post, one X thread, one LinkedIn post, one Bluesky post or thread, one
  TikTok photo post or one TikTok video.
  Each has a `rev` that every change must name.
- **Jobs** are scheduled posts. A once-a-minute scheduler checks each due post again, posts it, retries without
  posting anything twice, reads X posts back to compare them with the preview, and follows TikTok's status until
  TikTok is done.
- **Events** are the audit log: who (a person, a token, the operator or the system) did what, and when.

## What an agent does

1. Read `GET /api/v1/me` to learn its workspace. If an account isn't connected yet, start it
   (`POST /workspaces/{workspace}/connections/{platform}/start`) and give the owner the link.
2. Upload media, if any (`POST /workspaces/{workspace}/media`).
3. Post the whole plan in one call (`POST /workspaces/{workspace}/posts`): it creates the drafts, checks each one and,
   when every check passes, schedules them all. The answer has a `schedule_url` to the owner's schedule. When a check
   fails, nothing is scheduled: apply the fixes it offers and send the drafts again by id. The same steps one at a time
   are `POST …/drafts`, `POST …/drafts/{id}/check` and `POST …/approval-requests`.
4. Watch the jobs (`GET /workspaces/{workspace}/jobs`) and report the live check once they're posted. Later,
   `GET /workspaces/{workspace}/job-results` says how each X post did, and `GET /workspaces/{workspace}/top-posts`
   ranks the last 30 days' best, to draft from what worked.

The [agents guide](https://app.flaghand.com/docs/agents) walks through these steps with the CLI and with MCP.

Agents can [schedule and manage future posts](https://app.flaghand.com/docs/schedule-and-results.md#agent-scheduling) with the `drafts` scope.
Posts scheduled by you or your agent publish at their time. Your agent asks you before anything posts right now; you
confirm that one with your passkey. Scheduling sets aside the credits a post can spend and needs an active plan or card. Add a card with your first post.

## Conventions

- JSON in and out, except media uploads (raw bytes) and media downloads.
- Times are ISO 8601 (RFC 3339). Times you send need their UTC offset, `Z` or `±HH:MM`, like `2026-11-02T08:30:00-08:00`
  or `2026-11-02T16:30:00Z`; a time without one is refused. A new draft's `post_at` may instead be `"next_slot"`: the
  account's next open [weekly posting time](https://app.flaghand.com/docs/drafts-and-media#weekly-posting-slots). Times in answers are in UTC, like `2026-11-02T16:30:00.000Z`.
- Ids carry their type: `ws_` workspace, `usr_` person, `drf_` draft, `med_` media, `apr_` approval, `tkn_` token.
- Errors are `{ "error": { "code": "...", "message": "..." } }`. The code is stable; the message is one plain sentence.
