> ## Documentation Index
> Fetch the complete documentation index at: https://nango.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Gmail

> Integrate your application with the Gmail API

## 🚀 Quickstart

Connect to Gmail with Nango and see data flow in 2 minutes.

<Steps>
  <Step title="Create the integration">
    In Nango ([free signup](https://app.nango.dev)), go to [Integrations](https://app.nango.dev/dev/integrations) -> *Configure New Integration* -> *Gmail*.

    <Note>
      Nango has credentials you can use for testing. Activate them in the dashboard.
    </Note>
  </Step>

  <Step title="Authorize Gmail">
    Go to [Connections](https://app.nango.dev/dev/connections) -> *Add Test Connection* -> *Authorize*, then log in to Gmail. Later, you'll let your users do the same directly from your app.
  </Step>

  <Step title="Call the Gmail API">
    Let's make your first request to the Gmail API (fetch the profile of the currently signed-in user). This request will return basic details about the authenticated user, such as their email address and message/thread counts. Replace the placeholders below with your [secret key](https://app.nango.dev/dev/environment-settings), [integration ID](https://app.nango.dev/dev/integrations), and [connection ID](https://app.nango.dev/dev/connections):

    <Tabs>
      <Tab title="cURL">
        ```bash theme={null}
        curl "https://api.nango.dev/proxy/gmail/v1/users/me/profile" \
          -H "Authorization: Bearer <NANGO-SECRET-KEY>" \
          -H "Provider-Config-Key: <INTEGRATION-ID>" \
          -H "Connection-Id: <CONNECTION-ID>"
        ```
      </Tab>

      <Tab title="Node">
        Install Nango's backend SDK with `npm i @nangohq/node`. Then run:

        ```typescript theme={null}
        import { Nango } from '@nangohq/node';

        const nango = new Nango({ secretKey: '<NANGO-SECRET-KEY>' });

        const res = await nango.get({
            endpoint: '/gmail/v1/users/me/profile',
            providerConfigKey: '<INTEGRATION-ID>',
            connectionId: '<CONNECTION-ID>'
        });

        console.log(res.data);
        ```
      </Tab>
    </Tabs>

    Or fetch credentials dynamically via the [Node SDK](/reference/sdks/node#get-a-connection-with-credentials) or [API](/reference/api/connection/get).

    ✅ You're connected! Check the [Logs](https://app.nango.dev/dev/logs) tab in Nango to inspect requests.
  </Step>

  <Step title="Implement Nango in your app">
    Follow our [Auth implementation guide](/guides/primitives/auth) to integrate Nango in your app.

    To obtain your own production credentials, follow the setup guide linked below.
  </Step>
</Steps>

## 📚 Gmail Integration Guides

Nango maintained guides for common use cases.

* [How to register your own Gmail OAuth app](/api-integrations/google-mail/how-to-register-your-own-gmail-api-oauth-app)\
  Register an OAuth app with Gmail and obtain credentials to connect it to Nango

* [How to setup webhooks with Gmail on Nango](/api-integrations/google-mail/webhooks)
  Set up Gmail push notifications using Google Pub/Sub to receive real-time inbox updates

* [Google App & Security Review](/api-integrations/google-shared/google-security-review)
  Pass Google's OAuth app verification and CASA security assessment to go to production

Official docs: [Gmail API docs](https://developers.google.com/gmail/api/reference/rest)

## 🧩 Pre-built syncs & actions for Gmail

Enable them in your dashboard. Extend and customize to fit your needs.

### Attachments

| Function name    | Description                                                      | Type                                         | Source code                                                                                                                |
| ---------------- | ---------------------------------------------------------------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `get-attachment` | Retrieve a specific message attachment payload by attachment ID. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-attachment.ts) |

### Drafts

| Function name  | Description                                              | Type                                         | Source code                                                                                                              |
| -------------- | -------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `create-draft` | Create a Gmail draft message from RFC 2822 MIME content. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/create-draft.ts) |
| `delete-draft` | Delete an existing draft by draft ID                     | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/delete-draft.ts) |
| `get-draft`    | Retrieve a draft and its embedded message payload.       | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-draft.ts)    |
| `list-drafts`  | List drafts in the mailbox with pagination support.      | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-drafts.ts)  |
| `send-draft`   | Send an existing draft message                           | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/send-draft.ts)   |
| `update-draft` | Replace an existing draft with new MIME content.         | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-draft.ts) |

### Filters

| Function name   | Description                                                    | Type                                         | Source code                                                                                                               |
| --------------- | -------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `create-filter` | Create a mailbox filter with match criteria and label actions. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/create-filter.ts) |
| `delete-filter` | Delete a mailbox filter by filter ID                           | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/delete-filter.ts) |
| `get-filter`    | Retrieve a mailbox filter by filter ID.                        | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-filter.ts)    |
| `list-filters`  | List mailbox filters configured for the authenticated user     | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-filters.ts)  |

### Forwarding Addresses

| Function name               | Description                                               | Type                                         | Source code                                                                                                                           |
| --------------------------- | --------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `delete-forwarding-address` | Delete a forwarding address from Gmail settings.          | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/delete-forwarding-address.ts) |
| `get-forwarding-address`    | Retrieve a forwarding address configured for the mailbox. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-forwarding-address.ts)    |

### History

| Function name        | Description                                           | Type                                         | Source code                                                                                                                    |
| -------------------- | ----------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `list-watch-history` | List mailbox history records after a given history ID | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-watch-history.ts) |

### Labels

| Function name  | Description                                                | Type                                         | Source code                                                                                                              |
| -------------- | ---------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `create-label` | Create a new user label with visibility settings.          | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/create-label.ts) |
| `delete-label` | Delete a user-created label                                | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/delete-label.ts) |
| `get-label`    | Retrieve a single Gmail label by label ID.                 | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-label.ts)    |
| `list-labels`  | List built-in and user-created mailbox labels.             | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-labels.ts)  |
| `update-label` | Update a user-created label's name or visibility settings. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-label.ts) |

### Messages

| Function name           | Description                                                       | Type                                         | Source code                                                                                                                       |
| ----------------------- | ----------------------------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `batch-delete-messages` | Permanently delete multiple Gmail messages by ID                  | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/batch-delete-messages.ts) |
| `batch-modify-messages` | Add and remove labels on multiple Gmail messages at once.         | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/batch-modify-messages.ts) |
| `delete-message`        | Permanently delete a Gmail message by ID.                         | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/delete-message.ts)        |
| `get-message`           | Retrieve a specific Gmail message with optional format selection. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-message.ts)           |
| `list-messages`         | List messages matching Gmail query and label filters.             | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-messages.ts)         |
| `modify-message`        | Add and remove labels on a Gmail message                          | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/modify-message.ts)        |
| `send-message`          | Send an email message through Gmail using raw MIME content.       | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/send-message.ts)          |
| `trash-message`         | Move a Gmail message to trash                                     | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/trash-message.ts)         |
| `untrash-message`       | Restore a trashed Gmail message to the mailbox.                   | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/untrash-message.ts)       |

### Send As Aliases

| Function name          | Description                                                     | Type                                         | Source code                                                                                                                      |
| ---------------------- | --------------------------------------------------------------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `update-send-as-alias` | Update send-as alias settings such as display name or reply-to. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-send-as-alias.ts) |

### SendAs

| Function name             | Description                                       | Type                                         | Source code                                                                                                                         |
| ------------------------- | ------------------------------------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `delete-send-as-alias`    | Delete a custom send-as alias from the mailbox.   | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/delete-send-as-alias.ts)    |
| `list-send-as-aliases`    | List send-as aliases available for the mailbox.   | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-send-as-aliases.ts)    |
| `update-send-as-smtp-msa` | Update the SMTP MSA settings for a send-as alias. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-send-as-smtp-msa.ts) |

### Settings

| Function name                     | Description                                           | Type                                         | Source code                                                                                                                                 |
| --------------------------------- | ----------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `create-send-as-alias`            | Create a custom send-as alias for the mailbox         | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/create-send-as-alias.ts)            |
| `get-auto-forwarding-settings`    | Retrieve the mailbox auto-forwarding configuration.   | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-auto-forwarding-settings.ts)    |
| `get-imap-settings`               | Retrieve IMAP settings for the mailbox                | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-imap-settings.ts)               |
| `get-language-settings`           | Retrieve Gmail language settings for the mailbox.     | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-language-settings.ts)           |
| `get-pop-settings`                | Retrieve POP settings for the mailbox.                | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-pop-settings.ts)                |
| `get-send-as-alias`               | Retrieve a configured send-as alias                   | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-send-as-alias.ts)               |
| `get-vacation-settings`           | Retrieve the mailbox vacation responder settings.     | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-vacation-settings.ts)           |
| `list-forwarding-addresses`       | List forwarding addresses configured for the mailbox. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-forwarding-addresses.ts)       |
| `update-auto-forwarding-settings` | Update Gmail auto-forwarding behavior and disposition | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-auto-forwarding-settings.ts) |
| `update-imap-settings`            | Update IMAP enablement and visibility settings.       | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-imap-settings.ts)            |
| `update-language-settings`        | Update the mailbox display language                   | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-language-settings.ts)        |
| `update-pop-settings`             | Update POP access settings for the mailbox            | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-pop-settings.ts)             |
| `update-vacation-settings`        | Update the mailbox vacation responder configuration.  | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/update-vacation-settings.ts)        |
| `verify-send-as-alias`            | Trigger verification for a custom send-as alias       | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/verify-send-as-alias.ts)            |

### Threads

| Function name    | Description                                                       | Type                                         | Source code                                                                                                                |
| ---------------- | ----------------------------------------------------------------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `get-thread`     | Retrieve a Gmail thread and its messages.                         | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/get-thread.ts)     |
| `list-threads`   | List conversation threads matching Gmail query and label filters. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/list-threads.ts)   |
| `modify-thread`  | Add and remove labels across a Gmail thread.                      | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/modify-thread.ts)  |
| `trash-thread`   | Move a Gmail thread to trash.                                     | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/trash-thread.ts)   |
| `untrash-thread` | Restore a trashed Gmail thread to the mailbox.                    | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/untrash-thread.ts) |

### Watch

| Function name   | Description                                               | Type                                         | Source code                                                                                                               |
| --------------- | --------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `stop-watch`    | Stop Gmail push notification watch state for the mailbox. | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/stop-watch.ts)    |
| `watch-mailbox` | Start Gmail push notifications for mailbox changes.       | [Action](/guides/functions/action-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/watch-mailbox.ts) |

### Others

| Function name     | Description                                                                                 | Type                                           | Source code                                                                                                               |
| ----------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `delete-thread`   | Permanently delete a Gmail thread and its messages.                                         | [Action](/guides/functions/action-functions)   | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/actions/delete-thread.ts) |
| `filters`         | Sync Gmail mailbox filters and their criteria or actions.                                   | [Sync](/guides/functions/syncs/sync-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/syncs/filters.ts)         |
| `labels`          | Sync built-in and user-created Gmail labels.                                                | [Sync](/guides/functions/syncs/sync-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/syncs/labels.ts)          |
| `messages`        | Sync Gmail messages with an initial backfill followed by history-based incremental updates. | [Sync](/guides/functions/syncs/sync-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/syncs/messages.ts)        |
| `send-as-aliases` | Sync configured Gmail send-as aliases and alias settings                                    | [Sync](/guides/functions/syncs/sync-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/syncs/send-as-aliases.ts) |
| `threads`         | Sync Gmail conversation threads with full message hydration                                 | [Sync](/guides/functions/syncs/sync-functions) | [🔗 Github](https://github.com/NangoHQ/integration-templates/blob/main/integrations/google-mail/syncs/threads.ts)         |

***
