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

# Gmail Integration for AI Agents & Workflows

> Google Gmail email service for sending, reading, and managing emails.

{/* Self-hosted logo — build-time vendored from modulex.json / Iconify (see scripts/lib/logo.js). */}

<img src="https://mintcdn.com/modulexaillc/zKB2qsP6Q61VNLfB/logos/gmail.svg?fit=max&auto=format&n=zKB2qsP6Q61VNLfB&q=85&s=e5cdccb03259a64652ca2e06fbc7c57e" alt="Gmail logo" width="72" height="72" data-path="logos/gmail.svg" />

## Overview

Add **Gmail** to any ModuleX agent or workflow. Gmail integration via the Gmail REST v1 API (`www.googleapis.com/gmail/v1`). Send email + list labels. Pure HTTP — does **not** depend on the `google-api-python-client` SDK.

<Info>
  **Categories**: Communication · Communication & Collaboration · Email · Productivity · **Auth**: OAuth2, Service Account / Access Token · **Actions**: 2
</Info>

## Authentication

<Tabs>
  <Tab title="OAuth2">
    ### OAuth2 Authentication

    Connect using Google OAuth2 (recommended). Provides secure access to Gmail.

    #### Required Credentials

    | Field         | Description                                       | Required | Format                                                  |
    | ------------- | ------------------------------------------------- | -------- | ------------------------------------------------------- |
    | Client ID     | Google OAuth2 Client ID from Google Cloud Console | Yes      | `123456789-xxxxxxxxxxxxxxxx.apps.googleusercontent.com` |
    | Client Secret | Google OAuth2 Client Secret                       | Yes      | `-`                                                     |

    #### OAuth Configuration

    * **Authorization URL**: `https://accounts.google.com/o/oauth2/v2/auth`
    * **Token URL**: `https://oauth2.googleapis.com/token`
    * **Scopes**: `https://www.googleapis.com/auth/gmail.send`, `https://www.googleapis.com/auth/gmail.labels`
  </Tab>

  <Tab title="Service Account / Access Token">
    ### Service Account / Access Token

    Use a pre-generated access token or service account credentials

    #### Required Credentials

    | Field        | Description                                          | Required | Format |
    | ------------ | ---------------------------------------------------- | -------- | ------ |
    | Access Token | A valid Google OAuth2 access token with Gmail scopes | Yes      | `-`    |
  </Tab>
</Tabs>

## Available Actions

<AccordionGroup>
  <Accordion title="send_message — Send a new email via Gmail">
    ### Parameters

    <ResponseField name="to" type="string" required>
      Recipient email address
    </ResponseField>

    <ResponseField name="subject" type="string" required>
      Email subject line
    </ResponseField>

    <ResponseField name="body" type="string" required>
      Email body content
    </ResponseField>

    <ResponseField name="cc" type="string">
      CC recipients (comma-separated)
    </ResponseField>

    <ResponseField name="bcc" type="string">
      BCC recipients (comma-separated)
    </ResponseField>

    <ResponseField name="is_html" type="boolean">
      Whether the body is HTML content (Default: `false`)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Id"
        },
        "thread_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Thread Id"
        },
        "label_ids": {
          "items": {
            "type": "string"
          },
          "title": "Label Ids",
          "type": "array"
        }
      },
      "required": [
        "success"
      ],
      "title": "SendMessageOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="list_labels — List all available Gmail labels">
    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "labels": {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "title": "Labels",
          "type": "array"
        },
        "total": {
          "default": 0,
          "title": "Total",
          "type": "integer"
        }
      },
      "required": [
        "success"
      ],
      "title": "ListLabelsOutput",
      "type": "object"
    }
    ```
  </Accordion>
</AccordionGroup>

## Limits & Quotas

* `send_message` builds a base64url-encoded MIME message locally
  (no SDK dep).
* Sending is limited to 500 messages/day (consumer accounts) or
  2000/day (Google Workspace).
* 60s timeout for send, 30s for label listing.

## Related integrations

<CardGroup cols={3}>
  <Card title="Microsoft Outlook" href="/integrations/tools/microsoft-outlook" />

  <Card title="AgentMail" href="/integrations/tools/agentmail" />

  <Card title="Mailgun" href="/integrations/tools/mailgun" />
</CardGroup>

## Links

* [Gmail](https://mail.google.com)
