Taskwind
Start free trial

X (Twitter) posting API: POST /2/tweets and pricing (2026)

By Natnael Girma · Published

To post to X (Twitter) through the API, you send POST https://api.x.com/2/tweets with a JSON body such as {"text": "Hello"} and a user access token from OAuth 2.0 with the tweet.read, tweet.write and users.read scopes. Images are uploaded first with POST /2/media/upload and attached by ID. As of December 2026, X charges per request on a prepaid credit model: $0.015 per post, or $0.20 if the post contains a URL.

Pricing has changed several times since 2023, so this guide starts there. Everything below comes from docs.x.com as read in December 2026.

X API pricing in December 2026

X launched pay-per-use pricing on February 6, 2026. You buy credits in the Developer Console at console.x.com, and each request deducts from the balance. There is no subscription, contract or minimum spend.

The rates that matter for publishing:

Action Price
Create a post $0.015 per request
Create a post containing a URL $0.200 per request
Create a post as a summoned reply $0.010 per request
Media metadata $0.005 per request
Read a post $0.005 per post returned
Read a user $0.010 per user returned
Owned Reads (your own posts, mentions, followers, through your own app) $0.001 per resource

Other rules from the same page:

The pricing page lists no charge for uploading media itself.

What happened to Free, Basic and Pro?

The X changelog entry for the February 6, 2026 launch says Basic and Pro plans remain available and existing subscribers can opt in to pay-per-use. Recently active Legacy Free users got a one-time $10 voucher, and Public Utility Apps keep free access. We could not confirm current Basic or Pro prices on an official X page, so check the Developer Console before you rely on older figures you see quoted elsewhere.

Two later changes affect posting apps:

What a month of posting costs

Say a company publishes 3 posts a day, 90 a month, from its own developer app to its own account, and reads its last 20 posts once a day to check engagement. Because the app owner is reading their own posts, those reads qualify for Owned Read pricing:

Usage Calculation Monthly cost
90 text posts 90 × $0.015 $1.35
90 posts that each include a link 90 × $0.20 $18.00
Reading your last 20 posts daily (Owned Reads) 30 × 20 × $0.001 $0.60

Links are the expensive part. The same schedule costs about 13 times more when every post carries a URL. If your posts exist to drive clicks, budget for the URL rate. If not, keep links out of most posts.

Step 1: Create an app and turn on OAuth 2.0

  1. Sign up at console.x.com, create a developer account and describe how you will use the API.
  2. Create an app. Newly created apps use OAuth 2.0 only. OAuth 1.0a is disabled for new apps and scheduled to be retired on January 31, 2027.
  3. In the app's authentication settings, enable OAuth 2.0, add your exact callback URL and choose an app type. Web App, Automated App and bot types are confidential clients and get a client secret. Native and single-page apps are public clients.
  4. Buy credits, because requests are blocked at a zero balance.

Step 2: Get a user token with PKCE

Build the authorize URL with a PKCE code_challenge. Ask for offline.access, or you get no refresh token and the access token dies after two hours:

https://x.com/i/oauth2/authorize
  ?response_type=code
  &client_id=<CLIENT_ID>
  &redirect_uri=<REDIRECT_URI>
  &scope=tweet.read%20tweet.write%20users.read%20media.write%20offline.access
  &state=<STATE>
  &code_challenge=<CHALLENGE>
  &code_challenge_method=S256
Scope Why you need it
tweet.write Create posts
tweet.read, users.read Also required by POST /2/tweets
media.write Upload images and video
offline.access Get a refresh token

Exchange the code quickly. X's docs say the authorization code expires 30 seconds after the user approves:

curl -X POST https://api.x.com/2/oauth2/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "grant_type=authorization_code" \
  --data-urlencode "code=<CODE>" \
  --data-urlencode "redirect_uri=<REDIRECT_URI>" \
  --data-urlencode "code_verifier=<VERIFIER>"

Confidential clients authenticate with the Basic header shown here. Public clients send client_id in the body instead. To refresh, call the same endpoint with grant_type=refresh_token and the refresh_token.

Step 3: Publish a post

curl -X POST https://api.x.com/2/tweets \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "Shipping the new release today."}'
{
  "data": {
    "id": "1880028106020515840",
    "text": "Shipping the new release today.",
    "edit_history_post_ids": ["1880028106020515840"]
  }
}

The post lives at https://x.com/{username}/status/{id}. Get the username once from GET /2/users/me.

Useful body fields

From the Create Post reference:

Field What it does
text Up to 280 characters unless the account has X Premium. Optional if media is attached.
media.media_ids Up to 4 photos, 1 GIF or 1 video, attached in the order given
reply.in_reply_to_tweet_id Reply to a post (subject to the summoned rule)
reply_settings Who can reply: following, mentionedUsers, subscribers or verified
poll 2 to 4 options of 1 to 25 characters, open 5 to 10,080 minutes
made_with_ai Discloses AI-generated media
paid_partnership Discloses a paid partnership
community_id Posts to a Community
edit_options Edits an existing post instead of creating one

Delete a post with DELETE /2/tweets/{id}. The API has no scheduling field, so a scheduled post means storing it and calling the endpoint at the right time.

Step 4: Attach images

Images under 5 MB (JPG, PNG, GIF or WEBP) go up in one request to POST /2/media/upload with media_category set to tweet_image:

curl -X POST https://api.x.com/2/media/upload \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -F "media=@photo.jpg" \
  -F "media_category=tweet_image"

The response contains data.id. Pass up to four of them:

curl -X POST https://api.x.com/2/tweets \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "Before and after", "media": {"media_ids": ["1880028106020515840", "1880028106020515841"]}}'

Video

Video uses the chunked upload flow with dedicated paths:

  1. POST /2/media/upload/initialize with a JSON body of media_type, total_bytes and media_category: "tweet_video". The response has the media id.
  2. POST /2/media/upload/{id}/append for each chunk, with segment_index and the bytes. Keep chunks at or under 5 MB (the server maximum is 8 MB).
  3. POST /2/media/upload/{id}/finalize.
  4. If the response includes processing_info, poll GET /2/media/upload?command=STATUS&media_id={id} until state is succeeded, waiting check_after_secs between checks.

The old command=INIT, APPEND and FINALIZE parameters on /2/media/upload are the previous protocol and should not be used. Video length is limited by the posting account, not your API plan: 20 minutes and 8 GB by default, 125 minutes and 16 GB for X Premium or verified accounts. A video that uploads fine can still be rejected with a 403 when attached to a post from an account below that limit.

Rate limits

From the rate limits page, these sit on top of your credit balance:

Endpoint Per user Per app
POST /2/tweets 100 per 15 minutes 10,000 per 24 hours
DELETE /2/tweets/:id 50 per 15 minutes Not listed
POST /2/media/upload 500 per 15 minutes 50,000 per 24 hours
POST /2/media/upload/initialize, append, finalize 1,875 per 15 minutes 180,000 per 24 hours

Every response carries x-rate-limit-limit, x-rate-limit-remaining and x-rate-limit-reset (a Unix timestamp). Exceeding a limit returns 429 until the window resets.

Common errors

Error Cause Fix
401 Unauthorized Expired access token Refresh with the stored refresh token
403 on a reply The author has not summoned your account Only reply where you were mentioned or quoted
403 on quote_tweet_id Quote posts need Enterprise Post a link to the post instead
403 on a video post Video longer than the account may post Trim it, or post from a Premium account
429 Too Many Requests Rate limit hit Wait until x-rate-limit-reset
Requests blocked, out of credits Credit balance at zero or below, or spending limit reached Add credits or raise the limit; auto-recharge fires at most once per 5 minutes
No refresh token returned offline.access not requested Add the scope and have the user sign in again
Invalid code at token exchange Code older than 30 seconds Exchange it immediately in your callback

What we ran into building this

Taskwind's X connector runs this flow for every connected account:

The same post through Taskwind

With Taskwind, you connect an X account with X's official sign-in and post through one REST call. Taskwind runs the X app, so you do not need a developer account or credits of your own. Upload images first:

curl -X POST https://taskwind.ai/v1/media \
  -H "Authorization: Bearer $TASKWIND_API_KEY" \
  -H "Content-Type: image/png" \
  --data-binary @chart.png

Then post, now or at a Unix timestamp:

curl -X POST https://taskwind.ai/v1/posts \
  -H "Authorization: Bearer $TASKWIND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"Q4 numbers are in.","account_ids":["acc_..."],"media_ids":["med_..."],"scheduled_at":1798000000}'

The response has a targets array with the status, post link and any error per account, and the same call can include LinkedIn, Threads and Bluesky. See the REST API docs.

On X, Taskwind supports text up to 280 characters and up to 4 images. It does not post video, polls, threads, Community posts or replies, does not send or read X DMs, and has no analytics yet. Plans start at $49/month with a 7-day trial (pricing). For a comparison of posting APIs across networks, see the social media posting API guide.

Questions

Can I post with an app-only Bearer token?

No. The Create Post reference only accepts user-context authentication, either an OAuth 2.0 user token with tweet.read, tweet.write and users.read, or an OAuth 1.0a user token. An app-only Bearer token can read public data but cannot post.

Can I post a thread through the X API?

You build a thread by posting each part as a reply to the previous one with reply.in_reply_to_tweet_id, and each part is billed as a separate post. X's docs do not spell out how the February 2026 summoned-reply rule treats replies to your own posts, so test it on your account before you build on it.