POST /2/users/:id/following

POST /2/users/:id/following

Allows a user ID to follow another user.

If the target user does not have public Tweets, this endpoint will send a follow request.

The request succeeds with no action when the authenticated user sends a request to a user they're already following, or if they're sending a follower request to a user that does not have public Tweets.

Endpoint URL

https://api.x.com/2/users/:id/following

Authentication and rate limits

Authentication methods
supported by this endpoint

OAuth 1.0a is also available for this endpoint.

OAuth 2.0 Authorization Code with PKCE

Rate limit

User rate limit (User context): 50 requests per 15-minute window per each authenticated user

OAuth 2.0 scopes required by this endpoint

tweet.read

users.read

follows.write

Learn more about OAuth 2.0 Authorization Code with PKCE

Path parameters

NameTypeDescription
id
 Required 
stringThe authenticated user ID who you would like to initiate the follow on behalf of. You must pass the Access Tokens that relate to this user when authenticating the request.


JSON body parameters

NameTypeDescription
target_user_id
 Required 
stringThe user ID of the user that you would like the id to follow.


Example code with offical SDKs

TypeScript
Java
      (async () => {
  try {
    const followUser = await twitterClient.users.usersIdFollow(
      //The ID of the user that is requesting to follow the target user
      "6253282",
      {
        //The ID of the user that the source user is requesting to follow
        target_user_id: "2244994945",
      }
    );
    console.dir(followUser, {
      depth: null,
    });
  } catch (error) {
    console.log(error);
  }
})();

    
      // Set the params values

UsersIdFollowRequest usersIdFollowRequest = new UsersIdFollowRequest(); 
//The ID of the user that the source user is requesting to follow
usersIdFollowRequest.targetUserId("2244994945");

// String | The ID of the user that is requesting to follow the target user
String id = "6253282";

try {
    UsersFollowingCreateResponse result = apiInstance.users().usersIdFollow(usersIdFollowRequest, id);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling UsersApi#usersIdFollow");
    System.err.println("Status code: " + e.getCode());
    System.err.println("Reason: " + e.getResponseBody());
    System.err.println("Response headers: " + e.getResponseHeaders());
    e.printStackTrace();
}

    

Example responses

Successful response (public user)
Successful response (protected user)
      {
  "data": {
    "following": true,
    "pending_follow": false
  }
}
    
      {
  "data": {
    "following": false,
    "pending_follow": true
  }
}
    

Response fields

NameTypeDescription
followingbooleanIndicates whether the id is following the specified user as a result of this request. This value is false if the target user does not have public Tweets, as they will have to approve the follower request.
pending_followbooleanIndicates whether the target user will need to approve the follow request. Note that the authenticated user will follow the target user only when they approve the incoming follower request.