Getting started with the manage mutes endpoints

This quick start guide will help you make your first request to the manage mutes endpoints using Postman.

If you would like to see sample code in different languages, please visit our Twitter API v2 sample code GitHub repository.

 

Prerequisites

For you to be able to complete this guide, you will have need to have a set of keys and tokens, which you can generate by following these steps:

  1. Sign up for a developer account.
  2. Create a Project and an associated developer App in the developer portal.
  3. Navigate to your app's “Keys and tokens” page, and save your credentials in a secure location.

 

Steps to build a manage mutes request

Step one: Start with a tool or library

There are several different tools, code examples, and libraries that you can use to make a request to this endpoint, but we will use the Postman tool here to simplify the process.

To load the Twitter API v2 Postman collection into your environment, please click on the following button:

Once you have the Twitter API v2 collection loaded in Postman, navigate to the “Mutes” folder, and select “Mute a user’s ID”.

Step two: Authenticate your request

To make a successful request to this endpoint, you will need to use OAuth 1.0a User Context. To do this, you must add the following keys and tokens to Postman by selecting the environment named “Twitter API v2” and adding the following variables to the initial value and current value fields:

  • consumer_key with your API Key
  • consumer_secret with your API Key Secret
  • access_token with your Access Token
  • token_secret with your Access Token Secret
     

Step three: Specify who is going to mute whom

Manage mutes endpoints require two IDs: one for the user (the user who wishes to mute or unmute another user) and the target user (the user that will be muted or unmuted). The user’s ID must correspond to the authenticating user’s ID, meaning that you must pass the Access Tokens associated with the user ID when authenticating your request. In this case, you can specify the ID belonging to your own user. You can find your ID in two ways:

  1. Using the user lookup by username endpoint, you can pass a username and receive the id field. 
  2. Looking at your Access Token, you will find that the numeric part is your user ID.
     

The target ID can be any valid user ID. In Postman, navigate to the "Params" tab, and enter your ID into the "Value" column of the id path variable. Navigate to the “Body” tab and ID of the user you wish to mute as the value for the target_user_id parameter. Be sure not to include any spaces before or after any ID.

Key Value
id authenticated user ID
target_user_id the user ID you wish to mute

 

Step four: Make your request and review your response

Once you have everything set up, hit the "Send" button, and you will receive a similar response to the following example response:

      { "data": { "muting": true } }
    

If you receive a "muting": true, then the id is successfully muting the target_user_id

To unmute the same user you can use the request entitled “Unmute a user ID”, which is also found in the “Mutes” folder of the Twitter API v2 collection loaded in Postman. The source_user_id should be your user ID and target_user_id should be the user ID to unmute. You will not have to add this as a JSON body so you will want to make sure that you add in the requisite query params for source_user_id and target_user_id.

On a successful unmute, you will receive a similar response to the following example:

      { "data": { "muting": false } }