Pogton
Docs Menu

Headless connect

Connect your users' social accounts without the hosted connect page: start OAuth from your app, then list and select Facebook pages, LinkedIn organizations and other accounts through the API.

With connect links your users pick their accounts on Pogton's hosted page. Headless connect lets you build that screen yourself: you start OAuth for one platform, the user signs in, and your backend gets a short-lived connect session to list the pages, channels or business accounts and connect the ones the user picks in your UI.

Pogton still handles OAuth, token storage and refresh. Your users only see the platform's consent screen and your app.

1. Start OAuth

curl -X POST https://pogton.com/api/v1/connect/authorize \
  -H "Authorization: Bearer pk_3f9a..." \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "user_123",
    "platform": "facebook",
    "redirect_url": "https://app.example.com/social/connected"
  }'
{
  "authorization_url": "https://pogton.com/api/oauth/facebook?org=your-org&token=eyJ1c2VyX2lkIjoi...",
  "expires_at": "2026-10-21T09:15:00.000Z",
  "user_id": "user_123",
  "platform": "facebook",
  "redirect_url": "https://app.example.com/social/connected"
}
FieldTypeRequiredDescription
user_idstringYesYour ID for the user. Created now if new.
platformstringYesAn OAuth platform: twitter, linkedin, instagram, facebook, tiktok, youtube, pinterest, threads, google_business.
redirect_urlstringYesYour page that receives the user after OAuth. HTTPS, or http://localhost for development.
account_idstringNoReconnect this account. It must belong to user_id and platform.
expires_inintegerNoSeconds authorization_url stays valid: 60 to 3600. Default 900.
metadataobjectNoStored on the user.

Redirect the user's browser to authorization_url. It sends them on to the platform's consent screen. The platform must be enabled for your connect page (Dashboard → Connect → Page), otherwise the API returns 403 platform_not_enabled. If you added your own OAuth app, its name is on the consent screen.

2. Receive the user

After the user signs in, Pogton sends them to your redirect_url with:

Query parameterMeaning
connect_sessionToken for the next step. Valid for 10 minutes.
platformThe platform the user signed in to.
https://app.example.com/social/connected?connect_session=pcs_eyJzaWQiOi...&platform=facebook

Platforms where a login is a single account (X, TikTok, Threads) skip this: the account is connected right away and the user lands on redirect_url?connected=<platform>, as with connect links. Handle both, and use the account.connected webhook or GET /accounts to see the new account.

3. List the accounts

Pass the token from your backend, with your API key:

curl https://pogton.com/api/v1/connect/sessions/pcs_eyJzaWQiOi... \
  -H "Authorization: Bearer pk_3f9a..."
{
  "user_id": "user_123",
  "platform": "facebook",
  "platform_user_id": "10223344556677",
  "platform_username": "Jane Doe",
  "expires_at": "2026-10-21T09:10:00.000Z",
  "accounts": [
    { "id": "1029384756", "name": "Jane's Bakery", "type": "page", "avatar_url": "https://…", "already_connected": false },
    { "id": "5647382910", "name": "Jane's Blog", "type": "page", "avatar_url": null, "already_connected": true }
  ]
}

Show these in your own picker.

4. Connect the selected accounts

curl -X POST https://pogton.com/api/v1/connect/sessions/pcs_eyJzaWQiOi.../select \
  -H "Authorization: Bearer pk_3f9a..." \
  -H "Content-Type: application/json" \
  -d '{ "account_ids": ["1029384756"] }'
{
  "user_id": "user_123",
  "platform": "facebook",
  "data": [
    { "id": "j97fk2m8q4r1t6v3w8x0y5z2a7b4c9ed", "platform": "facebook", "type": "page", "name": "Jane's Bakery", "status": "active", "...": "…" }
  ]
}

data holds the connected accounts; publish with their id. Pogton sends account.connected for each. Accounts with already_connected: true can be selected again: they get the fresh tokens and keep their ID.

If the user cancels on the consent screen, the platform's error is shown on a Pogton page rather than sent to redirect_url; offer a retry in your app if no redirect arrives.

Security

  • The connect_session token is signed by Pogton, names your organization, the user and the platform, and expires 10 minutes after OAuth. Only an API key of your organization can use it.
  • A session can be selected once. A second select returns 404 connect_session_not_found; start again with /connect/authorize. Send an Idempotency-Key to retry a select safely after a network error.
  • IDs in account_ids that aren't in the session return 422 unknown_account, and the session stays usable.
  • The hosted select page refuses headless sessions, so the tokens can only be completed through your backend.
  • authorization_url is signed with the API key that created it, like a connect link. Revoking the key invalidates it.

MCP

The same flow is available to AI assistants through the MCP server: start_headless_connect, get_connect_session and select_connect_accounts.