Skip to main content
Read-only routes need a TwexAPI API key. Write routes also need a Twitter cookie or 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.
Never put cookies, auth_token values, or API keys in agent chat, handoff JSON, logs that leave your vault, or public repositories.

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.
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

CLI named profiles keep the same values off the command line:
Default CLI config is plain JSON in ~/.x-api-scraper/config.json. Restrict file permissions and do not commit that directory. SDK pattern (Python):
REST pattern:
MCP agents still send the API key on the MCP connection. Pass cookie only inside the twexapi_request body after a human approves the exact text, target, and media URLs.

Preview before you send

Dry-run validates the payload without creating the tweet. Use it from n8n, Zapier, and agent pipelines before the live call. Local file upload is not supported. Attach public --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. HTTP 200 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

  1. Call MCP explore with include_writes: true only when the user asked for a write.
  2. Stop before read_only: false. Show path, body preview, and target IDs.
  3. After approval, send cookie from a secret store, not from the model.
  4. Keep cookies out of the handoff JSON. Store tweet_id, route_used, and approval metadata only.
See Agent MCP Handoff and MCP Tools.