Get started
Quick start
Connect a social account and publish your first post through Flung, from your server or from an AI agent.
Claude Code
claude mcp add --transport http flung https://mcp.flung.dev/mcp-oauthTL;DR
| Question | Answer |
|---|---|
| What do I need? | A Flung API key (it starts flung_sk_), kept on your server. |
| How long does it take? | A few minutes: install, connect one account, post. |
| Can an AI agent do this for me? | Yes. Skip to Connect an AI agent, then ask it to "connect my LinkedIn and post that we're live". |
1. Install the SDK
bash
npm install @flung.dev/sdkThe SDK runs on a server: Node 20 or newer, Cloudflare Workers, Deno or Bun. Keep the key in an environment variable such as FLUNG_API_KEY.
2. Connect an account
Start a connect, send the person to the authorizationUrl it returns, and wait until they approve on the platform.
bash
curl -X POST 'https://api.flung.dev/v1/connect/linkedin' \ --header "Authorization: Bearer $FLUNG_API_KEY" \ --header 'Content-Type: application/json' \ --header "Idempotency-Key: $(uuidgen)" \ --data '{ "redirectUrl": "https://app.example.com/settings/social", "handle": "alice.bsky.social"}'ts
import { Flung } from '@flung.dev/sdk'
const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })const result = await flung.accounts.connect({ platform: 'linkedin', redirectUrl: 'https://app.example.com/settings/social', handle: 'alice.bsky.social',})js
const response = await fetch('https://api.flung.dev/v1/connect/linkedin', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.FLUNG_API_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': crypto.randomUUID(), }, body: JSON.stringify({ redirectUrl: 'https://app.example.com/settings/social', handle: 'alice.bsky.social', }),})if (!response.ok) throw new Error((await response.json()).error.message)const result = await response.json()The SDK waits for you:
ts
const session = await flung.accounts.connect({ platform: 'linkedin' })console.warn(`Open ${session.authorizationUrl}`)const done = await flung.waitForConnection(session.id)To let your own users connect accounts on your website instead, use the connect panel.
3. Publish a post
List the connected accounts, then post to them. Leave out publishAt to publish now, or give a time to schedule it.
bash
curl -X GET 'https://api.flung.dev/v1/accounts?reconnectBefore=2026-11-30T00%3A00%3A00Z' \ --header "Authorization: Bearer $FLUNG_API_KEY"ts
import { Flung } from '@flung.dev/sdk'
const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })const result = await flung.accounts.list({ reconnectBefore: '2026-11-30T00:00:00Z',})js
const response = await fetch('https://api.flung.dev/v1/accounts?reconnectBefore=2026-11-30T00%3A00%3A00Z', { method: 'GET', headers: { 'Authorization': `Bearer ${process.env.FLUNG_API_KEY}`, },})if (!response.ok) throw new Error((await response.json()).error.message)const result = await response.json()bash
curl -X POST 'https://api.flung.dev/v1/posts' \ --header "Authorization: Bearer $FLUNG_API_KEY" \ --header 'Content-Type: application/json' \ --header "Idempotency-Key: $(uuidgen)" \ --data '{ "content": "Launching today.", "accountIds": [ "acct_aaaaaaaaaaaaaaaaaaaaaaaa" ], "platformOverrides": { "x": { "content": "Launching today. #launch" } }, "variables": { "product": "Flung" }}'ts
import { Flung } from '@flung.dev/sdk'
const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })const result = await flung.posts.create({ content: 'Launching today.', accountIds: [ 'acct_aaaaaaaaaaaaaaaaaaaaaaaa', ], platformOverrides: { x: { content: 'Launching today. #launch', }, }, variables: { product: 'Flung', },})js
const response = await fetch('https://api.flung.dev/v1/posts', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.FLUNG_API_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': crypto.randomUUID(), }, body: JSON.stringify({ content: 'Launching today.', accountIds: [ 'acct_aaaaaaaaaaaaaaaaaaaaaaaa', ], platformOverrides: { x: { content: 'Launching today. #launch', }, }, variables: { product: 'Flung', }, }),})if (!response.ok) throw new Error((await response.json()).error.message)const result = await response.json()The answer has a target per account. Read the post again, or listen for webhooks, to see each one published or failed.
Where next
| To | Read |
|---|---|
| Let your users connect accounts on your site | Add account connecting to your site |
| Attach images and video | Images and video |
| Be told when posts go out | Webhooks |
| Give an AI agent the same powers | Connect an AI agent |
| See every endpoint | API reference |