AI agents
Flung for AI agents
What an AI agent needs to use Flung, and to build Flung into someone's product: which way in to choose, the order of calls, and the rules that keep posts and accounts safe.
TL;DR
| Question | Answer |
|---|---|
| What is Flung? | An API that connects social media accounts (X, Instagram, Facebook, Threads, LinkedIn, TikTok, YouTube, Pinterest, Bluesky, Mastodon, Discord, Farcaster) and publishes posts to them, now or on a schedule. |
| I am an agent posting for a person | Use the MCP server: https://mcp.flung.dev/mcp-oauth. See Connect an AI agent. |
| I am a coding agent adding Flung to a website | Follow Add Flung to a website step by step. Every file it shows is from a working example. |
| I need every page in one file | https://docs.flung.dev/llms-full.txt. The index is https://docs.flung.dev/llms.txt, and any page is Markdown with .md added to its address. |
| I need the exact API | https://docs.flung.dev/openapi.json (OpenAPI 3.1) and https://docs.flung.dev/tools.json (the MCP tools with JSON Schemas). |
Choose the way in
| The task | Use | Why |
|---|---|---|
| Post, schedule, or check accounts for a person, in a chat | The MCP server | The person signs in once in their browser; no key is handled. |
| Call Flung from a server or a script | @flung.dev/sdk, or the REST API | Typed, retried, idempotent. |
| Let people connect their accounts on a web page | @flung.dev/connect with a connect token | The API key never reaches the browser. |
| React to posts being published or failing | Webhooks | Signed events, retried until your endpoint answers. |
What the server tells every agent
The MCP server sends this when a client connects. It holds over HTTP too.
- Flung connects social media accounts and schedules posts to them.
- To keep accounts working, start with find_accounts_needing_attention. Accounts with renewal "automatic" renew themselves; the others need a person before reconnectBy.
- Connecting or reconnecting needs a person: call connect_account or reconnect_account, give the person the authorizationUrl, then poll get_connect_session until it is not pending. The link expires in ten minutes.
- To post, call list_accounts for ids, then schedule_post with an idempotencyKey you reuse on retry, then get_post for the outcome.
- A refused call is an answer, not a fault: its text says what to do next.
Rules
- Never put an API key (
flung_sk_...) in a browser, a page, a commit or a log. A page gets a connect token from its own server. - A person must approve every connect and reconnect on the platform's own page. Give them the link; never try to complete it.
- Send an
Idempotency-Keywith every POST, and reuse it when you retry the same request, or a post may go out twice. - Ask the person before calling anything that disconnects an account, cancels a post, or replies publicly.
- Branch on
error.code, never on the message. A refusal says what to do next.
See also
| Doc | Why |
|---|---|
| Add Flung to a website | The recipe for coding agents |
| Rules file | A block to paste into CLAUDE.md or AGENTS.md |
| Prompts and recipes | Requests that work, and the tools behind them |
| Files for agents | Every machine-readable file this site serves |