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

Methods

CreateAsync

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

CreatePostsRequest
required
Request payload.
Returns: Task<CreatePostsResponse>

CreatePostDraftAsync

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

CreatePostDraftRequest
required
Request payload.
Returns: Task<CreatePostDraftResponse>

DeleteAsync

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: Task<DeletePostsResponse>

DeletePostDraftAsync

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: Task<DeletePostDraftResponse>

GetAnalyticsAsync

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

Parameters

List<string>
required
ids (query parameter).
string
required
start_time (query parameter).
string
required
end_time (query parameter).
Returns: Task<GetPostsAnalyticsResponse>

GetByIdAsync

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

Parameters

string
required
id (path parameter).
Returns: Task<GetPostsByIdResponse>

GetByIdsAsync

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

Parameters

List<string>
required
ids (query parameter).
Returns: Task<GetPostsByIdsResponse>

GetCountsAllAsync

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: Task<GetPostsCountsAllResponse> (use GetCountsAllPages(...) for IAsyncEnumerable page iteration)

GetCountsRecentAsync

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: Task<GetPostsCountsRecentResponse> (use GetCountsRecentPages(...) for IAsyncEnumerable page iteration)

GetLikingUsersAsync

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: Task<GetPostsLikingUsersResponse> (use GetLikingUsersPages(...) for IAsyncEnumerable page iteration)

GetPostDraftsAsync

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: Task<GetPostDraftsResponse> (use GetPostDraftsPages(...) for IAsyncEnumerable page iteration)

GetQuotedAsync

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: Task<GetPostsQuotedPostsResponse> (use GetQuotedPages(...) for IAsyncEnumerable page iteration)

GetRepostedByAsync

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: Task<GetPostsRepostedByResponse> (use GetRepostedByPages(...) for IAsyncEnumerable page iteration)

GetRepostsAsync

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: Task<GetPostsRepostsResponse> (use GetRepostsPages(...) for IAsyncEnumerable page iteration)

HideReplyAsync

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).
HidePostsReplyRequest
required
Request payload.
Returns: Task<HidePostsReplyResponse>

SearchAllAsync

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: Task<SearchPostsAllResponse> (use SearchAllPages(...) for IAsyncEnumerable page iteration)

SearchRecentAsync

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: Task<SearchPostsRecentResponse> (use SearchRecentPages(...) for IAsyncEnumerable page iteration)