Connect
The connect flow lets your customer authorize their Instagram, Facebook, TikTok, YouTube, X, or Bluesky account from your application. They never see an Adeli dashboard, and you never handle a provider token.
Before starting, an organization owner or admin registers the application's
exact client callback under Settings → OAuth. The request's redirectUrl
must match that URI. This client return is separate from the provider callback
Adeli configures with each social platform. See OAuth setup.
How it works
- Your server calls
POST /api/v1/profiles/:profileId/connectand gets back anauthUrlplus a session id. - You send your customer's browser to
authUrl. They authorize with the provider directly. - The provider returns to Adeli, which exchanges the code server-side and stores the token.
- Adeli sends the browser back to your
redirectUrlwith the session id and status in the query string. - Your server polls the session until it reaches a terminal state.
Open authUrl in the customer's browser
Do not fetch it from your backend. It is an authorization page that requires a human to grant consent; requesting it server-side will not produce a connection.
The session is valid for ten minutes and its OAuth state can be consumed once. A callback that arrives late, twice, or with a tampered state is rejected without re-exchanging anything with the provider.
For the full internal sequence, see the repository's
docs/nested-oauth-connect-flow.md.
Endpoints
/api/v1/profiles/{profileId}/connectStart a hosted OAuth connection and get the URL to send your customer to.GETGet connection session/api/v1/profiles/{profileId}/connect/{connectionSessionId}Poll a connection session until it completes, fails, or expires.The browser return
When you supply a redirectUrl, Adeli sends the browser back with these query
parameters:
connectionSessionIduuid- The session to poll.
statusstring- The status at redirect time.
accountIduuid- Present only on success.
workflowIdstring- An internal hint —
connecting-accountsfor Instagram and Facebook,connecting-tiktokfor TikTok,connecting-youtubefor YouTube.
Poll, do not trust the query string
These parameters are convenient for rendering an immediate result in your UI, but they arrive through the customer's browser. Confirm the outcome with a server-side poll before acting on it.
Provider requirements
Instagram needs a professional (Business or Creator) account. With Instagram
Login, Adeli requests instagram_business_basic,
instagram_business_manage_comments, instagram_business_manage_insights,
instagram_business_manage_messages, and instagram_business_content_publish.
Request only what you need
By default an Instagram connect asks for every permission Adeli can use,
including publishing and Insights. If your product only needs some of them,
pass capabilities when you start the connection,
and the consent screen asks only for those. Fewer permissions make customers
more likely to say yes.
| Capability | What it allows | Instagram Login permission | Facebook Login permission |
|---|---|---|---|
profile.read | Account details (always included) | instagram_business_basic | instagram_basic |
feed.read | List posts and stories | instagram_business_basic | instagram_basic |
comments.read, comments.manage | Read, reply to and hide comments | instagram_business_manage_comments | instagram_manage_comments |
inbox.read, inbox.send | Read and send DMs, private replies | instagram_business_manage_messages | instagram_manage_messages |
post.publish | Publish posts, reels and stories | instagram_business_content_publish | instagram_content_publish |
analytics.read, post.analytics | Account and post Insights | instagram_business_manage_insights | instagram_manage_insights |
A Comment to DM product, for example, asks for comments and DMs only:
{
"platform": "instagram",
"redirectUrl": "https://client.example/connect",
"capabilities": ["comments.read", "comments.manage", "inbox.read", "inbox.send"],
"forceReauth": false
}The session's requestedPermissions lists what will be asked. Facebook Login
always adds the three Page permissions it needs to find the account, and on
Facebook Login a narrower request takes effect where Adeli's deployment has the
matching configuration; otherwise it asks for the full set. The account's
capabilities show what it was granted, and a feature it wasn't granted
returns 403 permission_required. To add a permission later, start another
connect with more capabilities: the account and its accountId stay the same.
forceReauth: false lets a customer whose browser is already logged in to
Instagram skip typing their password again.
Instagram login methods
An Instagram professional account can be connected two ways, and a profile's Instagram connection uses exactly one of them:
instagram_login(the default) — your customer signs in on Instagram. Adeli requests theinstagram_business_*permissions above. No Facebook Page is needed.facebook_login— your customer signs in with Facebook and grants the Facebook Page their Instagram account is linked to. The configuration requestsinstagram_basic,instagram_manage_messages,instagram_manage_comments,instagram_content_publish,instagram_manage_insights,pages_show_list,pages_read_engagement, andpages_manage_metadata. They must be able to manage messages on that Page.
Both produce an Instagram account record, and Accounts
reports which method it uses. Both request publishing, comments, and Insights
permissions. API capabilities reflect the token's actual grant, so a customer
who declines one of them gets 403 permission_required from that feature only.
Starting a connect with the method the profile's Instagram does not use
returns 409 auth_method_conflict before your customer reaches Meta. To switch,
disconnect the account first. A usable Facebook user token completes even when Page or Instagram-account discovery is unavailable, several accounts are visible, or the Page lacks a messaging task. Those unresolved fields remain null and affected features return 403 permission_required. auth_method_conflict remains a terminal session error if the profile was connected through the other method while OAuth was open.
Some accounts report a third method, unified_login: they were connected
through Meta's Instagram API with Unified Login, which Adeli has also offered.
They keep working, with a token that does not expire (expiresAt is null).
Starting a connect for such a profile with either method above is never
refused, and replaces the Unified Login connection. Sending
authMethod: "unified_login" starts an Instagram Login connect.
Facebook connects one Page. Adeli uses Facebook Login for Business. Its
configuration requests pages_show_list, pages_read_engagement,
pages_manage_metadata, pages_messaging, pages_manage_posts,
pages_manage_engagement, pages_read_user_content, and read_insights. A
Facebook account does not authorize Ads; that is the separate Meta Ads account
below.
Facebook is the one provider whose connection is not finished when the
authorization callback returns. Authorizing yields a user token, which lists
the Pages your customer manages; a Page still has to be chosen before anything
can be published or read. Until it is, the session stays processing and the
redirect carries status=pending_page_selection. The account exists at that
point and appears in Accounts with
connectionStatus: "pending_page_selection", but every write against it
returns 409 page_not_selected.
Only Pages Meta returns for this configuration are offered. A Page available solely through a Business portfolio may not be connectable through the organic Page flow; Adeli does not broaden this configuration to work around that asset assignment.
Meta Ads (platform: "meta_ads") connects a profile's ads, separately
from its Facebook Page, with its own consent: ads_management,
business_management, pages_manage_ads, leads_retrieval, pages_show_list,
and pages_read_engagement. Like Facebook, it finishes by choosing a Page —
the one ads are created from, which may be the Facebook account's Page or
another — so the session stays processing and the redirect carries
status=pending_page_selection until it is chosen. It gets its own accountId,
used by the Ads endpoints, and is billed as its own connected
account.
TikTok Ads (platform: "tiktok_ads") connects a profile's TikTok
advertiser authorization, separately from the TikTok account used for posting.
It gets its own accountId, used by the Ads endpoints, and is
billed as its own connected account.
LinkedIn Ads (platform: "linkedin_ads") connects a LinkedIn member's
Advertising API grant, separately from the LinkedIn account used for posting.
It requests r_basicprofile, r_ads, rw_ads, r_ads_reporting, and
r_organization_social, reaches every ad account the member has a role on,
gets its own accountId for the Ads endpoints, and is billed
as its own connected account. A member with no role on any ad account fails
with no_ad_accounts.
TikTok connects through TikTok API for Business and requests
user.info.basic, user.info.username, user.info.profile, user.info.stats,
user.account.type, user.insights, video.list, video.insights,
video.publish, video.upload, comment.list, comment.list.manage, and
biz.spark.auth. Both personal accounts and TikTok Business Accounts can
connect. The account identity and video list scopes — the first five and
video.list — are required; without them the connection fails outright. The
rest are stored as granted, and a call that needs a missing one returns
422 connection_expired until the customer reconnects and approves it.
TikTok always shows its consent screen, even to a customer who authorized
before.
TikTok connections made before Adeli moved to TikTok API for Business show
reconnect_required and must be connected again. Reconnecting keeps the same
accountId.
YouTube connects one channel through its own Google sign-in, separate from
Adeli's dashboard sign-in. Adeli requests
https://www.googleapis.com/auth/youtube.force-ssl, which covers uploads,
comments, and moderation, and https://www.googleapis.com/auth/yt-analytics.readonly
for YouTube analytics. Google's account chooser decides
which channel is connected: your customer's own, or one of their Brand Account
channels. Reconnecting the same channel keeps the same accountId; connecting a
different channel on the profile replaces it. Google always shows its consent
screen. A YouTube session that cannot finish fails with one of these
error.code values:
A usable Google access token completes even when the customer unticks a scope, no refresh token is returned, or channel hydration is unavailable. Adeli stores the exact grant and nullable resource fields. Data and Analytics features check their own requirements and return 403 permission_required with restart-OAuth guidance when missing. Google revokes a grant when your customer
removes Adeli from their Google account, and after six months unused; the
account then shows reconnect_required.
X connects one account through Adeli's X app with OAuth 2.0. Adeli
requests tweet.read, tweet.write, users.read, media.write, and
offline.access. They are recommended rather than a callback gate: a usable partial grant is stored, and reads, posts, media, and refresh each enforce their own requirements. Reconnecting the same X account
keeps the same accountId; connecting a different one on the profile replaces
it.
X shows every customer a warning that the app is requesting sensitive permissions and is not affiliated with X. It appears for any app that can post, and cannot be removed, so tell your customers to expect it.
Every X call is billed to you at X's price, including the one read of the
account's profile that connecting makes. On Free, starting a connect
returns 402 x_billing_required before any authUrl exists: X needs a paid
plan.
See X API pricing.
Every provider accepts usable partial consent: the connection is stored with exact scopes and provider-confirmed resources, and a feature needing missing authorization returns 403 permission_required with structured restart-OAuth guidance.
Bluesky
Bluesky connects one account with AT Protocol OAuth. Your customer signs in
on their account's own server: bsky.social for Bluesky-hosted accounts, which
is where a connect without handle starts. A customer who runs their own
server, or uses another provider's, must be connected with handle, or they
won't find their account at bsky.social.
The consent screen names Adeli and asks for broad access to the account,
because the permissions Bluesky offers today are not finer-grained than that.
Adeli uses it to publish, list, and delete posts. It does not read direct
messages. Reconnecting the same account keeps the same accountId; connecting
a different one on the profile replaces it. Bluesky's API is free: connecting
and posting cost nothing beyond the connected account itself.
error.code values beyond the common ones:
invalid_handle- The
handledid not resolve to a Bluesky account. Starting the connect returns400.
A usable Bluesky OAuth session is stored with its exact scope. Feed/post features return 403 permission_required when the recommended generic grant or resolved DID is unavailable.
A customer can revoke Adeli in the Bluesky app's settings at any time; the
account then shows reconnect_required.
Disconnecting
DELETE /api/v1/profiles/:profileId/accounts/:accountId removes Adeli's stored
credentials and cached history. See Accounts.
It never deletes anything on the provider side.