Introduction

Creating and deleting Posts using the X API is essential for engaging with the public conversation. The new manage Posts endpoints allow you to do just that and much more.

We have two available methods for managing Posts, POST and DELETE. The POST method lets you post polls, quote Tweets, post with reply settings, post with geo, post with media and tag users, and post to Super Followers, in addition to other features. Likewise, the DELETE method allows you to delete a specific Post. For the POST method, you can pass in the parameters you are looking for to enable you to further customize your request.

The ‘delete Post’ method has been updated to support edited Posts. When any Post in a chain of Post edits is deleted, all Posts in that edit chain are also deleted. To learn more about Edit Post metadata, check out the Edit Posts fundamentals page.

There is a user rate limit of 200 requests per 15 minutes for the POST method. The DELETE method has a rate limit of 50 requests per 15 minutes. Additionally, there is a limit of 300 requests per 3 hours, including Posts created with either manage Posts or manage Retweets.

Since you are making requests on behalf of a user with the manage Posts endpoints, you must authenticate with either OAuth 1.0a User Context or OAuth 2.0 Authorization Code with PKCE, and use user Access Tokens associated with a user that has authorized your App. To generate this user Access Token with OAuth 1.0a, you can use the 3-legged OAuth flow. To generate a user Access Token with OAuth 2.0, you can use the Authorization Code with PKCE grant flow.

Account setup

To access these endpoints, you will need:

Learn more about getting access to the X API v2 endpoints in our getting started guide.




Quick start

Getting started with the manage Posts endpoints**

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

Please visit our X API v2 sample code GitHub repository if you want to see sample code in different languages.

Prerequisites

To complete this guide, you will need to have a set of keys and tokens to authenticate your request. You can generate these keys and tokens by following these steps:

  • Sign up for a developer account and receive approval.
  • Create a Project and an associated developer App in the developer portal.
  • Navigate to your App’s “Keys and tokens” page to generate the required credentials. Make sure to save all credentials in a secure location.

Steps to building manage Posts requests

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 are going to use the Postman tool here to simplify the process.

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

Once you have the X API v2 collection loaded in Postman, navigate to the “Manage Posts” folder, and select “Create a Post”.  

Step two: Authenticate your request

To properly make a request to the X API, you need to verify that you have permission to do so. To do this with the manage Posts endpoints, you must authenticate your request using either OAuth 1.0a User Context or OAuth 2.0 Authorization Code with PKCE.

In this example, we are going to use OAuth 1.0a User Context.

You must add your keys and tokens (and specifically your API Key, API Secret Key, OAuth 1.0a user Access Token, and OAuth 1.0a user Access Token Secret) to Postman. You can do this by selecting the environment named “X API v2” (in the top-right corner of Postman), and adding your keys and tokens to the “initial value” and “current value” fields (by clicking the eye icon next to the environment dropdown).

If you’ve done this correctly, these variables will automatically be pulled into the request’s authorization tab.

Step three: Specify the text of the Post

When creating a new Post with this endpoint, text or media for the Post are the required body parameters.

In Postman, navigate to the “Body” tab and enter the text of the Post as the value for the text parameter. Additionally, if you wish to add parameters for items such as polls, replying to a Post ID, or adding reply settings you can also do so here. You can learn more about what’s available in our API reference guide.

KeyValueParameter type
textHello world!body

Step four: Identify and specify which fields you would like to retrieve

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

  "data": {
    "id": "1445880548472328192",
    "text": "Hello world!"
  }
}

If the returned response object contains an id and the text of your Post, you have successfully created a Post.  

Step five: Delete your Post

To delete a Post, select the “Delete a Post” request also found in the “Manage Posts” folder of the X API v2 collection loaded in Postman. This endpoint requires the ID of the Post you wish to delete. Then, in the “Params” tab, enter the ID of the Post you wish to delete as the value for the id column. 

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

{
   "data": {
       "deleted" : true
   }
}

Integration guide

This page contains information on several tools and key concepts that you should be aware of as you integrate the manag Posts endpoints into your system. We’ve broken the page into a couple of different sections:

Helpful tools

Before we dive into some key concepts that will help you integrate this endpoint, we recommend that you become familiar with:

Postman

Postman is a great tool that you can use to test out an endpoint. Each Postman request includes every path and body parameter to help you quickly understand what is available to you. To learn more about our Postman collections, please visit our “Using Postman” page.   

Code samples

Interested in getting set up with this endpoint with some code in your preferred coding language? We’ve got a handful of different code samples available that you can use as a starting point on our Github page.  

Third-party libraries

Take advantage of one of our communities’ third-party libraries to help you get started. You can find a library that works with the v2 endpoints by looking for the proper version tag.  

Key concepts

Authentication

All X API v2 endpoints require you to authenticate your requests with a set of credentials, also known as keys and tokens. 

These specific endpoints requires the use of OAuth 1.0a User Context, which means that you must use a set of API keys and user Access Tokens to make a successful request. The Access Tokens must be associated with the user that you are making the request on behalf of. If you would like to generate a set of Access Tokens for another user, they must authorize or authenticate your App using the 3-legged OAuth flow.

Please note that OAuth 1.0a can be difficult to use. If you are not familiar with this authentication method, we recommend that you use a library, use a tool like Postman, or use OAuth 2.0 to authenticate your requests.

OAuth 2.0 Authorization Code with PKCE allows for greater control over an application’s scope, and authorization flows across multiple devices. OAuth 2.0 allows you to pick specific fine-grained scopes which give you specific permissions on behalf of a user. 

To enable OAuth 2.0 in your App, you must enable it in your’s App’s authentication settings found in the App settings section of the developer portal.

Developer portal, Projects, and developer Apps

To retrieve a set of authentication credentials that will work with the X API v2 endpoints, you must have a developer account, set up a Project within that account, and created a developer App within that Project. You can then find your keys and tokens within your developer App.   

Rate limits

Every day, many thousands of developers make requests to the X API. To help manage the sheer volume of these requests, rate limits are placed on each endpoint that limits the number of requests that you can make on behalf of your app or on behalf of an authenticated user.

These endpoints are rate limited at the user level, meaning that the authenticated user that you are making the request on behalf of can only call the endpoint a certain number of times across any developer App. There is a user rate limit of 200 requests per 15 minutes for the POST method. The DELETE method has a rate limit of 50 requests for 15 minutes. Additionally, there is a limit of 300 requests per 3 hours, including Posts created with either manage Posts or manage Retweets.  

Source labels

Your App name and website URL will be shown as the source label within metadata for any Posts created programmatically by your application. If you change the use case of a X App, be sure to update the use case in these settings in order to ensure you are in compliance with the Developer Terms.  

Profile settings

You can only add a location to Posts if you have geo enabled in your profile settings. If you don’t have geo enabled, you can still add a location parameter in your request body, but it won’t get attached to your Post. The same is also true for tagging users in images. If the user you’re tagging doesn’t have photo-tagging enabled, their names won’t show up in the list of tagged users even though the Post is successfully created.   

Adding media to a Post

Currently, isn’t a way to fully upload media using v2 of the X API currently. However, you attach previously uploaded media to a Post. You can use media IDs that have been already uploaded using the v1 media endpoint or X Media Studio. These media ids must be your own or that of an authenticated user.

Manage Tweets

Comparing X API’s manage Posts endpoints

The v2 manage Posts endpoints will replace the standard v1.1 POST statuses/update and POST statuses/destroy/:id endpoints. If you have code, apps, or tools that use the v1.1 version of the manage Posts endpoints and are considering migrating to the newer X API v2 endpoint, then this set of guides is for you.

The following tables compare the standard v1.1 and X API v2 manage Posts endpoints:

Create a Post

DescriptionStandard v1.1X API v2
HTTP methods supportedPOSTPOST
Host domainhttps://api.x.comhttps://api.x.com
Endpoint path/1.1/statuses/update.json/2/tweets
AuthenticationOAuth 1.0a User ContextOAuth 1.0a User Context

OAuth 2.0 Authorization Code with PKCE
Default request rate limitsNone

300 requests per 3-hour window per user, per app. Shared with the v1.1 POST Retweets endpoint.
200 requests per 15 min per user

300 requests per 3-hour window per user, per app. Shared with the v2 POST Retweets endpoint.
Requires the use of credentials from a developer App associated with a Project

Delete a Post

DescriptionStandard v1.1X API v2
HTTP methods supportedPOSTDELETE
Host domainhttps://api.x.comhttps://api.x.com
Endpoint path/1.1/statuses/destroy/:id.json/2/tweets/:id
AuthenticationOAuth 1.0a User ContextOAuth 1.0a User Context

OAuth 2.0 Authorization Code with PKCE
Default request rate limitsNone50 requests per 15 min per user
Requires the use of credentials from a developer App associated with a Project

Other migration resources

Manage Posts: Standard v1.1 to X API v2

X API migration hub

Standard v1.1 compared to X API v2

If you have been working with the standard v1.1 POST statuses/update and POST statuses/destroy/:id endpoints, the goal of this guide is to help you understand the similarities and differences between the standard and X API v2 manage Posts endpoints.

  • Similarities
    • Authentiation
  • Differences
    • Endpoint URLs

    • App and Project requirements

    • Request parameters

Similarities

Authentication

Both the standard v1.1 and X API v2 manage Posts (POST statuses/update and POST statuses/destroy/:id) endpoints use OAuth 1.0a User Context. Therefore, if you were previously using one of the standard v1.1 endpoints, you can continue using the same authentication method if you migrate to the X API v2 version. 

Differences

Endpoint URLs

App and Project requirements

The X API v2 endpoints require that you use credentials from a developer App that is associated with a Project when authenticating your requests. All X API v1.1 endpoints can use credentials from standalone Apps or Apps associated with a project.

Request parameters

The following standard v1.1 request parameters accepted two request query parameters (user_id or screen_name). The X API v2 only accepts the numerical Post ID for the DELETE endpoint, and it must be passed as part of the endpoint path.

For the POST endpoint, additional parameters will need to be passed in via the JSON body of the request. You can learn more about what parameters are available in the API reference guide.

Manage Tweets API reference index

API reference index

For the complete API reference, select an endpoint from the list:

Manage Tweets

Post a TweetPOST /2/tweets
Delete a TweetDELETE /2/tweets/:id