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.
| Option | Type | Description |
|---|---|---|
opts.ascending | boolean | Sort 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.
| Option | Type | Description |
|---|---|---|
text | string | The draft body |
opts.mediaIds | string[] | Attached media ids (from the media upload flow) |
opts.replyTo | string | Tweet 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);drafts.removeMany(draftIds)
Untested
This mutation was built from the x.com web bundle and has not been run against a live account.
Delete several drafts in one request. Uses the GraphQL DeleteDraftTweets mutation, which the x.com drafts screen calls when you select more than one draft.
js
await client.drafts.removeMany(["1234567890", "1234567891"]);