Postwith API and CLI
Last updated: November 9, 2026
The REST API lets your own code do what your AI does with Postwith: add a photo or video, make a draft with a version for each account, check it, schedule it, and change it until it goes out. The CLI does the same from a terminal, and OAuth apps let your product post for other Postwith users. Every call acts as one person, with the same rules as the dashboard: Instagram, Facebook Pages, Threads, TikTok, YouTube, Pinterest and LinkedIn are all open.
The API is at https://api.postwith.app/v1. Its OpenAPI description works with code generators, Postman and AI tools.
Sign in
- An API key, for your own scripts and tools: make one in Postwith › Settings › Developers and send it as
Authorization: Bearer pwk_…. A key acts as you in your workspace, so keep it secret, and make one per script so you can revoke it on its own. - An OAuth app, when other people use your product: they approve it on Postwith’s own page, and your app gets a token for each of them. See OAuth apps.
Both kinds of token also work with the AI connector at https://mcp.postwith.app/mcp, for MCP clients that send a fixed header.
Quick start
export POSTWITH_API_KEY=pwk_…
# Where you can post
curl https://api.postwith.app/v1/accounts \
-H "Authorization: Bearer $POSTWITH_API_KEY"
# Add a photo from a public link
curl https://api.postwith.app/v1/media \
-H "Authorization: Bearer $POSTWITH_API_KEY" -H "Content-Type: application/json" \
-d '{"url": "https://postwith.app/samples/sample-photo.jpg"}'
# Make a draft: nothing is posted yet
curl https://api.postwith.app/v1/posts \
-H "Authorization: Bearer $POSTWITH_API_KEY" -H "Content-Type: application/json" \
-d '{
"mediaId": "MEDIA_ID",
"caption": "Hello from the API",
"accountIds": ["ACCOUNT_ID"],
"when": "2026-10-20T09:00:00-05:00",
"timezone": "America/Chicago",
"pinterest": {"boards": [{"accountId": "ACCOUNT_ID", "boardId": "BOARD_ID"}]}
}'
# Check the versions it returns, then schedule it
curl -X POST https://api.postwith.app/v1/posts/POST_ID/schedule \
-H "Authorization: Bearer $POSTWITH_API_KEY"
Every answer is {"data": …, "summary": "…"}: the data, and the same plain-English summary your AI would read.
Endpoints
| Call | What it does |
|---|---|
GET /accounts | Your connected accounts, whether each can post now, and its followers where the network gives them |
GET /accounts/{id}/boards | A Pinterest account’s boards |
GET /media | Your photos and videos, newest first |
POST /media | Adds one from a public https link: {"url": …} |
POST /media/ | A one-time link (24 hours) for files on a device: one, or up to 10 with files |
GET /media/ | Whether the files have come in, with their mediaIds in order |
GET /posts | Recent posts and where each stands |
POST /posts | Makes a draft, with a version for each account, and its labels if you send them. Sending the same draft twice returns the same post |
GET /posts/{id} | A post’s versions and how each network went, with links once it’s live, when it goes out, its revision, whether it can still be edited, and its labels |
PATCH /posts/{id} | Changes a draft or a scheduled post until any of it goes out: caption, one account’s own in versions, scheduledAt, title, altText, name and each network’s choices, as POST /posts takes them. Only what you send changes. It’s checked as scheduling checks it and saved whole or not at all (422 says what to fix); a scheduled post stays scheduled. Photos, video and accounts don’t change. 409 once it’s going out, or if it changed since the revision you send. labels alone change on any post, even one that went out |
POST /posts/{id}/ | Sends a draft out at its time, or within a minute if it’s for now. Safe to repeat |
POST /posts/{id}/ | Stops a scheduled post. Anything already live stays live |
GET /posts/{id}/ | The comments on its Instagram, Facebook and Threads versions, newest first, read live and not kept. next goes back as cursor for older ones. With your API key, not an OAuth app |
POST /posts/{id}/ | Answers a comment publicly from the account: {"text": …}. Send only what the account’s owner approved. The same reply again returns the first one |
GET /results? | How your Instagram, Facebook, TikTok and Threads posts did over 7, 30 or 90 days, and how each account’s followers changed |
GET /results/ | Every post from those days with its own numbers (views, reach, likes, comments, shares, saves), newest first, 50 at a time or up to 100 with limit. A number the network doesn’t give is null. accountId lists one account’s posts, and next goes back as cursor for older ones. Posts made with Postwith carry their labels |
GET /results/ | What works: those days’ posts grouped by a label (format, style, topic, hook, series, campaign, language, cta, tag) or by kind, weekday, hour, network, account, captionLength, hashtags or videoLength. Each group has its posts, the median, its lift against each post’s own account’s usual, its best post, and fewPosts under 3. Takes days, accountId and metric (views, interactions or engagement) |
GET /streak | Your posting streak and milestones |
Drafts
whenis"now"or an ISO 8601 time with its offset, up to a year ahead. Sendtimezone(likeAmerica/Chicago) so results and streaks follow your day.- YouTube needs a
title(up to 100 characters) andyoutube:whoCanWatch(public, unlisted or private) andmadeForKids. YouTube asks every uploader, so these must be the person’s own answers. A square or vertical video of up to 3 minutes becomes a Short. - Pinterest needs a board for each Pinterest account, from
GET /accounts/{id}/boards, and can take alinkthe Pin leads to. - TikTok needs
tiktok.whoCanView, chosen by the person. One photo or more make a TikTok photo post, which shows thetitle(up to 90 characters there) and gets a sound TikTok picks, which the person can change in TikTok;"autoAddMusic": falseintiktokleaves it out. Its version comes back with"format": "photo"andautoAddMusic. - TikTok’s inbox:
tiktok.postModeis"direct"(posted, withwhoCanView) or"inbox", which sends the video or photos to the account’s TikTok inbox as a draft: the person gets TikTok’s notification, taps it to keep editing in TikTok, chooses who can view it there and posts it. Left out, it’s"inbox"when there’s nowhoCanView. A photo post’s title and caption go with it; a video goes without its caption, which the person pastes in TikTok. TikTok holds up to 5 drafts in an account’s inbox within 24 hours, and an account connected before Postwith asked for drafts reconnects to allow them. Each TikTok version comes back withpostMode, and an inbox one with anotesaying where it is. - LinkedIn posts to the person’s own profile, not a Company Page: text on its own (leave out
mediaId), one photo, several photos in one post, or one video (MP4, 3 seconds to 30 minutes).linkedin.whoCanSeeis"anyone"(the default) or"connections", and each LinkedIn version comes back with it. A caption takes up to 3,000 characters when every account is on LinkedIn, and 2,200 otherwise. LinkedIn asks people to reconnect every 60 days, and Postwith reminds them a week before. - One video, or up to 10 photos, per post.
mediaIdis the video or the first photo, andmoreMediaIdslists the other photos in the order they show (up to 9). Several photos make a carousel on Instagram, one post on Facebook and LinkedIn, and a photo post on TikTok; YouTube takes one video, and Pinterest one photo or video. - Instagram Stories: Instagram accounts listed in
instagram.storyAccountIdsget the photo or video as a Story instead of a post or Reel. A Story is one photo or one video of 3 to 60 seconds, shows without the caption (the other accounts still get it) and disappears after 24 hours. Its version comes back with"format": "story"and"caption": null. - AI labels are the person’s own choice, and off unless they ask for one.
"aiGenerated": trueintiktokhas TikTok show an AI-generated label on the post; ininstagram, it labels Instagram posts, Reels and carousels as made with AI, and Instagram may show an AI info label. A Story doesn’t take Instagram’s label. Every TikTok and Instagram version comes back withaiGenerated. - Photos: JPEG, PNG or WebP up to 20 MB, saved as JPEG. Videos: MP4 or MOV up to 50 MB.
- Labels are your own notes on the post, never posted:
labelstakesformat,style,topic,hook,series,campaign,languageandcta(each up to 60 characters) and up to 10tags, like{"format": "sketch video", "style": "Chalkboard", "tags": ["sleep"]}. Capitals don’t split them.GET /results/groupscompares your posts by them, so it pays to have your AI fill them in as it posts.
Editing a post
Until any of it goes out, a draft or a scheduled post takes changes with PATCH /posts/{id}. Send only what changes:
curl -X PATCH https://api.postwith.app/v1/posts/POST_ID \
-H "Authorization: Bearer $POSTWITH_API_KEY" -H "Content-Type: application/json" \
-d '{"caption": "Lentil soup today", "scheduledAt": "2026-10-24T18:00:00+03:00",
"versions": [{"accountId": "LINKEDIN_ACCOUNT_ID", "caption": "A longer one for LinkedIn…"}],
"linkedin": {"whoCanSee": "connections"}, "revision": 3}'
captionchanges every version’s;versionsgives one account its own (itsaccountIdis on each version). A caption takes up to 2,200 characters, or 3,000 on LinkedIn.scheduledAtmoves it, aswhendoes for a draft:"now"or an ISO 8601 time, up to a year ahead.titleandaltTexttakenullto take them off.tiktok,youtube,pinterest(boards,link),instagram.aiGeneratedandlinkedin.whoCanSeetake whatPOST /postsdoes, and only the fields you send change.{"tiktok": {"postMode": "inbox"}}sends a post to the TikTok inbox instead, andtiktok.whoCanViewposts it on TikTok again.- Postwith checks the changed post as it checks a draft before scheduling. If a network couldn’t take it, nothing is saved and 422 lists what to fix. A scheduled post stays scheduled, and goes out with the changes at its time, or its new one.
- Its photos, video and accounts can’t change, nor whether an Instagram account gets a Story: cancel it and make a new one. Once any version is going out, has gone out or was tried, the answer is 409.
revisionis optional: send the oneGET /posts/{id}gave, and if the post changed since, nothing is saved and the answer is 409. The answer lists whatchanged; sending the same change again changes nothing.labelssent on their own change on any post, even one that went out, withoutrevision, and nothing changes on the networks. Only the labels you send change:nulltakes one off, andtagsreplace the list. Sent with other changes, they’re saved or refused together.
What works
GET /results/groups compares your posts from the last 7, 30 or 90 days. Each post is measured against its own account’s usual (the median of that account’s posts in those days), so a small account counts as much as a big one, and a group’s lift is the middle of those: 2.1 means its posts did 2.1 times as well as their accounts usually do. Posts at least 7 days old are compared at 7 days old where Postwith read that day’s numbers, otherwise by their numbers so far (each best post says which, and its age); posts under 2 days old wait. Posts without the label are one group, "No label", and a post with several tags counts in each.
curl "https://api.postwith.app/v1/results/groups?by=style&days=30" -H "Authorization: Bearer $POSTWITH_API_KEY"
{"data": {"by": "style", "compared": 48, "tooNew": 5, "groups": [
{"name": "Chalkboard", "posts": 6, "median": 4210, "lift": 2.1, "fewPosts": false, "best": {…}}, …]},
"summary": "Chalkboard posts got 2.1× their accounts’ usual views across 6 posts."}
It says what happened, not why: a group with fewPosts is too small to tell, and the summary always says how many posts a finding rests on.
Files from a device
For a file that has no public link, make an upload link, then send the file to it. The upload token is the last part of the link (pwu_…); it’s the permission, so these steps need no API key.
POST /media/upload-links → {"link": "https://app.postwith.app/u/pwu_…", "uploadId": …}
POST /uploads/{token}/start {"name": "clip.mp4", "type": "video/mp4", "size": 12345678}
→ {"data": {"uploadUrl": …, "contentType": "video/mp4"}}
PUT {uploadUrl} the file's bytes, with that Content-Type
POST /uploads/{token}/finish → {"data": {"mediaId": …, "type": "video"}}
Or open the link on any device, or run npx postwith upload <file> <link>.
For several files at once, send {"files": 5} (up to 10): the page then takes them all in one pick. File 0 goes through /uploads/{token} as above, and file n through /uploads/{token}.n. GET /media/upload-links/{uploadId} then answers with mediaIds, the ready files in order, to use as mediaId and moreMediaIds.
Errors and limits
A refusal is {"error": {"code", "message", "requestId", "retryable"}}, and its message says what to change in plain words.
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | Something’s missing or not allowed |
| 401 | unauthorized | No key or token, or it was revoked |
| 403 | forbidden | The person can’t do this in their workspace |
| 404 | not_found | Not found |
| 409 | conflict, limit_reached | Not possible right now, or a limit was reached (like 10 accounts) |
| 422 | not_ready | A network can’t take the draft, or the post as an edit would make it; the message lists what to fix |
| 429 | rate_limited | Over 120 requests a minute for one key or app; wait for Retry-After |
| 503 | unavailable | Postwith couldn’t do it right now; try again |
Each person can have 10 API keys and 5 OAuth apps.
OAuth apps
An OAuth app lets your product post for other Postwith users. Each person approves it on Postwith’s own page, sees it in their Settings, and can remove it anytime. Your app gets a token that does only what that person could.
- Register it in Settings › Developers: a name people will see, your redirect URLs (https, or
http://localhostwhile you build) and your website. Copy the client ID and secret; the secret is shown once, and you can rotate it. - Send the person to Postwith with PKCE (S256):
They sign in and choose Allow. Postwith sends them back withhttps://mcp.postwith.app/oauth/authorize?response_type=code &client_id=pwc_…&redirect_uri=https://yourapp.example/postwith/callback &code_challenge=…&code_challenge_method=S256&state=…code, yourstateandiss=https://mcp.postwith.app. - Swap the code from your server, with your secret as HTTP Basic (or
client_idandclient_secretin the form):
You get ancurl https://mcp.postwith.app/oauth/token -u "pwc_…:pws_…" \ -d grant_type=authorization_code -d code=… -d code_verifier=… \ -d redirect_uri=https://yourapp.example/postwith/callbackaccess_tokenfor an hour and arefresh_tokenfor 30 days. - Call the API with
Authorization: Bearer <access_token>, and get a new one withgrant_type=refresh_tokenand your secret. Refresh tokens rotate: use each once, because reusing one ends that person’s connection.
Only a workspace’s owners and admins can approve an app. Deleting your app ends every connection to it. Keep the secret on your server, never in an app people download. Comments aren’t open to OAuth apps: reading and answering them works with a person’s own API key or in their AI chat, where they OK each reply.
CLI
npx postwith login # paste a key from Settings › Developers
npx postwith accounts
npx postwith post photo.jpg --caption "Autumn menu" --to pinterest --board "Menus" --at "tomorrow 9am"
npx postwith post clip.mp4 --caption "Weekend recap" --to youtube --title "Weekend recap" \
--youtube-privacy public --made-for-kids no --at +2h
npx postwith post soup.jpg salad.jpg cake.jpg --caption "Three new dishes" --to instagram,facebook
npx postwith post tonight.jpg --caption "Tasting tonight at 7" --to instagram,facebook --instagram-story
npx postwith post --caption "We're hiring: two roles, both remote" --to linkedin --linkedin-visibility connections
npx postwith posts
npx postwith show <postId>
npx postwith edit <postId> --caption "Lentil soup today" --at "tomorrow 6pm"
npx postwith cancel <postId>
npx postwith comments <postId>
npx postwith reply <postId> <commentId> "Thank you!"
npx postwith results --posts --days 90
npx postwith post koala.mp4 --caption "Sleep like a koala" --to tiktok --tiktok-inbox --label style=Chalkboard --tag sleep
npx postwith results --by style
post takes a file on your computer, a public link or a mediaId (or up to 10 photos, which make one post in that order), shows every version, and schedules it after you say yes; --instagram-story makes it a Story on each Instagram account in --to; --tiktok-ai-label and --instagram-ai-label label it as made with AI on TikTok or Instagram (not on a Story), and without them nothing is labeled; --tiktok-inbox sends it to your TikTok inbox to finish and post in the TikTok app; without a file, it’s a text post, for LinkedIn once it’s open, and --linkedin-visibility anyone|connections says who can see it there; --yes skips the question and --draft stops at the draft. edit changes a post that hasn’t gone out: --caption for every version, or with --account <accountId|network> that account’s own, --at, --title, --alt, --name and post’s options for its networks; it shows each change before and after, and saves after you say yes. reply shows the comment and your reply, and asks before posting it. results --posts prints a line per post with its numbers, and the command for the next page. --label key=value and --tag (again for each) give post and edit the post’s labels, which edit changes on any post; results --by style (or any label, kind, weekday, hour and the rest) prints what works, with --days, --account and --metric. --at takes now, +30m, +2h, tomorrow 9am, 2026-10-20 18:00 or an ISO 8601 time. For CI, set POSTWITH_API_KEY instead of logging in. Every command takes --json; npx postwith lists them all.
Help
Email hi@postwith.app. See also our privacy policy and terms.