On this page
Quickstart
Send your first post with four calls: check your key, connect an account, send the post, and read its receipt.
Before you start
- An API key. It starts with
ps_live_. Get yours in the web app, under Developers → API keys. - A Bluesky account, and an app password for it. Bluesky connects in one call, with no sign-in page, so it is the quickest account to try.
- curl, Node.js 20 or later, or Python 3 with
requests.
Run it
The Node.js and Python samples build on each other: put them in one file, in order. The curl samples need the ids from the answers before them.
1Check your key
Put your key in an environment variable, so it stays out of your code:
export POSTSURE_KEY="ps_live_..."Then list your accounts. Every call sends the key in the
Authorizationheader.curl https://api.postsure.dev/v1/accounts \ -H "Authorization: Bearer $POSTSURE_KEY"const api = "https://api.postsure.dev";const headers = { Authorization: `Bearer ${process.env.POSTSURE_KEY}`, "Content-Type": "application/json",};const accounts = await fetch(`${api}/v1/accounts`, { headers }).then((r) => r.json());console.log(accounts);import os, time, uuidimport requestsapi = "https://api.postsure.dev"headers = {"Authorization": f"Bearer {os.environ['POSTSURE_KEY']}"}accounts = requests.get(f"{api}/v1/accounts", headers=headers).json()print(accounts)Example response200
{ "data": []}A new workspace has no accounts yet. A wrong key gets
401withinvalid_api_key.2Connect an account
In Bluesky, make an app password: Settings, Privacy and security, App passwords. Send it with the account's handle. Use your own handle and app password in place of the ones below.
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"}Keep the
id. You send posts to accounts by their id. Postsure keeps the app password encrypted and never sends it back.Most other networks connect through a sign-in page. For example,
POST /v1/connect/xanswers with aurl. Your user opens it and logs in to X. Connect accounts shows how each network connects.3Send the post
Send the account id and the text. If the call fails or times out, send it again with the same
Idempotency-Key: you get back the post Postsure already saved, not a second one.curl https://api.postsure.dev/v1/posts \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{"account_ids": ["<account id>"], "text": "Hello from Postsure!"}'let post = await fetch(`${api}/v1/posts`, { method: "POST", headers: { ...headers, "Idempotency-Key": crypto.randomUUID() }, body: JSON.stringify({ account_ids: [account.id], text: "Hello from Postsure!" }),}).then((r) => r.json());console.log(post.id, post.status);post = requests.post( f"{api}/v1/posts", headers={**headers, "Idempotency-Key": str(uuid.uuid4())}, json={"account_ids": [account["id"]], "text": "Hello from Postsure!"},).json()print(post["id"], post["status"])Example response202
{ "id": "cmgwb1n6e000bl808v5j0k8ry", "status": "queued", "text": "Hello from Postsure!", "targets": [ { "account_id": "cmhb1s7kq0001l808d6v3m9tw", "account": { "network": "bluesky", "username": "postsure-demo.bsky.social" }, "status": "queued", "url": null } ]}202means the post is saved and in the queue. Postsure posts it in the background, so the answer comes at once.4Read the receipt
Get the post by its id. The Node.js and Python samples ask again every 2 seconds until it is done.
curl https://api.postsure.dev/v1/posts/<post id> \ -H "Authorization: Bearer $POSTSURE_KEY"while (["queued", "publishing"].includes(post.status)) { await new Promise((done) => setTimeout(done, 2000)); post = await fetch(`${api}/v1/posts/${post.id}`, { headers }).then((r) => r.json());}const [target] = post.targets;console.log(target.status, target.url ?? target.error_reason);while post["status"] in ("queued", "publishing"): time.sleep(2) post = requests.get(f"{api}/v1/posts/{post['id']}", headers=headers).json()target = post["targets"][0]print(target["status"], target["url"] or target["error_reason"])Example response200
{ "id": "cmgwb1n6e000bl808v5j0k8ry", "status": "published", "text": "Hello from Postsure!", "targets": [ { "account_id": "cmhb1s7kq0001l808d6v3m9tw", "account": { "network": "bluesky", "username": "postsure-demo.bsky.social" }, "status": "published", "url": "https://bsky.app/profile/did:plc:postsuredemo2345abcdefgh/post/3m5kq2xa7ty2c", "error_category": null, "error_reason": null, "published_at": "2026-11-15T12:00:01.204Z", "attempts": [ { "number": 1, "outcome": "success" } ] } ]}Each account in the post has one target. It has its own
status, the live link inurl, and every try inattempts. In your app, use a webhook instead of asking again and again.
What just happened
- Your key was checked. Every call sends it as
Authorization: Bearer <key>. - A Bluesky account was connected. Postsure logged in once with the app password.
- The post went into the queue.
POST /v1/postsanswered at once with202, and the posting happened in the background. - The receipt was read. It has the live link, or the reason the post is not live.
If it fails
When a network says no, the target says why in plain English, in error_reason. error_category names the kind of error, so your code can decide what to do. This post failed on Bluesky:
curl https://api.postsure.dev/v1/posts/<post id> \ -H "Authorization: Bearer $POSTSURE_KEY"Example response200
{ "id": "cmgwb1n6e000bl808v5j0k8ry", "status": "failed", "targets": [ { "account": { "network": "bluesky", "username": "postsure-demo.bsky.social" }, "status": "failed", "url": null, "error_category": "auth", "error_reason": "Bluesky did not accept the handle or the app password. Reconnect the account with a new app password.", "retry_at": null } ]}Each target ends in one of these four states. Receipts and retries has every status and error category.
- published
- The post is live on that account. Nothing to do. You get
post.published. - waiting
- A try failed for a reason that can pass, like a rate limit or the network being down. Wait. You get
post.waitingwith the reason. - failed
- The network refused the post, or Postsure stopped trying. The reason says which. Fix what the reason names, then send it again.
- unconfirmed
- Postsure sent the post and the network did not answer. It may be live. Check the account before you post again. You get
post.unconfirmed.
A call Postsure turns down at once, such as one with a wrong key, answers with a 4xx status and at least two fields: error, a code for your program, and message, what to do. Here is a Bluesky main password sent in place of an app password. Postsure turns it down before anything goes to Bluesky:
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": "my main password"}'Example response400
{ "error": "app_password_required", "message": "This is not an app password. Postsure never takes your main Bluesky password. Make an app password in Bluesky (Settings, Privacy and security, App passwords) and use it here. An app password looks like xxxx-xxxx-xxxx-xxxx."}Next steps
- Webhooks
- Add your URL with
POST /v1/webhooks. Postsure sends a signed event when a post is done, and when it starts waiting. - Images and video
- Upload them with
POST /v1/media, then send their ids inmedia_ids. - Threads
- Send
thread, with 2 to 25 parts, instead oftext. - Scheduled posts
- Send
publish_atwith a time up to 365 days ahead. - Other networks
- Each network connects in its own way: with one call, a sign-in page, or a bot.
- AI tools
- Postsure is also an MCP server, at
/mcp. It takes the same API key.
Every call, field and error is in the API reference.