# Drafts

Source: https://developer.nylas.com/docs/reference/api/drafts/

Drafts represent messages that have been composed, but not yet sent. The Nylas Email API uses the same commands to manage drafts across providers, and can refer to specific drafts using the provider's `draft_id`.

The `/drafts` endpoints allow you to create and save drafts without sending them immediately. A draft may contain all components of a standard message, including recipients, a subject, body content, and attachments. The endpoints offer full Create, Read, Update, and Delete (CRUD) functions.

## Adding attachments to drafts

You use the Drafts endpoints to create and modify draft messages, including the files attached to them. The [Attachments APIs](#tag--Attachments) allow you to download or get the metadata about an existing attachment, but you use the Drafts API to add or modify the attachments. For more information, see [Working with email attachments](/docs/v3/email/attachments/).

When you add attachments to a draft, the format you use depends on the total size of the HTTP payload of your message. If the total size is more than 3MB, you must use the `multipart/form-data` schema. This format is subject to provider limits of 25MB for the full request.

## Metadata on drafts

You can add metadata to new and existing drafts by including the `metadata` sub-object in your `POST`, `PUT`, or `PATCH` request. For more information, see the [Metadata documentation](/docs/dev-guide/metadata/).

## Drafts scopes

The table below lists the Drafts endpoints and which scopes they require. The table shortens the full scope URI for space reasons, so add the prefix for the provider when requesting scopes.

The ☑️ in each column indicates the most restrictive scope you can request for each provider and still use that API. More permissive scopes appear under the minimum option. If you're already using one of the permissive scopes, you don't need to add the more restrictive scope.

| Endpoint                                                                                | Google Scopes</br>`https://www.googleapis.com/auth/...` | Microsoft Scopes</br>`https://graph.microsoft.com/...`                                 |
| :-------------------------------------------------------------------------------------- | :------------------------------------------------------ | :------------------------------------------------------------------------------------- |
| **GET** `/drafts`</br>**GET** `/drafts/<DRAFT_ID>`                                      | `/gmail.readonly` ☑️</br>`/gmail.compose`               | `Mail.Read` ☑️</br>`Mail.ReadWrite`</br>`Mail.Read.Shared`</br>`Mail.ReadWrite.Shared` |
| **POST** `/drafts`</br>**PUT** `/drafts/<DRAFT_ID>`</br>**DELETE** `/drafts/<DRAFT_ID>` | `/gmail.compose` ☑️                                     | `Mail.ReadWrite` ☑️</br>`Mail.ReadWrite.Shared`                                        |
| **POST** `/drafts/<DRAFT_ID>`                                                           | `/gmail.compose` ☑️</br>`/gmail.modify`                 | `Mail.ReadWrite` ☑️</br>`Mail.ReadWrite.Shared`                                        |

For more information about scopes, see [Using scopes to request user data](/docs/dev-guide/scopes/).

## Query IMAP server directly

Set the `query_imap` query parameter to `true` in your [Get Draft](/docs/reference/api/drafts/get-draft-id/) or [Get all Drafts](/docs/reference/api/drafts/get-drafts/) requests to query the IMAP server directly instead of the Nylas database. This lets you get the most up-to-date information from the IMAP server, or data older than the default three-month retention time.

When you use the `query_imap` query parameter in a Get all Drafts request, Nylas includes the specified folder ID only in the returned drafts' `folder` fields, even if the draft is in multiple folders.

Keep in mind that most IMAP servers are slow and have low [rate limits](/docs/dev-guide/platform/rate-limits/). Nylas might take more time to return responses compared to requests that don't use the `query_imap` query parameter. If an account has many folders, you're querying for a large draft, or you're also using the `has_attachment` query parameter, your request can take even longer.

## EWS query considerations

You _must_ enable search indexing for all mailboxes on your on-premises Microsoft Exchange server configuration for Nylas query parameters to work correctly.


## Endpoints

- **GET** `/v3/grants/{grant_id}/drafts` - [Return all Drafts](https://developer.nylas.com/docs/reference/api/drafts/get-drafts/)
- **POST** `/v3/grants/{grant_id}/drafts` - [Create a Draft](https://developer.nylas.com/docs/reference/api/drafts/post-draft/)
- **GET** `/v3/grants/{grant_id}/drafts/{draft_id}` - [Return a Draft](https://developer.nylas.com/docs/reference/api/drafts/get-draft-id/)
- **POST** `/v3/grants/{grant_id}/drafts/{draft_id}` - [Send a Draft](https://developer.nylas.com/docs/reference/api/drafts/send-draft-id/)
- **PUT** `/v3/grants/{grant_id}/drafts/{draft_id}` - [Update a draft](https://developer.nylas.com/docs/reference/api/drafts/put-drafts-id/)
- **DELETE** `/v3/grants/{grant_id}/drafts/{draft_id}` - [Delete a Draft](https://developer.nylas.com/docs/reference/api/drafts/delete-drafts-id/)
