postsyncer-cli is PostSyncer’s command-line tool. Each command sends one API v1 request with your API key and prints PostSyncer’s JSON answer. It takes the same fields as the API, so the API reference describes every body you send.
It needs Node.js 20 or later. The command you run is postsyncer.
Install
npx runs it once without installing. Every command takes --help, such as postsyncer posts --help.
Sign in with a key
- Make a key in Settings → API. Give it only the permissions your commands need: the table below lists them. Authentication explains keys and permissions.
- Put the key in
POSTSYNCER_TOKENand check it:
Output
ping reads GET /workspaces, so the key needs workspaces:read. To use a key for one command only, pass it with -t or --token instead.
Find your ids
id and the id of the account you post to. The examples below use workspace 4815 and account 16234: put your own ids in their place.
Save a draft
Commands that send a body take JSON in one of three ways:--file (-f) with a path, --data (-d) with the JSON itself, or --stdin to read it from a pipe. Use exactly one.
Save this as draft.json:
draft.json
id. A draft goes nowhere. On Windows, --file is simpler than --data, since each shell quotes differently.
Schedule it
posts update sends PUT /posts/{id} with the same fields as create. Send the workspace_id and the full content again. Save this as schedule.json:
schedule.json
posts:schedule. Without it, the command prints the 403 and nothing is saved. Leave accounts out and the post keeps its accounts. Update post has every rule.
Upload media
--workspace and --file are required, and --folder puts the file in a media folder. The CLI sends the file to the upload host, https://upload.postsyncer.com/api/v1, and reads the whole file into memory first. Put the answer’s media.id in a post’s content[].media.
To copy files from links into the library instead, send POST /media/upload/url:
Options for every command
Put these before the command, such aspostsyncer --raw-json posts list.
Commands
Each command sends one request. The key needs the permission in the last column.
What to know about some of them:
posts get-by-urlencodes the link for you. Pass it as you copied it.- On the Free plan,
posts analyze-twitteris refused, and so is turning on comment moderation or contact collection. Creating and changing labels is on paid plans too. Plan limits has the list. folders deletedeletes only an empty folder. A folder with subfolders or files answers422: move or delete what’s in it first.comments hideasks the network to hide the comment. On a network that can’t hide, it answers422and sends nothing. See Answer comments.comments synctakes{"post_id": POST_ID}as its body.labels updateneeds bothnameandcolor.accounts deletedisconnects the account. Scheduled posts that go only to it move to drafts. See Delete an account.posts deletecan’t be undone. Test safely says what it removes on each network.
When a command fails
The CLI prints the status and PostSyncer’s answer, then exits with code1:
Output
401 it says to check the key, after a 403 to check its permissions. Error handling lists every answer.
In scripts and CI
- Keep the key in your CI’s secret store and pass it as
POSTSYNCER_TOKEN. Don’t commit it or paste it into chats. - A non-zero exit code means the request failed, so a CI step stops there.
- The CLI shares the rate limit with the API and MCP: 60 requests a minute per person. Wait and retry when a run gets
429. - Each command runs once. After a timeout, check with
posts listbefore you create the post again, or you may make two.
Related
Quickstart
The same steps with curl, Node.js or Python.
MCP server
Let an AI agent do the same work.