---
updatedAt: 2025-01-08T23:23:48.000Z
agentTools:
  projectIndex: https://dev.frontapp.com/llms.txt
---

# updateDraft

Update a draft message.

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

## Parameters

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th style={{ textAlign: "left" }}>
        Parameter
      </th>

      <th style={{ textAlign: "left" }}>
        Type
      </th>

      <th style={{ textAlign: "left" }}>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td style={{ textAlign: "left" }}>
        `draftId`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        ID of the draft to update.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update`
      </td>

      <td style={{ textAlign: "left" }}>
        Object
      </td>

      <td style={{ textAlign: "left" }}>
        Properties of the draft to update.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.to`
      </td>

      <td style={{ textAlign: "left" }}>
        Array of String (optional)
      </td>

      <td style={{ textAlign: "left" }}>
        Handles to send the message to.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.cc`
      </td>

      <td style={{ textAlign: "left" }}>
        Array of String (optional)
      </td>

      <td style={{ textAlign: "left" }}>
        Handles to add in copy of the message. Supported only for email channels.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.bcc`
      </td>

      <td style={{ textAlign: "left" }}>
        Array of String (optional)
      </td>

      <td style={{ textAlign: "left" }}>
        Handles to add in blind copy of the message. Supported only for email channels.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.subject`
      </td>

      <td style={{ textAlign: "left" }}>
        String (optional)
      </td>

      <td style={{ textAlign: "left" }}>
        Subject of the message.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.content`
      </td>

      <td style={{ textAlign: "left" }}>
        Object (optional)
      </td>

      <td style={{ textAlign: "left" }}>
        Content properties of the draft.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.content.body`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        Content of the message.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.content.type`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>
        Content type of the body. Can be either `html` or `text`.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.attachments`
      </td>

      <td style={{ textAlign: "left" }}>
        Array of File (optional)
      </td>

      <td style={{ textAlign: "left" }}>
        Files to attach to the message.
      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `update.updateMode`
      </td>

      <td style={{ textAlign: "left" }}>
        String
      </td>

      <td style={{ textAlign: "left" }}>

      </td>
    </tr>

    <tr>
      <td style={{ textAlign: "left" }}>
        `cancelToken`
      </td>

      <td style={{ textAlign: "left" }}>
        [CancelToken](https://dev.frontapp.com/reference/plugin-sdk-cancel-token) (optional)
      </td>

      <td style={{ textAlign: "left" }}>
        Token to cancel the request.
      </td>
    </tr>
  </tbody>
</Table>

### 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](https://dev.frontapp.com/reference/plugin-sdk-message)  created.

## Examples

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