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
- Optional: create a profile for the customer.
- Call
GET /v1/connect/{platform}and get back aurl. - Redirect your user to
url. They sign in on the network and approve access. - Postkey exchanges the code for tokens, stores them encrypted and refreshes them.
- The user lands on your
redirectUri. - Call
GET /v1/connect/integrationsto get the new accountid. Post with it asaccountId.
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"{ "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:
| Parameter | What it does |
|---|---|
profileId | Put the new account in this profile. Without it, the account goes to Default. |
redirectUri | Where the user lands when they finish. URL-encode it. |
cancelRedirectUri | Where the user lands if they cancel or deny access. Falls back to redirectUri. |
appId | Connect through your own OAuth app instead of ours. See Apps. |
headless | true lets you build the page and location picker yourself. See below. |
reconnectAccountId | Re-authorize an existing account. Its id and posts stay the same. |
loginMethod | Instagram 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:
https://yourapp.com/connected?status=selection_required&platform=linkedin&selectionToken=sel_9Kf2…Then read the choices and save the ones the user picks:
| Call | What 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.
| Call | What 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.