# Quick start

> Page: https://docs.flung.dev/quick-start. Index of every page: https://docs.flung.dev/llms.txt

Connect a social account and publish your first post through Flung, from your server or from an AI agent.

## TL;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](https://docs.flung.dev/mcp.md), then ask it to "connect my LinkedIn and post that we're live". |

## 1. Install the SDK

```bash
npm install @flung.dev/sdk
```

The 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.

**curl**

```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"
}'
```

**TypeScript**

```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',
})
```

**fetch**

```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](https://docs.flung.dev/connect-accounts.md).

## 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.

**curl**

```bash
curl -X GET 'https://api.flung.dev/v1/accounts?reconnectBefore=2026-11-30T00%3A00%3A00Z' \
  --header "Authorization: Bearer $FLUNG_API_KEY"
```

**TypeScript**

```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',
})
```

**fetch**

```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()
```

**curl**

```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"
  }
}'
```

**TypeScript**

```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',
  },
})
```

**fetch**

```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](https://docs.flung.dev/connect-accounts.md) |
| Attach images and video | [Images and video](https://docs.flung.dev/media.md) |
| Be told when posts go out | [Webhooks](https://docs.flung.dev/webhooks.md) |
| Give an AI agent the same powers | [Connect an AI agent](https://docs.flung.dev/mcp.md) |
| See every endpoint | [API reference](https://docs.flung.dev/reference/api.md) |
