This guide covers the key concepts you need to integrate the blocks endpoints into your application.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.
The block and unblock users endpoints are only available under the Enterprise plan. You can fill out the Enterprise interest form here.
Authentication
Blocks endpoints require user authentication:| Method | Description |
|---|---|
| OAuth 2.0 Authorization Code with PKCE | Recommended for new applications |
| OAuth 1.0a User Context | Legacy support |
Required scopes (OAuth 2.0)
| Scope | Required for |
|---|---|
block.read | Retrieving blocked accounts |
block.write | Blocking and unblocking accounts |
users.read | Required with block scopes |
Endpoints overview
| Method | Endpoint | Description | Availability |
|---|---|---|---|
| GET | /2/users/:id/blocking | Get list of blocked accounts | Pay-per-useEnterprise |
| POST | /2/users/:id/blocking | Block an account | Enterprise |
| DELETE | /2/users/:source_user_id/blocking/:target_user_id | Unblock an account | Enterprise |
Fields and expansions
Default response
Available fields
user.fields
user.fields
| Field | Description |
|---|---|
created_at | Account creation date |
description | User bio |
profile_image_url | Avatar URL |
public_metrics | Follower/following counts |
verified | Verification status |
expansions
expansions
| Expansion | Description |
|---|---|
pinned_tweet_id | User’s pinned Post |
What happens when you block
They can't
- See your Posts (unless logged out)
- Follow you
- Send you DMs
- Add you to Lists
- Tag you in photos
You can't
- See their Posts
- Follow them
- Send them DMs
When you block someone who follows you, they are automatically unfollowed.
Pagination
For users with large block lists, results are paginated:cURL
Error handling
| Status | Error | Solution |
|---|---|---|
| 400 | Invalid request | Check user ID format |
| 401 | Unauthorized | Verify access token |
| 403 | Forbidden | Check scopes and permissions. Block/unblock require Enterprise |
| 404 | Not Found | User doesn’t exist |
| 429 | Too Many Requests | Wait and retry |
Next steps
Quickstart
Make your first blocks request
Mutes
Mute users instead of blocking
API Reference
Full endpoint documentation
Sample code
Working code examples