Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.x.com/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through Retweeting and undoing Retweets using the X API.
PrerequisitesBefore you begin, you’ll need:
  • A developer account with an approved App
  • User Access Token (OAuth 1.0a or OAuth 2.0 PKCE)

Retweet a Post

1

Get your user ID

You need your authenticated user’s ID. You can find it using the user lookup endpoint or from your Access Token (the numeric part is your user ID).
2

Get the Post ID

Find the Post ID in the URL when viewing a Post:
https://x.com/XDevelopers/status/1228393702244134912
                                └── This is the Post ID
3

Send the Retweet request

cURL
curl -X POST "https://api.x.com/2/users/123456789/retweets" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tweet_id": "1228393702244134912"}'
4

Review the response

{
  "data": {
    "retweeted": true
  }
}

Undo a Retweet

Remove a Retweet:
cURL
curl -X DELETE "https://api.x.com/2/users/123456789/retweets/1228393702244134912" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN"
Response:
{
  "data": {
    "retweeted": false
  }
}

Next steps

Retweets lookup

Get users who Retweeted a Post

Quote Posts

Get Quote Posts

API Reference

Full endpoint documentation