x_write
Act on X/Twitter through an account you connect: post a tweet, reply, like, retweet, follow or unfollow, send a DM, delete a tweet, remove a follower, or upload media. Ownership is checked server-side — an agent can only write as a handle its own wallet connected.
Guidance: PREREQUISITE: connect an X account first — POST /api/x-accounts/start (free, SIWX) with {username} only; it returns a one-time connect_url the USER opens in their own browser to sign in there. Never ask the user for their X password, email, or 2FA secret. Poll GET /api/x-accounts until the handle shows linked, then reference it in account. Actions: post (text) | reply (text + reply_to_tweet_id) | like|unlike|retweet|unretweet|delete_tweet (target_tweet_id) | follow|unfollow (target_user_id — the NUMERIC user id, get it from x_read get-user) | remove_follower (target_user_id of the follower) | send_dm (target_user_id + text) | upload_media (media_url → returns media_id). You can only write as a handle THIS wallet connected (checked server-side; the input account is not trusted). Payment settles before the action runs and is non-refundable; a write may return status=pending_confirmation with an actionId to poll — do NOT resend. Idempotency-Key header is required so a retry replays the original result instead of acting twice.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | post|reply|send_dm: the message body. | |
| action | Yes | Which write to perform. | |
| account | Yes | A connected X handle owned by this wallet (no @). | |
| media_ids | No | send_dm: optional uploaded media ids to attach. | |
| media_url | No | upload_media: public URL of the file to upload; returns a media_id. | |
| community_id | No | post: optional community to post into. | |
| is_note_tweet | No | post: long-form note tweet. | |
| target_user_id | No | follow|unfollow|send_dm|remove_follower: the numeric X user id of the target (not the @handle). Get it from x_read get-user. | |
| target_tweet_id | No | like|unlike|retweet|unretweet|delete_tweet: the target tweet ID. | |
| reply_to_tweet_id | No | reply: the tweet being replied to. |