auth_token on the request so TwexAPI can act as the logged-in account.
Use this page for posting, replies, likes, retweets, bookmarks, follows, and DMs. Preview payloads with the CLI --dry-run before sending from agents or production jobs.
What counts as a write
Related writes use the same cookie rule: retweet, bookmark, unfollow, unlike, thread create, and XChat DM. MCP marks these endpoints
read_only: false. Require human approval before any agent calls them. See Create a Tweet or Reply.
Credentials you need
1
TwexAPI API key
Create a key in the dashboard. Send it as
Authorization: Bearer YOUR_API_KEY (REST/SDK) or x-api-key (MCP).2
Twitter session
Supply a cookie string or an
auth_token. Most write bodies accept either in the cookie field.3
Optional cookie lookup
If you only have
auth_token, convert it with Get cookie by auth token (GET /twitter/{auth_token}/cookie), then store the returned cookie as a secret.Cookie vs auth_token
Export the session from a browser that is already logged into X/Twitter. Copy at least
auth_token and ct0. Treat the export as a password: it can post, follow, and DM as that account.
Store secrets
~/.x-api-scraper/config.json. Restrict file permissions and do not commit that directory.
SDK pattern (Python):
cookie only inside the twexapi_request body after a human approves the exact text, target, and media URLs.
Preview before you send
--media-url values (up to 4 images, or 1 GIF, or 1 MP4 up to 100 MB).
Did the write succeed?
TwexAPI does not expose a separate write-action polling API. HTTP200 with a tweet ID, message ID, or success envelope is the primary confirmation. Timeouts and 5xx are ambiguous: the write might have landed.
Persist an audit row
Store these fields before retrying:Check with a read before duplicating
Do not fire the same write again because the client timed out. Look up first, then retry once with the same fingerprint.
Credits and 403
Metered writes spend account credits. 403 often means no available credits or the action is not allowed for the key/account.
1
Stop write traffic
Pause agents, n8n batches, and CLI loops. Retrying a failed post can create duplicates after credits return.
2
Check balance
Call Get Balance:
3
Top up, then resume once
Restore credits in the dashboard. Re-run only writes that failed the read-back check.
Full HTTP recovery: Error Handling.
Agent rules
- Call MCP
explorewithinclude_writes: trueonly when the user asked for a write. - Stop before
read_only: false. Show path, body preview, and target IDs. - After approval, send
cookiefrom a secret store, not from the model. - Keep cookies out of the handoff JSON. Store
tweet_id,route_used, and approval metadata only.