If your product posts to social media on behalf of your users, the posting is the easy part. Getting permission is where the time goes. LinkedIn, Meta, TikTok and X each have their own OAuth flow, their own review process and their own idea of what counts as an account. A LinkedIn user can post as themselves or as any company page they admin. A Facebook login can come with a dozen Pages.
This is how the flow works in Postkey.
1. Make a profile for each customer
This step is optional. A profile is a label, usually one per customer of yours. Accounts connected under it stay grouped, which is handy if you're an agency or a multi-tenant app. If you skip it, accounts go into "Default".
curl -X POST https://api.postkey.dev/v1/profiles \
-H "x-access-key: $POSTKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Northwind Bakery" }'2. Ask for a connect link
Choose the network and tell us where to send the user afterwards:
curl "https://api.postkey.dev/v1/connect/linkedin?profileId=prof_123&redirectUri=https://app.example.com/connected" \
-H "x-access-key: $POSTKEY_API_KEY"You get back a url.
3. Send the user to it
The user lands on LinkedIn's own consent screen and approves. We exchange the code for tokens, store them, keep them refreshed, and redirect the user to your redirectUri. If they click cancel instead, they go to cancelRedirectUri, if you set one.
4. Get the account ID
curl "https://api.postkey.dev/v1/connect/integrations?profileId=prof_123" \
-H "x-access-key: $POSTKEY_API_KEY"Each connected account has an id. Pass it as accountId when you publish, and you're done.
Company pages and locations
For LinkedIn company pages, Facebook Pages, Instagram through Facebook and Google Business locations, the user has to choose which ones to connect. By default we show a small picker after the consent screen.
If you'd rather have that picker inside your own app, add headless=true to the connect request. We redirect back with a selectionToken, you fetch the options with it, show them however you like and post back the ones the user picked.
When a token stops working
Users revoke access, change passwords and let tokens lapse. When that happens you get an account.reauthorization_required webhook. Generate a new connect link with reconnectAccountId set to the old account and send it to the user. The account keeps its ID and its post history, so nothing on your side has to change.
Your own OAuth app
By default the consent screen says Postkey, and you don't need developer accounts on any network. If you'd rather your users see your own name there, add your app's credentials in the dashboard and pass its appId when you ask for a connect link.
The full list of query parameters is in the connecting accounts guide.