Skip to Content

Connecting accounts

Send your users through a connect link. Postkey runs OAuth and keeps tokens fresh.

Your users connect their own social accounts. You never see passwords or refresh tokens. You only store account ids.

How it works

  1. Optional: create a profile for the customer.
  2. Call GET /v1/connect/{platform} and get back a url.
  3. Redirect your user to url. They sign in on the network and approve access.
  4. Postkey exchanges the code for tokens, stores them encrypted and refreshes them.
  5. The user lands on your redirectUri.
  6. Call GET /v1/connect/integrations to get the new account id. Post with it as accountId.

Get a connect URL

curl "https://api.postkey.dev/v1/connect/linkedin?profileId=prof_acme&redirectUri=https%3A%2F%2Fyourapp.com%2Fconnected&cancelRedirectUri=https%3A%2F%2Fyourapp.com%2Fcancelled" \
  -H "x-access-key: $POSTKEY_API_KEY"
Response
{ "url": "https://www.linkedin.com/oauth/v2/authorization?client_id=…&state=…" }

{platform} is one of twitter, instagram, facebook, tiktok, linkedin, youtube, pinterest or googlebusiness.

All query parameters are optional:

ParameterWhat it does
profileIdPut the new account in this profile. Without it, the account goes to Default.
redirectUriWhere the user lands when they finish. URL-encode it.
cancelRedirectUriWhere the user lands if they cancel or deny access. Falls back to redirectUri.
appIdConnect through your own OAuth app instead of ours. See Apps.
headlesstrue lets you build the page and location picker yourself. See below.
reconnectAccountIdRe-authorize an existing account. Its id and posts stay the same.
loginMethodInstagram only: instagram_login or facebook_login.

Whose app your users see

Ours, by default. Your users see Postkey on the network's consent screen. You don't need a developer account or an app review on any network.

Want your own name on that screen? Register your own OAuth app and pass appId. See Apps.

Choosing pages and locations

Some networks let one login manage many accounts: LinkedIn (personal profile and company pages), Facebook (Pages), Instagram through Facebook Login, and Google Business (locations).

Default: Postkey shows a simple screen where the user ticks the pages or locations to connect. Then they go to your redirectUri.

Headless: pass headless=true and build that screen yourself. Postkey sends the user back with a short-lived token:

Redirect your page receives
https://yourapp.com/connected?status=selection_required&platform=linkedin&selectionToken=sel_9Kf2…

Then read the choices and save the ones the user picks:

CallWhat it does
GET /v1/connect/{platform}/selection/{token}List the pages or locations the user can connect.
POST /v1/connect/{platform}/selection/{token}Save the ones they picked. Each becomes an account.

Headless selection works for linkedin, facebook, instagram and googlebusiness. How long a selection token lasts: details before launch.

List and manage accounts

curl "https://api.postkey.dev/v1/connect/integrations?profileId=prof_acme&platform=linkedin" \
  -H "x-access-key: $POSTKEY_API_KEY"

Filters: platform, profileId (use null for Default), q (search name or username), limit (up to 100), offset, sortBy (createdAt or name) and sort.

CallWhat it does
GET /v1/connect/integrations/{id}One account, with its authStatus.
PATCH /v1/connect/integrations/{id}Move it to another profile.
DELETE /v1/connect/integrations/{id}Disconnect it.

Connected accounts are unlimited on every plan.

Reconnecting

Tokens sometimes stop working: the user changed their password, removed access, or the network expired the grant. Postkey then sets authStatus to reauthorization_required and sends an account.reauthorization_required webhook.

Send the user through a new connect link with reconnectAccountId set to the account id. The id stays the same, so your stored ids and past posts keep working.

On this page