On this page
Connect accounts
Each social account your user connects becomes an account in your Postsure workspace. You post to it by its id. How an account connects depends on its network.
The Node.js and Python samples use api and headers from the Quickstart's first step.
Networks
Every connect starts with a POST call for its network.
| Network | Start with | How it connects |
|---|---|---|
| Bluesky | POST /v1/connect/bluesky | One call, with a handle and an app password |
| X | POST /v1/connect/x | A sign-in link |
POST /v1/connect/instagram | A sign-in, then pick the accounts | |
| Threads | POST /v1/connect/threads | A sign-in, then pick the accounts |
| Facebook Pages | POST /v1/connect/facebook | A sign-in, then pick the Pages |
| TikTok | POST /v1/connect/tiktok | A sign-in that gives one account |
| YouTube | POST /v1/connect/youtube | A sign-in, then pick the channels |
POST /v1/connect/pinterest | A sign-in that gives one account | |
POST /v1/connect/linkedin | A sign-in, then pick the profile and pages | |
| Telegram | POST /v1/connect/telegram | Postsure's bot, added to a channel or group |
| Discord | POST /v1/connect/discord | Postsure's bot, added to a server, then pick the channels |
GET /v1/connect/x/callback and GET /v1/connect/discord/callback are pages that X and Discord send your user's browser back to, so you never call them.
Bluesky: one call
Bluesky needs no sign-in page. Your user makes an app password in Bluesky (Settings, Privacy and security, App passwords) and gives it to your app. Send it with the account's handle, with or without the @, or with the account's DID.
curl https://api.postsure.dev/v1/connect/bluesky \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -d '{"handle": "postsure-demo.bsky.social", "app_password": "abcd-efgh-ijkl-mnop"}'const account = await fetch(`${api}/v1/connect/bluesky`, { method: "POST", headers, body: JSON.stringify({ handle: "postsure-demo.bsky.social", app_password: "abcd-efgh-ijkl-mnop" }),}).then((r) => r.json());console.log(account.id, account.status);account = requests.post(f"{api}/v1/connect/bluesky", headers=headers, json={ "handle": "postsure-demo.bsky.social", "app_password": "abcd-efgh-ijkl-mnop",}).json()print(account["id"], account["status"])Example response200
{ "id": "cmhb1s7kq0001l808d6v3m9tw", "network": "bluesky", "provider_user_id": "did:plc:postsuredemo2345abcdefgh", "username": "postsure-demo.bsky.social", "display_name": "Postsure Demo", "status": "active", "status_reason": null}The answer is the account. Its provider_user_id is its DID, which never changes. Postsure keeps the app password encrypted and never sends it back. Connecting the same account again updates the same account and makes it active again.
Postsure turns these down, and message says what to do:
| Error | What happened |
|---|---|
app_password_required | The password is not an app password. Postsure never takes the main password. |
bluesky_handle_not_found | No Bluesky account has this handle or DID. |
bluesky_login_failed | Bluesky did not accept the app password. |
bluesky_account_unavailable | The account is deactivated, taken down or suspended. |
rate_limited | Bluesky allows 30 logins in 5 minutes and 300 a day for an account. Postsure logs in here, and again only when Bluesky refuses to renew the session. It never logs in per post. |
X: a sign-in link
POST /v1/connect/x answers with a url. Send your user there to log in to X. The link works once, for 10 minutes, until expires_at.
curl https://api.postsure.dev/v1/connect/x \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -d '{"redirect_url": "https://myapp.com/x-done?user=42"}'const link = await fetch(`${api}/v1/connect/x`, { method: "POST", headers, body: JSON.stringify({ redirect_url: "https://myapp.com/x-done?user=42" }),}).then((r) => r.json());// Send your user to link.url.console.log(link.url, link.expires_at);link = requests.post(f"{api}/v1/connect/x", headers=headers, json={ "redirect_url": "https://myapp.com/x-done?user=42",}).json()# Send your user to link["url"].print(link["url"], link["expires_at"])Example response200
{ "url": "https://x.com/i/oauth2/authorize?response_type=code&client_id=YOUR_CLIENT_ID&...", "expires_at": "2026-10-18T12:10:00.000Z"}After the login, X sends your user to Postsure, and Postsure saves the account. Postsure never returns its tokens.
Send your user back
With redirect_url, Postsure then sends your user's browser back to your app, with the new account's id added to your query:
https://myapp.com/x-done?user=42&account_id=cmgw7k2xq0003l808x9f2h1ab
When the login did not work, the browser comes back with error and error_description, the reason in plain English, instead:
| Error | What happened |
|---|---|
access_denied | Your user pressed Cancel on X. |
invalid_state | The link expired. |
x_connect_failed | X refused the login, or X had a problem. |
Without redirect_url, your user's browser shows the account as JSON. Your app finds the account in GET /v1/accounts.
A redirect_url must follow these rules, or the call answers 400 redirect_url_not_allowed and nothing is saved:
- Its scheme, host, port and path match one of your workspace's allowed redirect URLs exactly. A trailing
/counts. Add your allowed redirect URLs at [REDIRECT URL PAGE]. - It starts with
https://. Onlylocalhost,127.0.0.1and[::1]may usehttp://. - It has no
#fragment. - Its query has no
account_id,errororerror_description, and for a sign-in network or Discord, noconnect_id: Postsure adds them. The rest of your query is kept.
The sign-in networks and Discord take redirect_url too, with the same rules and the same allowed list.
Sign in, then pick
Instagram, Threads, Facebook Pages, TikTok, YouTube, Pinterest and LinkedIn connect through a sign-in on the network. One sign-in can give several accounts, such as the Pages your user manages. Your app then picks the ones to connect. These networks all use the same calls. Here is the full flow for Facebook Pages.
1Start the sign-in
The answer has a
connect_idand aurl. Send your user to theurl. It works once, for 10 minutes. From the moment your user opens it, they have 10 minutes to sign in.curl https://api.postsure.dev/v1/connect/facebook \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -d '{"redirect_url": "https://myapp.com/facebook-done?user=42"}'const start = await fetch(`${api}/v1/connect/facebook`, { method: "POST", headers, body: JSON.stringify({ redirect_url: "https://myapp.com/facebook-done?user=42" }),}).then((r) => r.json());// Send your user to start.url.console.log(start.connect_id, start.url);start = requests.post(f"{api}/v1/connect/facebook", headers=headers, json={ "redirect_url": "https://myapp.com/facebook-done?user=42",}).json()# Send your user to start["url"].print(start["connect_id"], start["url"])Example response200
{ "connect_id": "cmh4f1k7p0001l808v4n6q2fb", "url": "https://app.postsure.dev/v1/connect/start/EXAMPLE_START_TOKEN", "expires_at": "2026-11-03T12:10:00.000Z"}Your user signs in with Facebook and allows the Pages they manage. Then the browser comes back to your
redirect_urlwithconnect_idadded. When it failed, it also haserroranderror_description. When one account was connected at once, it also hasaccount_id. Withoutredirect_url, the browser shows the connect as JSON.2Follow the connect
Get the connect by its id. When the sign-in gave several Pages, its status is
accounts_found, andcandidateslists them. Show them to your user, so they can choose.curl https://api.postsure.dev/v1/connect/facebook/<connect id> \ -H "Authorization: Bearer $POSTSURE_KEY"const connect = await fetch(`${api}/v1/connect/facebook/${start.connect_id}`, { headers }).then((r) => r.json());console.log(connect.status, connect.candidates);connect_id = start["connect_id"]connect = requests.get(f"{api}/v1/connect/facebook/{connect_id}", headers=headers).json()print(connect["status"], connect["candidates"])Example response200
{ "connect_id": "cmh4f1k7p0001l808v4n6q2fb", "status": "accounts_found", "candidates": [ { "id": "100000000000001", "username": "Corner Bakery", "display_name": "Corner Bakery", "avatar_url": null }, { "id": "100000000000002", "username": "Corner Bakery Events", "display_name": "Corner Bakery Events", "avatar_url": null } ], "account_ids": [], "reason": null, "expires_at": "2026-11-03T13:06:00.000Z"}A connect has one of these statuses:
pending- The link was not opened yet.
signing_in- Your user is signing in.
accounts_found- The sign-in gave several accounts, listed in
candidates. Pick some within the hour, untilexpires_at. connected- Done. The new accounts are in
account_ids. failed- Nothing was connected.
reasonsays why, for example that your user did not allow Postsure. expired- The time ran out. Start again with a new connect.
A connect stays readable for a day after it expired.
3Pick the accounts
Send the
idof each candidate to connect, 1 to 25 of them. Each one becomes an account in your workspace, and the connect saysconnected.curl https://api.postsure.dev/v1/connect/facebook/<connect id>/accounts \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -d '{"candidate_ids": ["100000000000001"]}'const picked = await fetch(`${api}/v1/connect/facebook/${start.connect_id}/accounts`, { method: "POST", headers, // The Pages your user chose. Here, the first one. body: JSON.stringify({ candidate_ids: [connect.candidates[0].id] }),}).then((r) => r.json());console.log(picked.status, picked.account_ids);picked = requests.post(f"{api}/v1/connect/facebook/{connect_id}/accounts", headers=headers, json={ # The Pages your user chose. Here, the first one. "candidate_ids": [connect["candidates"][0]["id"]],}).json()print(picked["status"], picked["account_ids"])Example response200
{ "connect_id": "cmh4f1k7p0001l808v4n6q2fb", "status": "connected", "candidates": [ { "id": "100000000000001", "username": "Corner Bakery", "display_name": "Corner Bakery", "avatar_url": null }, { "id": "100000000000002", "username": "Corner Bakery Events", "display_name": "Corner Bakery Events", "avatar_url": null } ], "account_ids": [ "cmh4f2m9r0002l808t5w8z3fb" ], "reason": null, "expires_at": "2026-11-03T13:06:00.000Z"}The Pages you do not pick are not saved. You can pick more until
expires_at. An id that is not incandidatesis refused withunknown_candidate, and nothing is made. After the hour, a pick is refused withconnect_expired.
What each network gives
The other networks use the same three calls: change facebook in the path to the network's name. When a sign-in gives just one account, it is connected at once, with nothing to pick.
| Network | The three calls, and what one account is |
|---|---|
POST / GET / POST / A Business or Creator account. When the sign-in gives more than one, you pick them. | |
| Threads | POST / GET / POST / A Threads profile. When the sign-in gives more than one, you pick them. |
| Facebook Pages | POST / GET / POST / A Page, never a personal profile or a group. You pick the Pages: up to 25 are listed per sign-in. |
| TikTok | POST / GET / POST / One TikTok account. The sign-in connects it at once, so there is nothing to pick. The third call only picks it again. |
| YouTube | POST / GET / POST / A channel. When the Google sign-in has more than one, you pick them. |
POST / GET / POST / One Pinterest account. The sign-in connects it at once, so there is nothing to pick. The third call only picks it again. | |
POST / GET / POST / A profile or a company page. The sign-in gives the member's profile, and the pages where they are a super admin or content admin. You pick them: up to 25 are listed per sign-in. |
- Instagram's own login refuses a personal account. Your user switches it to a professional account in the Instagram app, then connects again.
- A sign-in with nothing to connect fails, and
reasonsays what to do. For example: "This Facebook sign-in gave no Pages. Postsure posts to Facebook Pages only: make a Page, or ask its admin to give you access, then connect again." - These networks connect an account to one Postsure workspace at a time. An account that another workspace has is not listed, or is refused with
account_already_connected.
Telegram and Discord: a bot
Postsure posts to Telegram and Discord with its own bot, so there is no login. Your user adds the bot to their chat or server. The account has no token.
Telegram
A Telegram account is one channel or one group. POST /v1/connect/telegram answers with a one-time code, as the command your user sends in the chat, and two links that add the bot.
curl -X POST https://api.postsure.dev/v1/connect/telegram \ -H "Authorization: Bearer $POSTSURE_KEY"Example response200
{ "connect_id": "cmh2c3q1d0008l808f0b7x2mn", "command": "/connect@PostsureBot Xq7kP2mZr9TbW4yNc8LdVg", "bot_username": "PostsureBot", "add_to_group_url": "https://t.me/PostsureBot?startgroup=Xq7kP2mZr9TbW4yNc8LdVg&admin=delete_messages", "add_to_channel_url": "https://t.me/PostsureBot?startchannel&admin=post_messages+delete_messages", "expires_at": "2026-10-24T12:15:00.000Z"}- A group:
add_to_group_urladds the bot to the group as an admin, and Telegram sends the code by itself. The command must come from an admin of the group. - A channel:
add_to_channel_urladds the bot as an admin that may post. Then your user sendscommandin the channel.
The code works once, for 15 minutes. It is in command, so show it only to that user. Follow the connect with GET /v1/connect/telegram/{connect_id}. When it says connected, the chat is the account account_id.
The bot checks that it can post first. In a channel it must be an admin with the Post messages right; in a group, an admin. When it cannot post yet, the code still works, and reason says what to fix in Telegram. Your user fixes it and sends the command again:
GET /v1/connect/telegram/{connect_id}
{ "connect_id": "cmh2c3q1d0008l808f0b7x2mn", "status": "pending", "account_id": null, "reason": "Make @PostsureBot an admin of Postsure Team.", "expires_at": "2026-10-24T12:15:00.000Z"}Discord
A Discord account is one channel of a server. Your user adds Postsure's bot to a server they manage, then you pick the server's channels. Start with POST /v1/connect/discord, with an optional redirect_url:
curl https://api.postsure.dev/v1/connect/discord \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -d '{"redirect_url": "https://myapp.com/discord-done?user=42"}'Example response200
{ "connect_id": "cmh0dc5qa0001l808k3n2w7xe", "authorize_url": "https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&...", "expires_at": "2026-10-30T12:15:00.000Z"}Send your user to authorize_url. It works once, for 15 minutes. There they pick the server and allow the bot. The bot asks to view channels, send messages, embed links, attach files, read message history, mention everyone, create public threads and send messages in threads. Postsure pings @everyone or @here only when a post allows it.
Then GET /v1/connect/discord/{connect_id} says server_added, with server_id and server_name. List the server's channels where the bot can post:
curl https://api.postsure.dev/v1/connect/discord/<connect id>/channels \ -H "Authorization: Bearer $POSTSURE_KEY"Example response200
{ "server_id": "1300000000000000001", "server_name": "Postsure Team", "data": [ { "id": "1300000000000000010", "name": "general", "type": "text" }, { "id": "1300000000000000011", "name": "announcements", "type": "announcement" } ]}Discord denies Send Messages in an announcement channel by default, also to the bot, so it is not listed. To list it, a server admin allows Send Messages for the bot's role in that channel's permissions.
Send the channels to post to, 1 to 100 of them, within 1 hour after the bot was added. Each one becomes an account:
curl https://api.postsure.dev/v1/connect/discord/<connect id>/channels \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -d '{"channel_ids": ["1300000000000000010", "1300000000000000011"]}'Example response200
{ "connect_id": "cmh0dc5qa0001l808k3n2w7xe", "status": "connected", "server_id": "1300000000000000001", "server_name": "Postsure Team", "account_ids": [ "cmh0dg7tb0002l808p4r9v1xk", "cmh0dg7tb0003l808w2c5n8hz" ], "reason": null, "expires_at": "2026-10-30T13:02:00.000Z"}The account
Every connect makes the same kind of object. This X account must be reconnected:
An account
{ "id": "cmgw7m4ta0005l808q3d7c2ze", "network": "x", "provider_user_id": "1849204858203947099", "username": "postsure_news", "display_name": "Postsure News", "avatar_url": null, "status": "needs_reconnect", "status_reason": "X no longer accepts this connection. The user may have removed the app's access in X. Reconnect the account.", "checked_at": "2026-10-18T15:04:12.381Z", "created_at": "2026-10-18T10:12:31.204Z"}id- Postsure's id for the account. Send it in
account_idsto post. It never changes, also after a reconnect. network- The network, such as
x,blueskyortelegram. provider_user_id- The account's id on the network. For example: the chat id on Telegram, the channel id on Discord and YouTube, the Page id on Facebook, the DID on Bluesky.
username,display_name- The account's names on the network. For a Facebook Page or a YouTube channel,
usernameis its name. A TikTok account'susernameis empty until a post's result names its TikTok handle. status,status_reason- If the account can post, and why not, in plain English.
checked_at- When the network last gave a clear answer about the account.
Some fields are for one network only, such as chat_type (Telegram and Discord), server_id (Discord) and email_confirmed (Bluesky). Tokens are never returned. The API reference has every field.
Statuses
active- The account works. Only
activeaccounts can post. needs_reconnect- The network refused the account.
status_reasonsays why and how to fix it. LinkedIn and TikTok also end a login on their own date (LinkedIn after 1 year). disabled- Postsure turned the account off, and it stays off.
status_reasonnames the account of your workspace to use instead. Today this happens only on Telegram: a group became a supergroup, and your workspace had connected that supergroup already. removed- You removed the account. You see this status only in the
account.removedevent.
List and get accounts
GET /v1/accounts lists every account of your workspace, newest first, with its saved status. It does not ask the networks.
curl https://api.postsure.dev/v1/accounts \ -H "Authorization: Bearer $POSTSURE_KEY"Example response200
{ "data": [ { "id": "cmgw7k2xq0003l808x9f2h1ab", "network": "x", "username": "postsure_demo", "status": "active", "status_reason": null }, { "id": "cmh2c4v8n0009l808k6t1w5pz", "network": "telegram", "username": "postsure_news", "chat_type": "channel", "status": "active", "status_reason": null } ]}GET /v1/accounts/{id} checks an active account with the network first. When the network refuses it, the answer says needs_reconnect, with the reason. A clear answer is kept for 15 minutes, so most reads do not call the network. Send fresh=true to ask the network now, at most once a minute.
curl "https://api.postsure.dev/v1/accounts/<account id>?fresh=true" \ -H "Authorization: Bearer $POSTSURE_KEY"A Telegram or Discord account that needs a reconnect is checked too. Once the bot is back with the rights it needs, the check makes the account active again. On Instagram, Threads, Facebook, TikTok, YouTube, Pinterest and LinkedIn, the check does not see when the owner takes back access on the network. The next post to the account fails or ends unconfirmed.
POST /v1/posts does not check: it uses the saved status. A post to an account that is not active is refused with 409 account_not_active. If you think the status changed, get the account first.
Reconnect an account
POST /v1/accounts/{id}/reconnect starts a new sign-in for an account you have already. Use it for X and for the sign-in networks. It takes the same body as the network's connect call and answers the same way, so your code is the same. For a sign-in network, the answer also has a connect_id: follow it with GET /v1/connect/<network>/{connect_id}.
curl https://api.postsure.dev/v1/accounts/<account id>/reconnect \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -d '{"redirect_url": "https://myapp.com/x-done?user=42"}'Example response200
{ "url": "https://x.com/i/oauth2/authorize?response_type=code&client_id=YOUR_CLIENT_ID&...", "expires_at": "2026-10-18T12:10:00.000Z"}After the sign-in, the account keeps its id, its posts, its scheduled posts and its history. It becomes active. Postsure sends account.active when the account was needs_reconnect or disabled.
Your user must sign in as the account's own user. Another user is refused with wrong_account, and nothing changes. On X the message reads: "You signed in as @other on X, but this account is @name. Sign in as @name." A Facebook sign-in must give the account's own Page. A LinkedIn page needs a member who is still a super admin or content admin of it.
Telegram, Discord and Bluesky do not reconnect this way. They answer 400 reconnect_not_supported, and the message says what to do:
| Network | How it reconnects |
|---|---|
| Telegram | Your user adds the bot back to the chat, with the rights it needs. The account then works again by itself: GET /v1/accounts/{id} shows it. To connect the chat again, send a new code with POST /v1/connect/telegram. |
| Discord | Your user adds Postsure's bot back to the server, with the rights it needs. The account then works again by itself. To connect it again, start with POST /v1/connect/discord and pick the channel again. |
| Bluesky | Call POST /v1/connect/bluesky with the handle and a new app password. It updates the same account. |
Remove an account
DELETE /v1/accounts/{id} removes an account from your workspace. It answers 204 with no body, also when you call it again.
curl -X DELETE https://api.postsure.dev/v1/accounts/<account id> \ -H "Authorization: Bearer $POSTSURE_KEY"- It is gone for the API.
GET /v1/accountsdoes not list it,GET /v1/accounts/{id}answers404, and a new post to it is refused withunknown_account. - Its posts stay.
GET /v1/posts/{id}still reads them, with the same account id. - One event. Postsure sends
account.removed, and no event about the account after it. - A post that is being sent finishes. It is
publishedwhen the network clearly confirms it, otherwiseunconfirmed, and it is not sent again by itself. A post that was waiting to be sent fails with "This account was removed." - Connect it again with a normal connect. In the same workspace, the account comes back under its old id, with its old posts.
What happens on the network depends on the network:
| Network | What happens |
|---|---|
| Instagram, Threads, Facebook, TikTok, YouTube, Pinterest, LinkedIn | Postsure ends the sign-in it used for the account, unless another workspace has connected that user since. |
| Bluesky | Postsure ends the session. The app password stays: delete it in Bluesky (Settings, Privacy and security, App passwords). |
| X | Postsure forgets the tokens. To end Postsure's access in X too, remove the app in X's settings (Security and account access, Apps and sessions). |
| Telegram | Postsure's bot stays in the chat. Remove it there if you want. |
| Discord | Postsure's bot stays in the server, because other channels may use it. Remove it in the server's settings if no channel needs it. |
While a post is using the account, the call answers 503 account_busy: "A post is using this account right now. Try again in a few seconds."
Account events
Postsure sends these events to your webhooks when an account changes. Each one carries the whole account.
account.connectedaccount.needs_reconnectaccount.activeaccount.updatedaccount.disabledaccount.removed
Webhooks says when each one comes, and how to check its signature.
Network helpers
GET /v1/accounts/{id}/discord/mentions?q= helps an editor suggest mentions as its user types. It returns @everyone, @here, the server's roles, and up to 25 members, whose names start with q. Without q, it returns no members. Each comes with the token to put in the text. A token pings only when the post allows it in discord.allowed_mentions (see Send posts).
GET /v1/accounts/{id}/pinterest/boards will list a Pinterest account's boards, each with its id, name and privacy. It is not usable yet: no Pinterest account connected today can list its boards, so it answers 409 boards_not_listable. Send the board id of each pin in pinterest.board_id.
Every call, field and error is in the API reference.