Docs menu

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 connect

Start 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": "…" }
Fields of the connect call
FieldWhat it does
platformRequired. The platform name, for example instagram, twitter or google.
brand_idThe 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_uriWhere the person lands afterwards. It must be in the workspace's allowed redirect URIs (validation.redirect_uri_not_whitelisted otherwise).
stateYour own value, up to 512 characters, returned on the redirect.
permissionsLimit what the account may be used for, such as posts.write or comments.read. Leave out for every permission.
metadataCredentials for platforms without OAuth, and per-platform choices (connection_type, app_id, auth_factor_token).
onboardingWhatsApp 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

Redirect parameters
ParameterValue
statussuccess, selection_required or error.
account_id, brand_idOn success with one account. Several accounts send account_ids and brand_ids as comma lists.
connection_idOn selection_required: call the pending endpoints with it.
error, error_descriptionOn error: a code from the list below and a sentence for the person.
platform, stateThe 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 answers 409 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.updated event with change permissions_reduced is 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

Metadata fields of credential platforms
Platformmetadata
blueskyhandle 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.
telegrambot_token, and chat (the channel or group's @username or id) to post there. A token alone connects an inbox-only bot.
app_store_connectkey_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_type profile or organization limits the choice. linkedin_page is not a platform name: use linkedin.
  • TikTok: only creator connections. metadata.connection_type business answers 400 validation.field_invalid.
  • WhatsApp: onboarding is cloud_api (the number is used only through the API) or business_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:

Permissions added since launch
PlatformNew permissionsUnlocks
Facebookbusiness_management, public_profilePages owned through a Business Portfolio.
Google Businessopenid, email, profileThe login's email.
Xlike.write, tweet.moderate.writeLikes and hiding replies.
YouTubeyoutube.force-ssl onlyComments and video edits with one scope.
TikTokuser.info.profile, user.info.stats, video.listAnalytics.
LinkedIn*_feed scopesComments and reactions on Pages.
Threads, InstagramInsights permissionsAnalytics.

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.

Connection error codes
CodeMeaning
account.already_linkedThe brand already has an account on this platform, or lock_accounts_to_brand stops a move.
billing.brands_limitNo brand_id, and the plan has no room for a new brand.
platform.facebook.no_pagesThe Facebook login manages no usable Page.
platform.facebook.no_assignable_pagesEvery Page of an invited login already belongs to another brand.
platform.linkedin.no_pagesNo company Page on the LinkedIn login (connection_type organization).
platform.google.no_locationsThe Google login manages no Business Profile location.
platform.google.insufficient_scopeThe Business Profile permission was not ticked on Google's consent screen.
platform.youtube.no_channelsThe Google account has no YouTube channel.
platform.<name>.no_accountsThe sign-in returned nothing to connect.
whatsapp.no_wabaNo WhatsApp Business Account was shared.
whatsapp.no_phone_numberThe WhatsApp Business Account has no phone number.
byok.credentials_invalidThe platform refused the app keys (X: the workspace's own keys).
byok.app_access_deniedX refused the workspace's app access to its API.
byok.credentials_missingNo developer app keys for this platform on the server or in the workspace.
exchange_failedThe platform did not accept the sign-in code. Start again.
internal_errorThe connection failed on our side. Start again.
validation.redirect_uri_not_whitelistedThe redirect_uri is not allowed for this workspace.
the platform's own errorWhen 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, including permissions_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.