On this page
API basics
What every call to the Postsure API has in common: the address, the key, JSON, errors, safe retries and pages.
Base URL
Every call goes to one host, and every API path starts with /v1: https://api.postsure.dev/v1.
For example, GET /v1/accounts is https://api.postsure.dev/v1/accounts. The MCP server for AI tools is outside /v1, on its own host: https://mcp.postsure.dev/mcp. See MCP server.
Your API key
Send your key in the Authorization header of every call, as Bearer <key>. Keys start with ps_live_. Get yours in the web app, under Developers → API keys.
curl https://api.postsure.dev/v1/accounts \ -H "Authorization: Bearer $POSTSURE_KEY"const res = await fetch("https://api.postsure.dev/v1/accounts", { headers: { Authorization: `Bearer ${process.env.POSTSURE_KEY}` },});console.log(res.status, await res.json());import osimport requestsres = requests.get( "https://api.postsure.dev/v1/accounts", headers={"Authorization": f"Bearer {os.environ['POSTSURE_KEY']}"},)print(res.status_code, res.json())Without a good key, the answer is 401 with one of these errors:
| Error | Message | When |
|---|---|---|
missing_api_key | Send your API key as: Authorization: Bearer <key> | There is no key, or no Bearer before it. |
invalid_api_key | This API key is not valid or was revoked. | The key is wrong, or it was revoked. |
A key belongs to one workspace. Each call sees only that workspace: its accounts, posts, media and webhooks. Keep the key secret, like a password: anyone who has it can post to your accounts.
Make and revoke keys
You make and revoke API keys in the web app, under Developers → API keys.
- Give each key a name, to tell keys apart: 1 to 60 characters, on one line. The spaces around it are taken off. Tabs, line breaks and other hidden characters are refused.
- The key is shown once, when you make it, so copy it then. Postsure keeps only a scrambled copy of it (a hash), so it can never show the key again.
- The list of keys shows only each key's first 12 characters, like
ps_live_Q3vW, so you can find it in your code. - A workspace can make keys only after one of its members has checked their email.
- A revoked key stops at once: every call with it gets
401 invalid_api_keyfrom then on. The AI tools you approved with it are cut off too. It stays in the list, with the time it was revoked. GET,POSTandDELETE /v1/api-keyswork only from the web app's login. An API key gets401 login_required, so a key can never make or revoke keys.
Keys for some accounts
A key can use every account of your workspace, or only some accounts. You choose when you make the key: the web app sends the accounts in limit.account_ids, at most 100. The limit cannot change later, so make a new key instead.
A key for some accounts:
- Sees nothing outside its limit, as if it did not exist:
404 not_foundin a path, and400 unknown_accountorunknown_mediain a body. - Sees and uses only the files it uploaded itself.
- Gives the same limit to an AI tool you approve with it, in every MCP tool.
- Gets
403 key_limitedon the routes for the whole workspace: every/v1/webhooksroute, the AI connections routes, and connecting new accounts. That isPOST /v1/connect/<network>, the pick after a sign-in, and every Telegram and Discord connect route.
Health check
GET /v1/health needs no API key. Use it to check that the API is up.
curl https://api.postsure.dev/v1/healthExample response200
{ "status": "ok"}200 with "status": "ok" means the API is up. 503 with "status": "degraded" means a part of the service it needs is down. The answer also has telegram and discord, the state of Postsure's bots on those networks. They never change status.
JSON and snake_case
- Send bodies as JSON, with the header
Content-Type: application/json. Every answer with a body is JSON too. - Every key is snake_case: in bodies, queries, answers, errors and webhook events. For example
account_ids,error_reasonandretry_at. - Postsure drops a key in another spelling, like
accountIds, before it reads the body. It also drops most keys it does not know. So a post sent withaccountIdsgets400 invalid_request, becauseaccount_idsis missing. - Two places refuse a key they do not know, with
400 invalid_request. Each network's options (liketelegram) refuse an unknown key, and most also refuse a key in camelCase: see Network options. A change to a draft (PATCH /v1/posts/{id}) refuses an unknown snake_case field. A camelCase field there is dropped, as anywhere else. - One field keeps the network's own keys: an attempt's
details. It is the network's answer, exactly as the network sent it. - A body that is not valid JSON gets
400 bad_request: "The request body is not a valid JSON object."
Ids and times
- Ids are strings, like
cmgwb1n6e000bl808v5j0k8ry. You get one when you make something: an account when you connect it, a post when you send it, a file when you upload it. Then you use it in paths and bodies, likeGET /v1/posts/{id}andaccount_ids. - An id from another workspace counts as unknown:
404 not_foundin a path, and400 unknown_accountorunknown_mediain a body. - Times are ISO 8601 strings. Answers give them in UTC, like
2026-10-18T12:00:01.904Z. - A time you send must have a time zone:
2026-11-20T09:00:00Zor2026-11-20T11:00:00+02:00. A time with no zone gets400 invalid_request. This is true forpublish_at,created_afterandcreated_before. - Plain-English texts, like a target's
status_text, write times in UTC without milliseconds:2026-10-18T15:30:00Z.
Errors
Every error answer has the same shape, except the health check's 503. error is a short code for your program to check. message is the reason in plain English, for people.
A body that is not valid400
{ "error": "invalid_request", "message": "The request body is not valid.", "issues": [ { "path": "account_ids", "message": "Too small: expected array to have >=1 items" }, { "path": "text", "message": "Too small: expected string to have >=1 characters" } ]}Some errors have one more field:
issues- With most
invalid_requestanswers: what is wrong in the request. Each item has apath, the key you sent, and amessage. accounts- With
account_not_activeandmedia_permission_missing: the accounts to reconnect, each with itsid,username,statusandreason. post_id- With
queue_unavailable: the post that was saved. retry_at- With
rate_limited, when you connect a Bluesky account: when to try again, if known.
Common error codes
| Status | Error | What it means |
|---|---|---|
| 400 | invalid_request | The body, the query or a header is not valid. Most of these answers have issues, which says what. |
| 400 | bad_request | The body is not valid JSON. |
| 400 | unknown_accountunknown_media | An account id or a media id in the body is not in your workspace. |
| 400 | text_too_long | The text is too long for one of the accounts. The message names the account and its limit. |
| 400 | media_not_supported | A network does not take the post's files. The message says why. |
| 400 | invalid_cursor | The cursor is not from this list. |
| 401 | missing_api_keyinvalid_api_key | No API key, or a wrong or revoked one. |
| 404 | not_found | Nothing with this id in your workspace, or no such path. |
| 409 | account_not_active | An account of the post must be reconnected, or it is disabled. accounts lists them. |
| 413 | payload_too_large | The body is over 4,000,000 bytes. |
| 503 | queue_unavailable | The post was saved but not queued. Send the same request again, with the same Idempotency-Key. |
The API reference lists every error of every call.
Retry a request safely
A call can time out, or its answer can get lost on the way. Then you do not know if Postsure saved the post. Send POST /v1/posts with an Idempotency-Key header, and you can send it again safely.
KEY=$(uuidgen)curl https://api.postsure.dev/v1/posts \ -H "Authorization: Bearer $POSTSURE_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $KEY" \ -d '{"account_ids": ["<account id>"], "text": "Hello from Postsure!"}'# No answer? Run the same curl again. $KEY stays the same.const api = "https://api.postsure.dev";const headers = { Authorization: `Bearer ${process.env.POSTSURE_KEY}`, "Content-Type": "application/json", // One key for this post, the same on every try. "Idempotency-Key": crypto.randomUUID(),};const body = JSON.stringify({ account_ids: ["<account id>"], text: "Hello from Postsure!" });let res;for (let tries = 0; tries < 3; tries++) { try { res = await fetch(`${api}/v1/posts`, { method: "POST", headers, body }); if (res.status !== 503) break; } catch { // No answer. Send the same request again, with the same key. } await new Promise((done) => setTimeout(done, 2000));}console.log(res?.status, res?.headers.get("Idempotent-Replayed"));import os, time, uuidimport requestsapi = "https://api.postsure.dev"headers = { "Authorization": f"Bearer {os.environ['POSTSURE_KEY']}", # One key for this post, the same on every try. "Idempotency-Key": str(uuid.uuid4()),}body = {"account_ids": ["<account id>"], "text": "Hello from Postsure!"}res = Nonefor tries in range(3): try: res = requests.post(f"{api}/v1/posts", headers=headers, json=body, timeout=30) if res.status_code != 503: break except requests.RequestException: pass # No answer. Send the same request again, with the same key. time.sleep(2)if res is not None: print(res.status_code, res.headers.get("Idempotent-Replayed"))Example response202
{ "id": "cmgwb1n6e000bl808v5j0k8ry", "status": "queued", "text": "Hello from Postsure!", "idempotency_key": "4f9d2c7e-8b1a-4e3f-9a6d-2c5b7e1f0a3d", "created_at": "2026-10-18T12:00:00.000Z"}- The key is any text of 1 to 255 characters. A new UUID for each post works well.
- Send the same request again with the same key. If a post with that key exists, you get it back with
202and the headerIdempotent-Replayed: true. Postsure makes no second post, and never sends the first one twice. - You get the post as it is now, for example a draft with its changes. The second body is checked, but not used.
- Postsure keeps the key with the post, in
idempotency_key. So use a new key for every new post: an old key gives back the old post. 503 queue_unavailablemeans the post was saved but not queued. Send the same request again, with the same key, and Postsure queues the saved post.- The header works on
POST /v1/posts. A change to a draft (PATCH /v1/posts/{id}) refuses it: the same change sent twice gives the same draft.
Lists and pages
GET /v1/posts lists your posts, newest first, one page at a time:
curl "https://api.postsure.dev/v1/posts?limit=2" \ -H "Authorization: Bearer $POSTSURE_KEY"const api = "https://api.postsure.dev";const headers = { Authorization: `Bearer ${process.env.POSTSURE_KEY}` };const posts = [];let cursor = null;do { const query = new URLSearchParams({ limit: "100" }); if (cursor) query.set("cursor", cursor); const page = await fetch(`${api}/v1/posts?${query}`, { headers }).then((r) => r.json()); posts.push(...page.data); cursor = page.next_cursor;} while (cursor);console.log(posts.length);import osimport requestsapi = "https://api.postsure.dev"headers = {"Authorization": f"Bearer {os.environ['POSTSURE_KEY']}"}posts, cursor = [], Nonewhile True: params = {"limit": 100} if cursor: params["cursor"] = cursor page = requests.get(f"{api}/v1/posts", headers=headers, params=params).json() posts += page["data"] cursor = page["next_cursor"] if not cursor: breakprint(len(posts))A page with limit=2200
{ "data": [ { "id": "cmh0q4z2k0007l708c1d2e3f4", "status": "queued", "created_at": "2026-10-18T12:05:00.000Z", "targets": [ { "account": { "network": "x", "username": "postsure_demo" }, "status": "queued", "url": null } ] }, { "id": "cmgwb1n6e000bl808v5j0k8ry", "status": "published", "created_at": "2026-10-18T12:00:00.000Z", "targets": [ { "account": { "network": "x", "username": "postsure_demo" }, "status": "published", "url": "https://x.com/postsure_demo/status/1979234567890123456" } ] } ], "next_cursor": "cmgwb1n6e000bl808v5j0k8ry"}limitis the number of posts on a page: 1 to 100, and 20 when you do not send it. Over 100 is refused with400 invalid_request, not cut to 100.- For the next page, send the answer's
next_cursorascursor, with the same filters.next_cursorisnullon the last page. - A post made while you read the pages causes no gap and no repeat.
- The filters combine.
statustakes one or more statuses, comma-separated:status=failed,unconfirmed.account_idkeeps the posts to one account.created_afterandcreated_beforeset a range oncreated_at: the first one keeps the time itself, the second leaves it out.
GET /v1/accounts has no pages: it answers with all your accounts at once, in data, newest first. A webhook's deliveries (GET /v1/webhooks/{id}/deliveries) page like posts, with limit and cursor.
Limits
- A JSON body can be up to 4,000,000 bytes. The largest post fits: a thread of 25 parts of 25,000 characters each. A larger body gets
413 payload_too_large: "The request body is larger than 4,000,000 bytes, the most the API reads." - A file you upload to
POST /v1/mediahas its own limits. See Images and video. - The MCP server limits how many calls an AI tool can make. See MCP server.
- Each connected account can send a set number of posts a day. X posts have a monthly limit and cannot have links, and the free trial has its own limits. See Post limits.
- The networks have their own limits. When a network limits an account, Postsure waits and tries again. See Retry rules.