> Markdown version of https://socialcannon.app/guides/let-users-connect-social-accounts-api (Let your users or clients connect their social accounts to your app). The index of all SocialCannon documentation is at https://socialcannon.app/llms.txt.

# Let your users or clients connect their social accounts to your app

Your backend creates a short-lived connect link, the account owner approves on the social network and returns to your own URL with the new account ID. Covers return URLs, plan limits, reconnecting and agencies.

Updated 29 November 2026 · 8 min read

If you run a SaaS product, your users may want to post to their own social accounts from inside it. If you run an agency, your clients own the accounts you post for. In both cases the account owner has to sign in to the social network and approve access themselves. SocialCannon gives your backend a short-lived connect link for that step. The owner opens it, approves on the network and comes back to your app with the new account ID, and from then on your backend posts to that account through the REST API.

Accounts connected this way are connected to **your** SocialCannon workspace, the one that owns the API credentials. Your users do not need a SocialCannon account, and their accounts count towards your plan.

SocialCannon has no branded connect page. The connect link goes to the social network’s own consent screen, which names SocialCannon’s app, and the person then returns to your app. Bluesky, Facebook and Instagram add a SocialCannon page on the way: Bluesky first asks for the person’s handle, and Facebook and Instagram show a page to choose which Pages or accounts to connect when the login has more than one. Tell your users before they start that they will be asked to approve SocialCannon.

## How the flow works

1. Your backend asks SocialCannon for a connect link for one network, with a return URL in your app.
2. You send the account owner’s browser to that link.
3. The owner signs in to the network and approves access on its consent screen.
4. SocialCannon saves the account in your workspace and sends the browser back to your return URL with the new account ID in the query string.
5. Your backend checks the account and stores its ID against the user or client who connected it.

There is no webhook for a new connection. Your app learns about it from the return URL, or by listing accounts with the API.

## Before you start

- A SocialCannon account and API credentials from **Settings → API Keys**. The calls in this guide need these scopes: `accounts:write` to create connect links, `accounts:read` to read accounts, `posts:write` to post, and `clients:manage` only if you register return origins through the API rather than in Settings.
- A plan with room for the accounts you expect. Each connected account counts towards your plan: a new Free workspace allows one connected account, Pro allows 20 connected accounts ($15 a month), Agency allows 200 connected accounts ($49 a month) and Enterprise allows unlimited connected accounts ($150 a month). See [pricing](https://socialcannon.app/pricing) for the other limits.

Request a token

```
curl -X POST https://socialcannon.app/api/v1/auth/token \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "client_credentials",
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET"
  }'
```

The response’s `access_token` is the bearer token for the calls below. Keep the credentials on your server: a connect link must never be created from code that runs in your users’ browsers.

## Step 1: Register your return origins

SocialCannon only sends people back to addresses you have approved. Register up to 10 return origins for your workspace, either in **Settings → API Keys → Return URLs** or with `PUT /api/v1/accounts/connect-return-origins`, which needs the `clients:manage` scope. The request replaces the whole list.

Register two return origins

```
curl -X PUT https://socialcannon.app/api/v1/accounts/connect-return-origins \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "origins": ["https://app.example.com", "https://staging.example.com"] }'
```

Each entry is an exact origin: `https://`, a host name and an optional port, with no path, query, wildcard or user name. Plain `http://` is accepted only for `localhost` and `127.0.0.1`. Matching is exact, so a subdomain or another port needs its own entry. If you remove an origin, connections already in progress no longer return there; they end on SocialCannon’s result page instead.

## Step 2: Create a connect link

When a user clicks “Connect LinkedIn” (or any other network) in your app, your backend calls `POST /api/v1/accounts/connect-token` with the `accounts:write` scope.

Create a LinkedIn connect link

```
curl -X POST https://socialcannon.app/api/v1/accounts/connect-token \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "linkedin",
    "redirectTo": "https://app.example.com/integrations/social/done?pending=8f3c2a",
    "timezone": "Europe/London"
  }'
```

| Field | Meaning |
| --- | --- |
| `platform` | The network to connect. Required. The accepted values are listed below. |
| `redirectTo` | Optional. Where the browser goes afterwards: a URL on one of your return origins, at most 1024 bytes once URL-encoded (a longer one is refused with 400). It keeps any query string you put on it, so you can add your own reference to the pending connection. |
| `timezone` | Optional. An IANA time zone such as Europe/London, saved on the account. |
| `accountId` | Optional. Reconnects an existing Facebook or Instagram account; see reconnecting below. |

Response

```
{
  "success": true,
  "data": {
    "connectUrl": "https://socialcannon.app/api/connect/linkedin?connect_token=...",
    "expiresIn": 600,
    "connectContractVersion": 3
  }
}
```

Send the browser to `connectUrl` unchanged. The link is valid for 10 minutes (`expiresIn` is in seconds), so create it when the person clicks and redirect them straight away; do not email it or store it. `connectContractVersion` identifies the result format described in this guide: check that it is 3 before you redirect, and if it is not, stop and alert your team rather than sending the person through.

An absolute `redirectTo` whose origin is not on your list is refused with `400 CONNECT_REDIRECT_NOT_ALLOWED` and no link is created:

The refusal message

```
redirectTo must be a relative path or a URL on one of this workspace's return origins. Add the exact origin (for example https://app.example.com) in Settings → API Keys → Return URLs, or with PUT /api/v1/accounts/connect-return-origins, then request a new connect token.
```

If you leave out `redirectTo`, the flow ends on a plain SocialCannon page that says “Account connected. You can close this tab.” It shows no account details, so your backend then finds the new account with `GET /api/v1/accounts`.

## Networks you can connect

| platform value | Network | On the Free plan |
| --- | --- | --- |
| `twitter` | X (Twitter) | No: X needs a paid plan |
| `facebook` | Facebook | Yes |
| `instagram` | Instagram | Yes |
| `linkedin` | LinkedIn | Yes |
| `tiktok` | TikTok | Yes |
| `youtube` | YouTube | Yes |
| `threads` | Threads | Yes |
| `bluesky` | Bluesky | Yes |

On Free, a connect link for X is refused before the X sign-in screen and the person returns with an error.

## Step 3: Handle the return in your app

After a successful connection the browser arrives at your return URL with these query parameters:

| Parameter | Value |
| --- | --- |
| `connected` | The platform value, for example linkedin. |
| `connected_account_id` | The SocialCannon account ID. Use it as accountId when you post. |
| `connected_account_ids` | Facebook and Instagram only: the connected account IDs, separated by commas. |
| `connected_count` | Facebook and Instagram only: how many accounts were connected. |
| `connect_intent` | Facebook and Instagram only: connect_one for a new connection, or reconnect. |
| `warning` | Sometimes present: a sentence to show the person, for example when only some selected accounts were connected. |

Example return

```
https://app.example.com/integrations/social/done?pending=8f3c2a&connected=linkedin&connected_account_id=ACCOUNT_ID
```

If the connection fails, the browser usually returns to the same URL with `error=` and a sentence you can show the person, such as an account limit or a refused permission. Facebook and Instagram sometimes add `error_code` as well. An expired or invalid link, or a rate limit, ends on SocialCannon’s plain error page instead, and a repeated callback can return with `connection_status` and a `warning` but neither `connected` nor `error`.

Anyone can type a URL with these parameters, so treat them as a pointer, not as proof. Your return handler should:

1. Look up the pending connection from your own reference (`pending` above) and the signed-in user.
2. Read the account with `GET /api/v1/accounts/ACCOUNT_ID` (scope `accounts:read`). It is returned only if it is in your workspace.
3. Check that its platform matches the link you created.
4. Accept the ID only if you have not already stored it against a different user or client; if you have, do not move it, and ask the person to contact you. Then store it against that user or client. Every account in your workspace passes the first checks, so on their own they do not show which of your users connected it. Connecting the same social account again returns the same ID, so a retry or a reconnect by the same user passes. Account IDs are random, and only your backend can list them with your API credentials, so a user cannot guess another account’s ID; keep IDs out of other users’ views.
5. For a stricter check, list your workspace’s accounts with `GET /api/v1/accounts` when you create the pending connection, and accept a new ID only if it was not on that list or is already stored against this user. A retry after a lost return then needs your support team.
6. For Facebook and Instagram, read `connected_account_ids`: one approval can connect several Pages or accounts, and each one needs the same checks.

Check the new account

```
curl https://socialcannon.app/api/v1/accounts/ACCOUNT_ID \
  -H "Authorization: Bearer TOKEN"
```

A server that follows the final redirect itself, rather than a browser, can send `Accept: application/json` on that request to get the same result as JSON when there is no return URL.

## Step 4: Post to the account

Use the stored ID as `accountId` on `POST /api/v1/posts`, which needs the `posts:write` scope. Leave out `scheduledAt` to publish at once.

Publish a text post

```
curl -X POST https://socialcannon.app/api/v1/posts \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "ACCOUNT_ID",
    "content": "Our spring timetable is out. Book a class from today."
  }'
```

Instagram and TikTok need an image or video in every post, and YouTube needs a video. The [API reference](https://socialcannon.app/docs.md) lists each network’s rules, scheduling and media uploads, and [Scheduling posts with one REST API](https://socialcannon.app/guides/schedule-social-media-posts-api.md) walks through scheduled posts.

## Reconnecting an expired account

Social networks withdraw access from time to time, for example after a password change. SocialCannon checks connections every day, and `GET /api/v1/accounts` reports the result on each account:

An account that needs reconnecting

```
{
  "id": "ACCOUNT_ID",
  "platform": "linkedin",
  "tokenHealth": "expired",
  "lastFailureReason": "..."
}
```

`tokenHealth` is `healthy`, `warning`, `expired` or `unknown`. When it is `expired`, stop posting to that account and ask its owner to connect it again: create a new connect link for the same platform and send them through Step 2.

For Facebook and Instagram, pass the existing ID as `accountId` on the connect-token request. The return then carries `connect_intent=reconnect`. `accountId` is accepted only for Facebook and Instagram, and only for an account of that platform in your workspace.

On the other networks, connecting the same social account again updates the existing record with fresh access, so your stored account ID keeps working.

## Plan rules that affect connections

- Every account connected through your credentials is in your workspace and counts towards your plan. When the plan is full, a new account is refused: the person returns with an error and it is not connected. Only a new account, or one that is no longer active in the workspace, uses an account slot when it is saved; reconnecting an account that is still active uses none and is allowed even on a full plan. A Facebook or Instagram link also needs one free account slot when the flow starts, unless you pass the active account’s `accountId` on the connect-token request to reconnect it. If the person then picks more new Pages or accounts than there are free slots, the ones saved first stay connected and the rest are not connected.
- On Free, a social account can be active in one workspace only, and a Facebook login can back accounts in one workspace only. Connecting one that is already in use in another SocialCannon workspace is refused.
- X needs a paid plan.

Free is useful for trying the flow with your own account. A product whose users connect their own accounts needs a paid plan.

## Agencies: keeping clients apart

All the accounts you connect are in one workspace, and your API credentials can post to any of them. Keep the separation in your own system: record which client each connect link was created for, store each returned account ID against that client, and check that an account belongs to the client before you post to it. Ask each client to connect their accounts themselves, so that they approve access on the network directly and never share a password with you.

## Frequently asked questions

**Do my users need their own SocialCannon account?**

No. Your backend creates each connect link with your own API credentials. The account owner only signs in to the social network and approves access. The account is then connected to your SocialCannon workspace, counts towards your plan, and your backend posts to it with its account ID.

**Can the connect screen show my own brand?**

No. SocialCannon has no branded connect page. The connect link goes to the social network's own consent screen, which names SocialCannon's app, and then back to your app; Bluesky first asks for the handle, and Facebook and Instagram can show a SocialCannon page to choose Pages or accounts. Tell your users before they start that they will be asked to approve SocialCannon.

**Which return URLs can I use?**

A URL on one of your return origins. Register up to 10 exact origins, such as https://app.example.com, in Settings → API Keys → Return URLs or with PUT /api/v1/accounts/connect-return-origins. A subdomain or another port needs its own entry. Any other absolute redirectTo is refused with 400 CONNECT_REDIRECT_NOT_ALLOWED and no link is created.

**Can I build this on the Free plan?**

You can try the flow, but a new Free workspace allows one connected account for the whole workspace, a social account or Facebook login that is already active in another workspace cannot be connected, and X needs a paid plan. A product whose users connect their own accounts needs a paid plan.

**How do I keep an agency's clients apart?**

Every account connected with your credentials is in the same workspace, so keep the separation in your own records: note which client each connect link was created for, and store each returned account ID against that client. Only post to an account ID that belongs to the client you are posting for.
