Skip to main content
Access Posts endpoints via client.posts (PostsClient).

Methods

create

POST /2/tweets Create or Edit Post Creates a new Post for the authenticated user, or edits an existing Post when edit_options are provided. Media in media.media_ids is attached in the order given; get the ids by uploading each image with Upload Media, or a video with Initialize Media Upload. Supports paid partnership disclosure via the paid_partnership field. To share a clip of another Post’s video, set clip to that Post’s id and a range of 5 to 60 seconds.

Parameters

Hash
required
Request payload.
Returns: Hash

create_post_draft

POST /2/posts/drafts Create Post Draft Saves a Post draft to the authenticated user’s X account without publishing it. Takes the body of Create or Edit Post, of which a draft stores text, media with tagged users, a reply and the AI and paid partnership disclosures. Any other field that is set is a 400 that names it.

Parameters

Hash
required
Request payload.
Returns: Hash

delete

DELETE /2/tweets/{id} Delete Post Deletes a specific Post by its ID, if owned by the authenticated user.

Parameters

String
required
id (path parameter).
Returns: Hash

delete_post_draft

DELETE /2/posts/drafts/{id} Delete Post Draft Deletes one of the authenticated user’s Post drafts by its ID. The whole draft is deleted, including any part Get Post Drafts does not list, and cannot be restored. An ID that is not one of the user’s drafts also returns deleted: true.

Parameters

String
required
The ID of the draft to delete.
Returns: Hash

get_analytics

GET /2/tweets/analytics Get Post Analytics Retrieves analytics data for specified Posts within a defined time range.

Parameters

Array<String>
required
ids (query parameter).
String
required
start_time (query parameter).
String
required
end_time (query parameter).
Returns: Hash

get_by_id

GET /2/tweets/{id} Get Post by ID Retrieves details of a specific Post by its ID.

Parameters

String
required
id (path parameter).
Returns: Hash

get_by_ids

GET /2/tweets Get Posts by IDs Retrieves details of multiple Posts by their IDs.

Parameters

Array<String>
required
ids (query parameter).
Returns: Hash

get_counts_all

GET /2/tweets/counts/all Paginated Get Count of All Posts Retrieves the count of Posts matching a search query from the full archive. At most one of pagination_token, next_token may be provided.

Parameters

String
required
query (query parameter).
Returns: Enumerator<Hash>

get_counts_recent

GET /2/tweets/counts/recent Paginated Get Count of Recent Posts Retrieves the count of Posts from the last 7 days matching a search query. At most one of pagination_token, next_token may be provided.

Parameters

String
required
query (query parameter).
Returns: Enumerator<Hash>

get_liking_users

GET /2/tweets/{id}/liking_users Paginated Get Liking Users Retrieves a list of Users who liked a specific Post by its ID.

Parameters

String
required
id (path parameter).
Returns: Enumerator<Hash>

get_post_drafts

GET /2/posts/drafts Paginated Get Post Drafts Returns the authenticated user’s Post drafts, newest first, in the fields of the Create or Edit Post body. thread holds the Posts after the first. A draft with unsupported_content is not listed in full: do not publish it from this list or delete it unless the user asks. Needs the tweet.write scope.

Parameters

Returns: Enumerator<Hash>

get_quoted

GET /2/tweets/{id}/quote_tweets Paginated Get Quoted Posts Retrieves a list of Posts that quote a specific Post by its ID.

Parameters

String
required
id (path parameter).
Returns: Enumerator<Hash>

get_reposted_by

GET /2/tweets/{id}/retweeted_by Paginated Get Reposted By Retrieves a list of Users who reposted a specific Post by its ID.

Parameters

String
required
id (path parameter).
Returns: Enumerator<Hash>

get_reposts

GET /2/tweets/{id}/retweets Paginated Get Reposts Retrieves a list of Posts that repost a specific Post by its ID.

Parameters

String
required
id (path parameter).
Returns: Enumerator<Hash>

hide_reply

PUT /2/tweets/{tweet_id}/hidden Hide Reply Hides or unhides a reply to a conversation owned by the authenticated user.

Parameters

String
required
tweet_id (path parameter).
Hash
required
Request payload.
Returns: Hash

search_all

GET /2/tweets/search/all Paginated Search All Posts Retrieves Posts from the full archive matching a search query. At most one of start_time, since_id may be provided. At most one of end_time, until_id may be provided. At most one of pagination_token, next_token may be provided.

Parameters

String
required
query (query parameter).
Returns: Enumerator<Hash>

search_recent

GET /2/tweets/search/recent Paginated Search Recent Posts Retrieves Posts from the last 7 days matching a search query. At most one of start_time, since_id may be provided. At most one of end_time, until_id may be provided. At most one of pagination_token, next_token may be provided.

Parameters

String
required
query (query parameter).
Returns: Enumerator<Hash>