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.

NetworkStart withHow it connects
BlueskyPOST /v1/connect/blueskyOne call, with a handle and an app password
XPOST /v1/connect/xA sign-in link
InstagramPOST /v1/connect/instagramA sign-in, then pick the accounts
ThreadsPOST /v1/connect/threadsA sign-in, then pick the accounts
Facebook PagesPOST /v1/connect/facebookA sign-in, then pick the Pages
TikTokPOST /v1/connect/tiktokA sign-in that gives one account
YouTubePOST /v1/connect/youtubeA sign-in, then pick the channels
PinterestPOST /v1/connect/pinterestA sign-in that gives one account
LinkedInPOST /v1/connect/linkedinA sign-in, then pick the profile and pages
TelegramPOST /v1/connect/telegramPostsure's bot, added to a channel or group
DiscordPOST /v1/connect/discordPostsure'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"}'

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:

ErrorWhat happened
app_password_requiredThe password is not an app password. Postsure never takes the main password.
bluesky_handle_not_foundNo Bluesky account has this handle or DID.
bluesky_login_failedBluesky did not accept the app password.
bluesky_account_unavailableThe account is deactivated, taken down or suspended.
rate_limitedBluesky 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"}'

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:

ErrorWhat happened
access_deniedYour user pressed Cancel on X.
invalid_stateThe link expired.
x_connect_failedX 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:

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.

  1. 1Start the sign-in

    The answer has a connect_id and a url. Send your user to the url. 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"}'

    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_url with connect_id added. When it failed, it also has error and error_description. When one account was connected at once, it also has account_id. Without redirect_url, the browser shows the connect as JSON.

  2. 2Follow the connect

    Get the connect by its id. When the sign-in gave several Pages, its status is accounts_found, and candidates lists 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"

    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, until expires_at.
    connected
    Done. The new accounts are in account_ids.
    failed
    Nothing was connected. reason says 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.

  3. 3Pick the accounts

    Send the id of each candidate to connect, 1 to 25 of them. Each one becomes an account in your workspace, and the connect says connected.

    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"]}'

    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 in candidates is refused with unknown_candidate, and nothing is made. After the hour, a pick is refused with connect_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.

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

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"}

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

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

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

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_ids to post. It never changes, also after a reconnect.
network
The network, such as x, bluesky or telegram.
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, username is its name. A TikTok account's username is 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 active accounts can post.
needs_reconnect
The network refused the account. status_reason says 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_reason names 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.removed event.

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

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

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

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:

NetworkHow it reconnects
TelegramYour 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.
DiscordYour 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.
BlueskyCall 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

curl -X DELETE https://api.postsure.dev/v1/accounts/<account id> \  -H "Authorization: Bearer $POSTSURE_KEY"

What happens on the network depends on the network:

NetworkWhat happens
Instagram, Threads, Facebook, TikTok, YouTube, Pinterest, LinkedInPostsure ends the sign-in it used for the account, unless another workspace has connected that user since.
BlueskyPostsure ends the session. The app password stays: delete it in Bluesky (Settings, Privacy and security, App passwords).
XPostsure 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).
TelegramPostsure's bot stays in the chat. Remove it there if you want.
DiscordPostsure'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.

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.