> ## Documentation Index
> Fetch the complete documentation index at: https://api.onlysocial.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Client Connect API

> Give a customer a link that connects, or reconnects, their social accounts and messaging channels, with no dashboard login.

> [!NOTE]
>
> Switched on per partner. `GET /api/partner/connect/settings` tells you whether
> it is on for you and which providers you can use.

Your software gives one of your customers a link. They open it, sign in with
the social network (or WhatsApp's own signup), tick the accounts if there is a
choice, and the accounts and channels appear in their workspace, ready to
publish to and, where the workspace has an inbox, to message from. Nobody logs
into the dashboard, and no provider token ever reaches your software or their
browser.

One endpoint covers every network: publishing profiles, messaging channels,
WhatsApp numbers and Telegram bots.

All paths are relative to `/api/partner`, authenticated by your partner key as
`X-API-KEY`, from your backend only.

## What you can connect

| `provider` | What your customer does |
| - | - |
| `facebook_page` | Signs in with Facebook, then ticks the Pages. Each Page is connected for publishing and, with an inbox, for Messenger. `facebook` and `messenger` are accepted as aliases. |
| `instagram` | Signs in with Facebook, then ticks the Instagram professional accounts (each linked to a Page). |
| `instagram_direct` | Signs in with Instagram (Instagram Login: no Facebook Page needed). `instagram_login` is accepted as an alias. |
| `linkedin` | Signs in with LinkedIn. One login is one profile. |
| `linkedin_page` | Signs in with LinkedIn, then ticks the organisation pages. |
| `youtube` | Signs in with Google, then ticks the channels. |
| `google_m_b` | Signs in with Google, then ticks the Business Profile locations. `gbp` is accepted as an alias. |
| `threads` | Signs in with Threads. |
| `tiktok` | Signs in with TikTok. |
| `pinterest` | Signs in with Pinterest. Boards are chosen per post. |
| `reddit` | Signs in with Reddit, then ticks the profile and the subreddits they moderate. |
| `tumblr` | Signs in with Tumblr, then ticks the blogs. |
| `twitter` | Signs in with X. `x` is accepted as an alias. |
| `v_kontakte` | Signs in with VK. `vk` is accepted as an alias. |
| `blue_sky` | Signs in with Bluesky (no app password). `bluesky` is accepted as an alias. |
| `mastodon` | Types their Mastodon server (unless you send it), then signs in there. |
| `whatsapp` | Opens Meta's own WhatsApp signup and picks the number there. Add `"coexistence": true` to keep the number on the WhatsApp Business app. |
| `telegram` | Nothing: you send the bot's BotFather token, and the bot is connected in the same call. See [Telegram](#telegram). |

When the sign-in gives access to just one account, it is connected straight
away, with no picker. For publishing providers, `provider` is the same value the
Publishing API returns in an account's `provider` field.

> [!NOTE]
>
> Which providers are available depends on how OnlySocial is configured, so ask
> rather than assume: `GET /api/partner/connect/settings` returns the list. A
> provider that is not on it is refused with a `422` and
> `"error_code": "provider_not_supported"`.

## 1. Read the settings and register your return URLs

```bash theme={null}
curl https://app.onlysocial.io/api/partner/connect/settings \
  -H "X-API-KEY: $PARTNER_KEY"
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "enabled": true,
    "providers": [
      { "provider": "facebook_page", "broker_slug": "facebook_page", "mode": "relay", "entities": true, "reconnect": true, "configured": true, "asks_for": null },
      { "provider": "mastodon", "broker_slug": null, "mode": "direct", "entities": false, "reconnect": true, "configured": true, "asks_for": "server" },
      { "provider": "whatsapp", "broker_slug": null, "mode": "broker", "entities": false, "reconnect": true, "configured": true, "asks_for": null },
      { "provider": "telegram", "broker_slug": null, "mode": "token", "entities": false, "reconnect": false, "configured": true, "asks_for": "bot_token" }
    ],
    "return_urls": ["https://app.acmedealers.test/integrations/callback"]
  }
}
```

* `entities` is `true` when your customer ticks accounts after signing in.
* `configured` is `false` when OnlySocial is not set up for that provider yet.
  A link for it fails at the start with `provider_not_configured`.
* `asks_for` names what the hosted page asks your customer for when you did not
  send it (`server` for Mastodon, `handle`, optional, for Bluesky), and what a
  Telegram call needs (`bot_token`).

Your customer is sent back to a return URL you registered. Register them once:

```bash theme={null}
curl -X PUT https://app.onlysocial.io/api/partner/connect/settings \
  -H "X-API-KEY: $PARTNER_KEY" -H "Content-Type: application/json" \
  -d '{"return_urls":["https://app.acmedealers.test/integrations/callback"]}'
```

Up to 20 HTTPS URLs, no credentials, query strings or fragments. The list is
replaced on every `PUT`. **Matching is exact**, including the path and any
trailing slash. Removing a URL also stops unfinished sessions from completing
against it.

## 2. Check the allowance

A workspace's plan limits how many publishing accounts it can connect. Ask
before you show your customer a Connect button:

```bash theme={null}
curl https://app.onlysocial.io/api/partner/workspaces/$WORKSPACE/connect/allowance \
  -H "X-API-KEY: $PARTNER_KEY"
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "limit": 10,
    "used": 7,
    "remaining": 3,
    "providers": { "facebook_page": true, "twitter": false, "whatsapp": true }
  }
}
```

* `limit` and `remaining` are `null` when the plan sets no account limit.
* `providers` says, per provider, whether a new account may be added now.
  WhatsApp numbers and Telegram bots have their own limits, checked when they
  are stored, so they always read `true` here.

Creating a connection for a provider whose answer is `false` is refused at once
with a `422` and `"error_code": "account_limit_reached"`, before your customer
signs in anywhere. A reconnect never uses a new slot, so it is never refused for
the limit.

## 3. Create a connection

```bash theme={null}
curl -X POST https://app.onlysocial.io/api/partner/workspaces/$WORKSPACE/connections \
  -H "X-API-KEY: $PARTNER_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: dealer-4821-gbp-1" \
  -d '{
    "provider": "google_m_b",
    "return_url": "https://app.acmedealers.test/integrations/callback",
    "state": "dealer-4821"
  }'
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "id": "c6a1f0d2-....",
    "workspace_id": "6b1f0e2c-....",
    "provider": "google_m_b",
    "mode": "relay",
    "reconnect": false,
    "status": "pending",
    "account_id": null,
    "account": null,
    "accounts": [],
    "skipped": [],
    "max_accounts": null,
    "allow_unverified": false,
    "coexistence": false,
    "channel_id": null,
    "error_code": null,
    "state": "dealer-4821",
    "expires_at": "2026-11-28T18:30:00+00:00",
    "connect_url": "https://app.onlysocial.io/partner-connect/accounts/c6a1f0d2-...?token=..."
  }
}
```

Open `connect_url` as a **top-level navigation** in your customer's browser,
not an iframe and not a fetch. Everything after they click Continue is bound to
that browser. The session lasts **30 minutes**.

Optional fields:

| Field | For | What it does |
| - | - | - |
| `max_accounts` | Pages, channels, locations, blogs | The most accounts your customer may tick. `1` makes it a single choice. Default: as many as the plan allows. |
| `server` | `mastodon` | Your customer's server, such as `mastodon.social`. Without it, the hosted page asks. |
| `handle` | `blue_sky` | The handle Bluesky's sign-in page opens on. |
| `coexistence` | `whatsapp` | `true` keeps the number on the WhatsApp Business app. Refused for any other provider. |
| `account_id` | publishing providers | Makes it a reconnect of that account. See [Reconnect](#reconnect). |
| `channel_id` | any with a channel | Makes it a reconnect of that messaging channel. See [Reconnect](#reconnect). |
| `allow_unverified` | reconnects | Lets your customer confirm a profile that cannot be proven to be the same one. |

`state` comes back to you on the return URL and in the completion events, so
use it to match the session to your own customer. Do not put secrets or
personal data in it; at most 500 characters.

`Idempotency-Key` (1–200 characters) is optional. The same key and the same
request returns the same connection with `200`; a different request on that key
is a `409`. Only a pending, unexpired session carries a `connect_url`. Use a
new key to start over.

## 4. Read the result

Your customer comes back to your registered URL with `connection_id` and
`state`. That redirect is a hint, not the answer. Read the authoritative result:

```bash theme={null}
curl https://app.onlysocial.io/api/partner/workspaces/$WORKSPACE/connections/$CONNECTION \
  -H "X-API-KEY: $PARTNER_KEY"
```

| `status` | Meaning |
| - | - |
| `pending` | The link has not been used yet. |
| `authorizing` | Your customer is signing in with the provider, or in Meta's WhatsApp signup. |
| `selecting` | They signed in and are ticking accounts. |
| `confirming` | A reconnect you allowed to be confirmed is waiting for your customer to confirm. |
| `connected` | Done. `accounts` and `channel_id` say what was connected. |
| `failed` | See `error_code`. |
| `cancelled` | The customer denied the sign-in or refused a confirmation, or you cancelled. |
| `expired` | The 30 minutes ran out. |

On `connected`:

* `accounts` lists every account connected, in the order the provider listed
  them. Each has `id`, `uuid`, `provider`, `name` and `username`. A WhatsApp
  number is listed here too.
* `account_id` and `account` are the first of them, for code that reads one.
* `uuid` is the `{account}` in the Publishing API's `GET /accounts/{account}`.
  `id` is the integer the Publishing API's post endpoints take in `accounts`.
* `skipped` lists accounts your customer ticked that were not connected, each
  with `name` and `reason` (for example `account_limit_reached` when the plan
  had room for fewer).
* `channel_id` is the messaging channel, when there is one: a WhatsApp number or
  Telegram bot always has one; a publishing account has one when the workspace
  has an inbox and the network supports messaging. It is `null` otherwise, and
  that is not an error.

For WhatsApp, `connected` means the number was stored and subscribed. Whether
messages actually flow still depends on Meta account eligibility and messaging
rules.

`POST /api/partner/workspaces/{workspace}/connections/{connection}/cancel`
cancels an unfinished session. Repeating it is safe, and it never disconnects an
account or channel that already connected.

## Reconnect

When an account or channel stops working (an expired or revoked sign-in), send
your customer a reconnect link: create a connection with its uuid.

* `account_id`: a publishing account of that workspace and that `provider`.
* `channel_id`: a messaging channel. A WhatsApp channel is reconnected through
  WhatsApp's signup; a channel that belongs to an account (a Page's Messenger, an
  Instagram account) reconnects that account, so send that account's `provider`.

```bash theme={null}
curl -X POST https://app.onlysocial.io/api/partner/workspaces/$WORKSPACE/connections \
  -H "X-API-KEY: $PARTNER_KEY" -H "Content-Type: application/json" \
  -d '{
    "provider": "linkedin",
    "return_url": "https://app.acmedealers.test/integrations/callback",
    "account_id": "9d3f6a10-...."
  }'
```

The account keeps its id, its scheduled posts and its history. Your customer
must sign in as the **same** profile:

* If they sign in as a different one, nothing is changed and the session fails
  with `reconnection_target_mismatch`.
* For a Page, channel or location, there is no picker on a reconnect. The
  sign-in must have access to that same Page, channel or location, or the
  session fails with `reconnection_target_mismatch`.
* A target that is not in that workspace, or not that provider's, is a `422`.
* WhatsApp is the one exception: the number is picked inside Meta's dialog. If
  your customer picks a different number, that number **is** connected, and the
  session fails with `reconnection_target_mismatch` and the new `channel_id`, so
  you can decide what to do.

### When the profile cannot be proven

Some providers give a different user id to each app, so after OnlySocial moves
apps a reconnect cannot always prove it is the same profile. By default such a
reconnect fails with `reconnect_needs_confirmation` and nothing is changed.

If you know who your customer is, send `"allow_unverified": true` with the
reconnect. The hosted page then shows the account being reconnected and the
profile they signed in as, and your customer confirms or refuses. A profile
proven to be a different one is still refused.

## Telegram

Telegram has no sign-in screen, so there is no link: you collect the bot's
BotFather token in your software and send it.

```bash theme={null}
curl -X POST https://app.onlysocial.io/api/partner/workspaces/$WORKSPACE/connections \
  -H "X-API-KEY: $PARTNER_KEY" -H "Content-Type: application/json" \
  -d '{"provider":"telegram","bot_token":"123456:ABC...","name":"Acme Motors","state":"dealer-4821"}'
```

The answer is a connection that is already `connected`, with the bot's
`channel_id`, and `meta.webhook_registered` / `meta.webhook_taken_over`. `201`
for a new bot, `200` for the same bot again (its channel is refreshed, not
duplicated). The token is never stored on the connection or echoed back.

* A `422` on `bot_token` means the token was rejected, or the bot is
  OnlySocial's own bot, or it is already connected to another workspace, or the
  plan's limit is reached.
* A `422` on `takeover` means the bot's webhook points somewhere else.
  Connecting it here stops that from receiving the bot's messages, so resend
  with `"takeover": true` only if your customer confirms.

## Read channels

* `GET /api/partner/workspaces/{workspace}/channels`: `per_page` up to 100.
* `GET /api/partner/workspaces/{workspace}/channels/{channel}`

Both return the public channel fields only: never channel data or access tokens.

## Or subscribe

Rather than polling, subscribe the workspace's webhooks (with the `osk_` key you
issued for it) to `publishing.account.connection.completed`, `.failed`,
`.cancelled` and `.expired`. Every connection sends them. See
[Events](https://api.onlysocial.io/webhooks/events.md#client-connect-api).

A connection that has a messaging channel (WhatsApp, Telegram, Facebook Pages,
Instagram, TikTok, YouTube, LinkedIn pages, Google Business Profile, Threads,
Reddit, Mastodon and Bluesky) also sends `salesbot.channel.connection.*`, with
the same connection `id`, so a subscriber that only listens to messaging events
hears about it too.

Delivery is at least once. **Deduplicate on the envelope's `id`.**

## Error codes

| Code | Meaning |
| - | - |
| `provider_not_supported` | That provider is not available on OnlySocial. Read `GET /connect/settings` for the list. |
| `provider_not_configured` | The provider is not set up yet. Contact OnlySocial support. |
| `provider_unavailable` | A transient failure reaching the provider. Retry with a new session. |
| `authorization_not_completed` | The sign-in or WhatsApp's dialog was closed or denied, or the number could not be stored (connected elsewhere, the plan's limits are full, a permission withheld). |
| `token_exchange_failed` | The provider would not exchange the authorization. Retry with a new session. |
| `no_eligible_accounts` | The sign-in has nothing to connect: no Page, no Instagram professional account, no channel, no location or no organisation page. |
| `account_limit_reached` | The plan's connected-account limit is full. |
| `account_blocked` | That profile may not be connected to OnlySocial. |
| `reconnection_target_mismatch` | A reconnect signed in as a different profile, or without access to what it was meant to reconnect. Nothing was changed, except for WhatsApp (see [Reconnect](#reconnect)). |
| `reconnect_needs_confirmation` | The reconnect could not prove it is the same profile, and the link did not allow your customer to confirm (or they refused). |
| `reconnect_not_supported` | That account's provider cannot be reconnected by link. |
| `reconnect_failed` | The account changed while the session was open. Retry with a new session. |
| `server_not_supported` | Mastodon: that server could not be used (not a public server, or it refused the app registration). |
| `session_expired` | The 30 minutes ran out. |

Provider error bodies are deliberately not exposed. Fix the configuration, or
let your customer retry with a **new** session.

## Keep it safe

* The partner key stays on your server. It can act on every workspace you have
  provisioned.
* `connect_url` carries a one-session capability and lasts 30 minutes. Hand it
  straight to the customer's browser; do not log it, e-mail it or put it in an
  analytics event. To invite a customer by e-mail (a reconnect reminder, say),
  e-mail a link to **your own** app and create the connection when they arrive.
* A Telegram bot token is a credential: send it from your server only, and do not
  keep it once the bot is connected.
* A connection id is not a secret, but your `state` should be unguessable if you
  use it to resume anything on your side.
* Send `allow_unverified` only when your own records tie the link to the account's
  owner: a confirmed reconnect hands the account's scheduled posts to the profile
  that signed in.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.