updateDraft

Update a draft message.

function updateDraft(draftId: string, update: object, cancelToken?: CancelToken): Promise<void>;

Parameters

ParameterTypeDescription
draftIdStringID of the draft to update.
updateObjectProperties of the draft to update.
update.toArray of String (optional)Handles to send the message to.
update.ccArray of String (optional)Handles to add in copy of the message. Supported only for email channels.
update.bccArray of String (optional)Handles to add in blind copy of the message. Supported only for email channels.
update.subjectString (optional)Subject of the message.
update.contentObject (optional)Content properties of the draft.
update.content.bodyStringContent of the message.
update.content.typeStringContent type of the body. Can be either html or text.
update.attachmentsArray of File (optional)Files to attach to the message.
update.updateModeString
cancelTokenCancelToken (optional)Token to cancel the request.

Content type

The type of the draft.content.body property is defined in draft.content.type. It can be either text or html.
Front will convert the content in a format that matches the teammate's composer preferences.

Update mode

When updating a draft, you need to set the updateMode. It can be one of

  • insert to insert the properties while keeping the existing ones. It will append the recipients and subject as well as insert the content where the caret is.
  • replace to replace the properties of the draft.

Return value

The function returns a promise that resolves with the draft message created.

Examples

Front.updateDraft('dra_uid:xxx', {
  updateMode: 'insert',
  content: {
    body: 'Please refer to this <a href="https://example.com">useful link</a>.',
    type: 'html'
  }
});
Front.updateDraft('dra_uid:xxx', {
  updateMode: 'replace',
  to: ['[email protected]'],
  // Make sure no recipient is cc'd or bcc'd.
  cc: [],
  bcc: []
});