draftId is the one every later call, including send_draft, must use.
Labels the user put on the draft are carried onto the replacement, so an edit does not quietly untag it.
The sender and the reply threading are not editable here. Changing who a message is from, or which conversation it belongs to, makes it a different message — stage that with create_draft.
Parameters
string
required
The draft to edit, as returned by
create_draft or a previous update_draft.string[]
Replace the recipients. Omit to keep them; pass
[] to clear them. Bare address or Name <address> form.string[]
Replace the carbon-copy recipients, same rules as
to.string[]
Replace the blind-copy recipients, same rules as
to.string
Replace the subject. Omit to keep it.
string
Replace the plain-text body. Omit to keep it. If the draft has both a plain-text and an HTML body, pass both or neither — see the note below.
string
Replace the HTML body. Omit to keep it. If the draft has both bodies, pass both or neither.
object[]
Replace the attached files, same entry shape as
create_draft: blobId or base64 content. filename is required with blobId — a blob carries no name of its own, and the one get_draft lists beside it is the one to pass — and optional but worth setting with content. mimeType is guessed from the filename’s extension when omitted.Omit to keep the files already attached — the rewrite re-references their blobs, so this transfers nothing. Pass [] to remove them all. Supplying a list replaces the whole thing, so to add a file, read the existing blobIds back with get_draft and list them alongside the new one.Example
Call
Result
Notes
- A draft with both bodies must have both replaced at once. Replacing only
texton a text+HTML draft is refused, because mail clients render the HTML alternative: the tool would report the corrected body and deliver the old one. - A draft whose body is too large to read back in full is refused rather than edited, since re-staging a truncated read would silently amputate the message.
- Attached files survive an edit that never mentions them. The rewrite re-references the blobs the draft already points at, so keeping them transfers nothing. Supplying
attachmentsreplaces the whole list instead — to add one more file, read the existingblobIds back withget_draftand list them alongside the new one; an empty array removes them all. - An attachment that cannot be re-referenced blocks the edit. A stored part with no
blobIdcould not be carried onto the replacement, and the original is destroyed on the way, so the loss would be permanent and reported as a success. Such a draft is left unchanged — edit it in Langmail, or passattachmentsexplicitly to say what the edited draft should carry. - An edit that changes nothing is refused too, and the existing
draftIdkeeps working. Replacing a draft for no change would invalidate every stored reference to it for no benefit.
Errors
Draft not found: <id>— no such message, or a stale id from before an earlier edit.<id> is not a draft — it has already been sent or received, and cannot be edited.Not a valid email address: …— a replacement recipient was malformed. Nothing was changed.This draft has both a plain-text and an HTML body, and only \text` was given…` — pass both, or stage a fresh draft.Draft <id> has a body too large to edit without risking losing part of it…Draft <id> carries a file this tool cannot carry across an edit (<names>), so it was left unchanged.The server refused this draft (invalidProperties).— most often an attachmentblobIdthe server does not recognise; blobIds belong to one account and do not outlive the message they were read from. The draft is left unchanged and its id still works.No changes were given, so draft <id> was left exactly as it is — its id still works.Note: the previous draft <id> could not be removed and is still in Drafts. It holds the PRE-EDIT content and is still sendable…— appended to a successful result when the replacement landed but the superseded draft couldn’t be retired. Send the new id, not the old one.