Skip to main content
Question

updateDraft, removes attachments from draft.

  • March 13, 2026
  • 2 replies
  • 11 views

zenithwang

I am currently using the Front sdk updateDraft function in the updateMode: ‘replace’ when I run it with only the subject defined, all attachments on the draft get deleted. 

     await sdk.updateDraft(draftId as Parameters<FrontSdk['updateDraft']>[0], {
updateMode: 'replace',
subject: subject
});

This is the current code I am using.

2 replies

Forum|alt.badge.img+5
  • Fronteer
  • March 13, 2026

Hi there!

Attachments are getting cleared because updateMode: 'replace' tells the SDK to overwrite the entire draft, and in that mode attachments are treated as “not specified ⇒ empty list”, which the backend interprets as “remove all attachments.”

On the server side, when a draft is updated, attachments are only modified if an attachments array is passed in the dependencies. If that array is present (even if empty), all existing attachments are replaced.

In updateMode: 'replace', the plugin SDK builds a full replacement payload for the draft. Because your call only specifies subject, the SDK ends up sending an empty attachments list for the draft, which the backend treats as “set attachments to []”, thereby removing all existing attachments.

How to avoid it

  • If you want to keep existing attachments, use an update mode that does a partial update (update / merge)
    or
  • Explicitly include the current attachments when calling updateDraft in replace mode (by first reading the draft, then passing its attachments back in).

zenithwang
  • Author
  • Conversationalist
  • March 13, 2026

Hi, thanks for the response.

 

How can I get the attachments list. I couldn’t find the relevant function or model value to retrieve it.

 

Further, in the documentation it only says there are 2 insert modes insert and replace. 

 

Are there actually more?