Skip to content

Drafts ​

Create, list, edit, and delete draft tweets. Drafts are private to your account.

drafts.list(opts?) ​

List your draft tweets. Uses the GraphQL FetchDraftTweets query.

OptionTypeDescription
opts.ascendingbooleanSort order (default false, newest first)
js
const drafts = await client.drafts.list();
// [{ rest_id, tweet_create_request: { status, ... } }, ...]

drafts.create(text, opts?) ​

Save a new draft. Uses the GraphQL CreateDraftTweet mutation.

OptionTypeDescription
textstringThe draft body
opts.mediaIdsstring[]Attached media ids (from the media upload flow)
opts.replyTostringTweet id this draft replies to
js
const res = await client.drafts.create("a thought for later");
const draftId = res.data.tweet.rest_id;

drafts.edit(draftId, text, opts?) ​

Replace a draft's content. Same opts as create. Uses the GraphQL EditDraftTweet mutation.

js
await client.drafts.edit(draftId, "a revised thought");

drafts.remove(draftId) ​

Delete a draft. Uses the GraphQL DeleteDraftTweet mutation.

js
await client.drafts.remove(draftId);

not affiliated with X Corp.