How to post a tweet from the command line

Install the octopost CLI, run octopost login, then run octopost post "Your text" --to x. The tweet goes out on the X account you connected to Octopost. It's one binary for macOS and Linux, and you don't need an X developer app.

Why posting from a terminal is harder than it should be

The X API expects a registered developer app and an OAuth flow in a browser, and its access tokens expire every two hours. That is a lot of setup for one line of text from a terminal.

With the CLI, you connect X once in the Octopost dashboard and sign in once from the terminal. The CLI saves its sign-in in ~/.config/octopost/credentials.json, readable only by you, and refreshes it on its own.

Install it and post

Create an Octopost account and connect X on the accounts page first. Then:

Install (no sudo, checks the SHA-256, puts octopost in ~/.local/bin)

curl -fsSL https://octopost.ink/cli/install.sh | sh

Sign in (opens your browser)

octopost login

Post a tweet

octopost post "Shipped the new export button today" --to x

Post with an image, or as a thread

octopost post "The new dashboard" --to x \
  --media ./screenshot.png --alt "Dashboard with a weekly chart"

octopost post "I wrote up how we cut our build time in half" --to x \
  --thread "https://example.com/blog/faster-builds"

Read the text from a file or another command

cat announcement.txt | octopost post - --to x

Schedule it, or check it first

octopost schedule "Weekly update is live" --to x --at "2026-11-10 09:00"
octopost schedule "Back in an hour" --to x --at +1h --approval

octopost preview "Is this too long for X?" --to x

preview shows the character count, the X units the post would use and anything that would stop it. Nothing is saved or posted.

In cron, CI and shell scripts

Where there's no browser, use an API key: set OCTOPOST_API_KEY or run octopost login --key op_.... Add --json to any command to get raw JSON. The exit status is 0 on success, 1 when Octopost refused the post or it failed (a partly published post counts too), and 2 for a mistake in the command.

Every option is in the CLI docs. If you would rather send plain HTTP from Python or TypeScript, see posting to X from a script. Coding agents can run the CLI too, or use the MCP server.

Limits worth knowing

  • Builds exist for macOS and Linux, on Apple silicon or ARM and on Intel or x64. There is no Windows build.
  • Always pass --to x if you only mean X. With no --to, the post goes to every network you have connected.
  • A tweet must fit 280 characters, with links counted as 23. Long posts on X Premium are not supported, so split longer text with --thread.
  • The same text to the same network within 7 days is refused unless you pass --allow-duplicate.
  • The CLI needs an active Octopost plan. Basic allows 500 X posts a month, or about 38 with links, because X charges per post and more for a link.
  • X, Bluesky and Mastodon are live. Threads opens after Meta approves the Octopost app. LinkedIn is in testing, so a post there may fail.

Questions

Can I tweet from the terminal without an X developer account?

Yes. You connect X through the Octopost dashboard and Octopost publishes with its own X app. The CLI only needs your Octopost sign-in or API key.

How do I attach an image to a tweet from the command line?

Add --media with a local file or a URL. Local files are uploaded for you, and --alt sets the alt text for the --media in the same position. X allows up to 4 images per post.

How do I schedule a tweet from the terminal?

Run octopost schedule "text" --to x --at TIME. TIME can be +30m, 17:30, 2026-11-10 09:00 in your computer’s time zone, or an ISO 8601 time.

How do I see whether my tweet went out?

Run octopost list for your newest posts or octopost get with a post id for its links and errors. octopost retry reposts to the networks that failed.

Can I run it in GitHub Actions?

Yes. Install it in the job, set OCTOPOST_API_KEY from a secret and run the same commands. There is also a ready workflow for announcing releases.