# Customers, connect links and the connect page

> Index of all OmniSocials docs pages: https://docs.omnisocials.com/llms.txt

A customer is one customer of yours. Its social accounts connect on the connect page, a page we host with your brand. Your server opens that page with a connect link, and the page sends the person back to your product when they are done.

The examples use the sandbox address. For live, use `https://api.omnisocials.com` with a live key.

## Customers

Create one customer per customer of yours, the first time you need it:

```bash
curl -X POST https://sandbox-api.omnisocials.com/connect/v1/customers \
  -H "Authorization: Bearer $OMNISOCIALS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "name": "Harbor Coffee", "external_id": "hc-1042", "metadata": { "plan": "pro" } }'
```

The answer is `{ "id": "cust_…", "external_id": "hc-1042", "name": "Harbor Coffee", … }`.

- Use your own id as `external_id`. Every call can then name the customer as `ext:hc-1042`, and you never need to store `cust_` ids.
- `409 external_id_conflict` means the customer exists already. Read it with `GET /connect/v1/customers/ext:hc-1042`.
- `DELETE /connect/v1/customers/{ref}` removes the customer with its accounts, posts and statistics. `{ref}` is the `cust_…` id or `ext:<your id>`. While one of its posts is publishing, the delete answers `409 customer_publishing`: try again when the post is done. While one of its ads runs or waits for review, it answers `409 customer_ads_running` and lists those ads in `details.running_ads`, because the network would keep spending with nothing left to stop it. Send the delete again with `?pause_running_ads=true` to pause them and delete in one call; the answer lists them in `paused_ads`. An ad the network does not pause stays in the list with `pause_error`, and nothing is deleted.

## Create a connect link

Create a new link on your server each time the person clicks "Connect" in your product, then open its `url`.

```bash
curl -X POST https://sandbox-api.omnisocials.com/connect/v1/customers/ext:hc-1042/connect-links \
  -H "Authorization: Bearer $OMNISOCIALS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "platforms": ["instagram", "facebook", "tiktok"],
    "return_url": "https://app.example.com/settings/social"
  }'
```

The answer is `{ "id": "cl_…", "url": "https://connect.omnisocials.com/c/…", "expires_at": "…" }`.

| Field | Meaning |
|-------|---------|
| `platforms` | The networks the page offers. Leave it out to offer every network you switched on. The names are listed in the [overview](https://docs.omnisocials.com/connect/overview.md#networks) |
| `return_url` | Where the page sends the person when they are done. With a live key, its origin must be on your list in the console under **Settings** |
| `expires_in` | Seconds until the link expires: 600 to 604,800. The default is 3,600 (one hour) |

## Open the link

- **On a phone, open the link in the system browser**, not in a web view. The networks refuse a sign-in inside a web view, and the page checks that one browser finishes the sign-in.
- **In an in-app browser** (the browser inside Instagram, Facebook, TikTok, LinkedIn and similar apps), the page first asks the person to open it in Safari or Chrome, with a button to copy the link.
- **One link per browser at a time.** A second connect link opened in the same browser replaces the first. The first tab then asks the person to open their link again.
- **A link ends at Done.** Before the person presses Done, they can open the link again. After Done, or after `expires_at`, the link no longer opens: create a new one.

## The connect page

- **Your brand.** The page shows your name, logo and colour, and a link to your support page. Set them in the console under **Appearance**. A logo can be PNG, JPEG, WebP or GIF, up to 2 MB.
- **Powered by OmniSocials.** A small "Powered by OmniSocials" link sits under the page. It is on by default; switch it off in the console under **Appearance**.
- **Sign-in screens name OmniSocials.** Each network's own sign-in screen shows OmniSocials, and the page tells the person so.
- **Connected accounts** show with their picture, name and handle.
- **Pages.** After a Facebook or LinkedIn sign-in, the person picks the Facebook Page or the LinkedIn page on the connect page.

## Back in your product

When the person is done, the page sends them to `return_url` with these query parameters:

| Parameter | Meaning |
|-----------|---------|
| `status` | `connected` when this visit connected at least one account that can post now, else `cancelled` |
| `connected` | The networks connected on this visit, for example `instagram,tiktok` |
| `needs_reconnect` | Networks whose account was connected but needs a new sign-in. They are left out of `connected` |
| `customer` | The `cust_…` id |
| `external_id` | Your own id of the customer |
| `connect_link_id` | The `cl_…` id of the link |

Read the accounts again after the return, or wait for the `account.connected` event (see [Events and webhooks](https://docs.omnisocials.com/connect/webhooks.md)).

## The customer's accounts

```bash
curl https://sandbox-api.omnisocials.com/connect/v1/customers/ext:hc-1042/accounts \
  -H "Authorization: Bearer $OMNISOCIALS_KEY"
```

Each account has `platform`, `username`, `display_name`, `picture` and `status`:

| `status` | Meaning | What to do |
|----------|---------|------------|
| `active` | The account posts | Nothing |
| `needs_reconnect` | The network ended the sign-in | Create a new connect link for that network |
| `pick_pending` | The person still has to choose a Facebook Page or a LinkedIn page | Create a new connect link so they can choose |

`GET /v1/accounts` with the customer header lists the same accounts on the posting API. A Facebook account that waits for its Page there carries `pick_pending: true`, and a post to it fails until the Page is chosen.

## Reconnects

A network can end a sign-in. The account's status becomes `needs_reconnect`, and your webhook gets `account.needs_reconnect`. Create a link for that network only:

```json
{ "platforms": ["instagram"], "return_url": "https://app.example.com/settings/social" }
```

A `notification.requested` event can carry a message for your customer with a reconnect link in `data.action_url`. Send it by email, SMS or in your product: we never contact your customers. When the account signs in again, your webhook gets `account.reconnected`.

## Choose the networks

In the console under **Appearance**, switch off the networks you do not want to offer.

- A link without `platforms` leaves the switched-off networks out.
- A link that names one answers `400 network_turned_off`, with `param` set to `platforms`.
- A link made before you switched a network off still shows it.
- Accounts that are already connected keep posting.

## X through your own app

X shows on your connect page only after you add your own X app in the console under **Appearance**, X: its OAuth 2.0 Client ID and Client Secret. The secret is never shown again.

- Your customers sign in to X through your X app, and X bills its API use to you. OmniSocials charges no X credits to a Connect account.
- With the keys of another X app, or without an X app, every customer's X account has to sign in again. A new secret for the same app changes nothing.
