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 liking and unliking Posts 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)

Like 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 like request

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

Review the response

{
  "data": {
    "liked": true
  }
}

Unlike a Post

Remove a like from a Post:
cURL
curl -X DELETE "https://api.x.com/2/users/123456789/likes/1228393702244134912" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN"
Response:
{
  "data": {
    "liked": false
  }
}

Next steps

Likes lookup

Get users who liked a Post

API Reference

Full endpoint documentation