DELETE /2/users/:source_user_id/following/:target_user_id

DELETE /2/users/:source_user_id/following/:target_user_id

Allows a user ID to unfollow another user.

The request succeeds with no action when the authenticated user sends a request to a user they're not following or have already unfollowed.

Endpoint URL

https://api.twitter.com/2/users/:source_user_id/following/:target_user_id

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
source_user_id
 Required 
stringThe user ID who you would like to initiate the unfollow on behalf of. You must pass the Access Tokens that relate to this user when authenticating the request.
target_user_id
 Required 
stringThe user ID of the user that you would like the source_user_id to unfollow.


Example code with offical SDKs

TypeScript
Java
      (async () => {
  try {
    const unfollowUser = await twitterClient.users.usersIdUnfollow(
      //The ID of the user that is requesting to unfollow the target user
      "2244994945",

      //The ID of the user that the source user is requesting to unfollow
      "6253282"
    );
    console.dir(unfollowUser, {
      depth: null,
    });
  } catch (error) {
    console.log(error);
  }
})();

    
      // Set the params values

// String | The ID of the user that is requesting to unfollow the target user
String sourceUserId = "2244994945";

// String | The ID of the user that the source user is requesting to unfollow
String targetUserId = "6253282";

try {
    UsersFollowingDeleteResponse result = apiInstance.users().usersIdUnfollow(sourceUserId, targetUserId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling UsersApi#usersIdUnfollow");
    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
      {
  "data": {
    "following": false
  }
}
    

Response fields

NameTypeDescription
followingbooleanIndicates whether the source_user_id is unfollowing the specified user as a result of this request. This value is false for a successful the unfollow request.