API
Connect accounts
Accounts belong to brands. Your users connect with the platform's own sign-in page, or, for Bluesky, Telegram and App Store Connect, with credentials you pass in the call.
Endpoints
POST /v1/accounts/connect start a connection
GET /v1/accounts/pending/{connection_id} the choices of a pending connection
POST /v1/accounts/pending/{connection_id}/select pick the Page, location or profile
GET /v1/accounts list connected accounts
GET /v1/accounts/{account_id} one account
DELETE /v1/accounts/{account_id} disconnect (204)
POST /v1/invites a link someone else opens to connectStart a connection
curl https://api.zaynstack.com/v1/accounts/connect \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{ "platform": "linkedin", "brand_id": "…", "redirect_uri": "https://yourapp.com/connected", "state": "user-42" }'
→ 202 { "auth_url": "https://www.linkedin.com/oauth/v2/authorization?…", "state": "…", "message": "…" }| Field | What it does |
|---|---|
platform | Required. The platform name, for example instagram, twitter or google. |
brand_id | The brand the account joins. Leave it out and a new brand named after the account is created; that answers 403 billing.brands_limit when the plan has no room for another brand. |
redirect_uri | Where the person lands afterwards. It must be in the workspace's allowed redirect URIs (validation.redirect_uri_not_whitelisted otherwise). |
state | Your own value, up to 512 characters, returned on the redirect. |
permissions | Limit what the account may be used for, such as posts.write or comments.read. Leave out for every permission. |
metadata | Credentials for platforms without OAuth, and per-platform choices (connection_type, app_id, auth_factor_token). |
onboarding | WhatsApp only: cloud_api (default) or business_app. |
OAuth platforms answer 202 with auth_url: send the person there. Credential platforms connect at once and answer 201 with the account.
What comes back on the redirect
| Parameter | Value |
|---|---|
status | success, selection_required or error. |
account_id, brand_id | On success with one account. Several accounts send account_ids and brand_ids as comma lists. |
connection_id | On selection_required: call the pending endpoints with it. |
error, error_description | On error: a code from the list below and a sentence for the person. |
platform, state | The platform name and your own state. |
Brands and accounts
- A brand holds one account per platform. LinkedIn is the exception (a member profile and several company Pages), and each Facebook Page is its own account, so a brand can hold several Pages. A second account answers
409 account.already_linked. - Connecting an account that another brand holds moves it to the new brand, unless the workspace turned on
lock_accounts_to_brand(PATCH /v1/users/me). Then it answers409 account.already_linked. Facebook Pages are assigned per Page instead. - Reconnecting an account keeps its id. When the new sign-in grants fewer permissions, an
account.updatedevent with changepermissions_reducedis sent. - Removing a permission from an account deletes the data that came with it (conversations, imported posts, analytics). Inbound comments, messages and reviews are not stored while the account lacks comments.read, messages.read or reviews.read.
Choosing a Page, location or profile
When a Facebook, Google Business, LinkedIn or WhatsApp sign-in can reach more than one account, nothing is connected yet: you get status=selection_required and a connection_id. Read the choices, then select. Facebook takes several Pages (page_ids); the others take exactly one (platform_account_id). A pending connection expires, and then answers 404 resource.not_found.
GET /v1/accounts/pending/{connection_id}
POST /v1/accounts/pending/{connection_id}/select { "platform_account_id": "accounts/1/locations/2" }Google logins also list their locations at GET /v1/platforms/google/logins/{login_id}/locations (each login shows its login_email); a location is assigned with its id or its full name such as accounts/1/locations/2. A brand that already holds a Google location answers 409 platform.google.brand_has_account.
Platform notes
Credential platforms
| Platform | metadata |
|---|---|
bluesky | handle and password (an app password). Accounts with email two-factor sign-in: the first call answers 400 platform.bluesky.auth_factor_required and Bluesky emails a code; call again with it in auth_factor_token. |
telegram | bot_token, and chat (the channel or group's @username or id) to post there. A token alone connects an inbox-only bot. |
app_store_connect | key_id, issuer_id, private_key (the .p8 text) and app_id. One app per connection: a key that sees several apps and no app_id answers 400 validation.field_required with meta.field app_id and meta.apps, a list of { app_id, name, bundle_id }. |
OAuth platforms
- LinkedIn:
metadata.connection_typeprofileororganizationlimits the choice.linkedin_pageis not a platform name: uselinkedin. - TikTok: only creator connections.
metadata.connection_typebusinessanswers400 validation.field_invalid. - WhatsApp:
onboardingiscloud_api(the number is used only through the API) orbusiness_app(it stays on the WhatsApp Business app). The chat history of a business_app number is not imported. - Instagram: Instagram Login only;
instagram_fb(Instagram through a Facebook Page) is not offered. - YouTube: one channel per sign-in. Connect again for another channel.
Account status and reconnecting
Accounts report status active, reconnect_recommended or token_expired. When a platform stops accepting the token, the account turns token_expired, an account.disconnected event with reconnect_required: true is sent once, and every call that needs it answers 403 account.reconnection_required with meta.id. Start a new connection for the same platform and brand to fix it.
Some features need permissions that were added after early accounts connected. Those accounts keep working but must reconnect to use them:
| Platform | New permissions | Unlocks |
|---|---|---|
| business_management, public_profile | Pages owned through a Business Portfolio. | |
| Google Business | openid, email, profile | The login's email. |
| X | like.write, tweet.moderate.write | Likes and hiding replies. |
| YouTube | youtube.force-ssl only | Comments and video edits with one scope. |
| TikTok | user.info.profile, user.info.stats, video.list | Analytics. |
| *_feed scopes | Comments and reactions on Pages. | |
| Threads, Instagram | Insights permissions | Analytics. |
Disconnect
DELETE /v1/accounts/{account_id} answers 204. It does not send account.disconnected: that event is only for disconnections the platform causes. The platform may keep its own grant; revoke it there to cut access completely.
Connection errors
These come back as error on the redirect, or as the error of the connect call.
| Code | Meaning |
|---|---|
account.already_linked | The brand already has an account on this platform, or lock_accounts_to_brand stops a move. |
billing.brands_limit | No brand_id, and the plan has no room for a new brand. |
platform.facebook.no_pages | The Facebook login manages no usable Page. |
platform.facebook.no_assignable_pages | Every Page of an invited login already belongs to another brand. |
platform.linkedin.no_pages | No company Page on the LinkedIn login (connection_type organization). |
platform.google.no_locations | The Google login manages no Business Profile location. |
platform.google.insufficient_scope | The Business Profile permission was not ticked on Google's consent screen. |
platform.youtube.no_channels | The Google account has no YouTube channel. |
platform.<name>.no_accounts | The sign-in returned nothing to connect. |
whatsapp.no_waba | No WhatsApp Business Account was shared. |
whatsapp.no_phone_number | The WhatsApp Business Account has no phone number. |
byok.credentials_invalid | The platform refused the app keys (X: the workspace's own keys). |
byok.app_access_denied | X refused the workspace's app access to its API. |
byok.credentials_missing | No developer app keys for this platform on the server or in the workspace. |
exchange_failed | The platform did not accept the sign-in code. Start again. |
internal_error | The connection failed on our side. Start again. |
validation.redirect_uri_not_whitelisted | The redirect_uri is not allowed for this workspace. |
the platform's own error | When the person cancels, the platform's code (such as access_denied) is passed on. |
Events
account.connected: an account was connected.account.updated: status or details changed, includingpermissions_reduced.account.disconnected: the platform cut access (reconnect_required: true).page.removed: a reconnected Facebook login no longer reaches a Page.
Per-platform details: Platforms.