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

# Connecting Gmail to your app

> Connect Base44 to Gmail to send, read, and manage emails from your app.

Connect your Base44 app to Gmail to send, read, and manage emails. Use Gmail to deliver alerts, approvals, and reports, to turn incoming messages into records in your app, and to trigger flows when new mail arrives, either from one shared account or from each person's own inbox.

<Tip>
  **Which type should you use?** Use a **connector for app builders** when your app sends email from one Gmail account for everyone, for example an ops inbox that emails weekly reports. Use a **connector for app users** when each person sends email from their own Gmail account.
</Tip>

<Note>
  You need a [**Builder plan**](https://base44.com/pricing) or higher to use connectors in your app.
</Note>

***

## What you can do

<CardGroup cols={3}>
  <Card title="Send email automatically" icon="envelope">
    Send confirmations, alerts, and personalized follow-ups when something happens in your app.
  </Card>

  <Card title="Read incoming email" icon="inbox">
    Read and parse messages that arrive, then turn them into records such as support tickets.
  </Card>

  <Card title="Manage the inbox" icon="tags">
    Organize mail as your app works through it, for example mark messages as read or apply labels.
  </Card>
</CardGroup>

**Example prompts for the AI chat**

```text theme={null}
Send automated confirmation emails when a new order is placed.
```

```text theme={null}
Read and parse incoming emails to create support tickets.
```

```text theme={null}
Trigger a workflow automatically when a new email arrives.
```

```text theme={null}
Send personalized follow-up emails to new leads.
```

```text theme={null}
Notify team members via email when tasks are assigned.
```

***

## At a glance

<Card>
  <div className="b44-spec">
    <div className="b44-spec-row"><div className="b44-spec-key">Type identifier</div><div className="b44-spec-val"><code>gmail</code></div></div>
    <div className="b44-spec-row"><div className="b44-spec-key">Auth model</div><div className="b44-spec-val">OAuth</div></div>
    <div className="b44-spec-row"><div className="b44-spec-key">Connector types</div><div className="b44-spec-val">For app builders, For app users</div></div>
    <div className="b44-spec-row"><div className="b44-spec-key">Connection config</div><div className="b44-spec-val">None</div></div>
    <div className="b44-spec-row"><div className="b44-spec-key">Permissions guide</div><div className="b44-spec-val"><a href="#gmail-scopes-and-permissions">Gmail scopes and permissions</a></div></div>
  </div>
</Card>

***

## Connect it

<Tabs>
  <Tab title="For app builders">
    Connect one Gmail account that all flows in your app use.

    **To connect Gmail:**

    1. Go to your app editor.
    2. Describe what you want to do with Gmail in the AI chat, for example: `Connect this app to Gmail and email me when a new ticket is created.`
    3. Review what the AI chat asks for under **We need your permission to access**.
    4. Click **Connect to Gmail**.
    5. In the Google window, select the account you want to connect, review the permissions, and click **Allow**.
    6. Return to the editor and let the AI finish creating the flows that use Gmail.
  </Tab>

  <Tab title="For app users">
    Let each person using your app connect their own Gmail account. An admin sets up the connector once at the workspace level, from workspace settings or from the AI chat, then each person connects their own account inside your app.

    <Warning>
      Treat your Client Secret like a password. Do not share it or include it in screenshots. Only enter it when Base44 asks for it during setup.
    </Warning>

    ### Prepare your connector

    Set up a Google OAuth app and gather its details before you add the connector in Base44.

    **To prepare your connector:**

    1. Create a Google OAuth app in [Google Cloud](https://cloud.google.com/) to get a **Client ID** and a **Client Secret**.
    2. Note the scopes your app needs. See [Gmail scopes and permissions](#gmail-scopes-and-permissions).
    3. Register your redirect URIs with the OAuth app. See the card below.

    <Card title="Register your callback URL" icon="link">
      Register this callback URL with your Google OAuth app. It works for every app in your workspace, including your live, preview, share, and custom domain URLs:

      `https://connectors.base44.com/api/oauth/callback`

      If you set this connector up before Base44 moved to a single callback URL, it still uses a separate URI for each app host. Open **Workspace Settings → Connectors**, click **View redirect URIs for your apps** under **Connectors For App Users**, select your app, and register every URI listed under **Per-app URLs (for legacy connectors)**.
    </Card>

    ### Add the connector

    **To add the connector:**

    1. Click your workspace name at the bottom left.
    2. Click **Settings**.
    3. Click **Connectors** under **Plugins**.
    4. Under **Connectors For App Users**, click **Add Connector**.
    5. Click **Gmail**.
    6. In the connector details, click **Add Connector**.
    7. Enter a **Connector name**, then the **Client ID** and **Client Secret** from your Google OAuth app.
    8. Under **Scopes**, open the suggested scopes drop-down and select the scopes your app needs. Use **Additional scopes** only for scopes that are not listed.
    9. Click **Add Connector**.

    ### Let people connect

    Each person connects their own Gmail account inside your app. Prompt the AI chat to add a feature where people sign in with Gmail, then each person connects their own account when they use it.
  </Tab>
</Tabs>

***

## Use it in a backend function

Once Gmail is connected, your backend functions can retrieve an access token and call the Gmail API directly. Base44 handles the OAuth flow and token storage.

* For a shared connection, use `getConnection()` to retrieve the token.
* For an app user connection, use `getCurrentAppUserConnection()` so each request uses the signed-in person's token.

```javascript theme={null}
// Shared connection: one account the whole app uses
const connection = await base44.asServiceRole.connectors.getConnection("gmail");
// Use the connection's access token to call the Gmail API.
```

<CardGroup cols={2}>
  <Card title="Shared connectors" icon="code" href="/developers/backend/resources/connectors/shared-connectors">
    Configure, deploy, and call a shared connection from a backend function.
  </Card>

  <Card title="App user connectors" icon="user" href="/developers/backend/resources/connectors/app-user-connectors">
    Retrieve a per-user token and call the API as the signed-in person.
  </Card>
</CardGroup>

***

## Gmail scopes and permissions

When you connect Gmail, the connector requests permissions (scopes) that control what your app can do with your Gmail account. Below is the current list of Gmail scopes the connector may request.

<Card title="Gmail scopes" icon="shield">
  * `email`: Identify the Google account being connected.
  * `https://www.googleapis.com/auth/gmail.readonly`: Read messages and metadata.
  * `https://www.googleapis.com/auth/gmail.send`: Send messages.
  * `https://www.googleapis.com/auth/gmail.labels`: Manage labels.
  * `https://www.googleapis.com/auth/gmail.modify`: Modify messages, for example mark as read or apply a label.
  * `https://www.googleapis.com/auth/gmail.compose`: Create and update drafts.
  * `https://www.googleapis.com/auth/gmail.settings.basic`: Manage basic mail settings, such as filters, signatures, and the vacation responder.
</Card>

<Note>
  Scope lists may change over time. Always review the permissions shown during the connection flow.
</Note>

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="The connection fails with a redirect URI error">
    Check that `https://connectors.base44.com/api/oauth/callback` is registered in your Google OAuth app, exactly as shown. If the connector still uses per-app URLs, the URI in your OAuth app must instead match one shown under **Per-app URLs (for legacy connectors)** in **View redirect URIs for your apps**, so register every URI listed there for the app you are connecting.
  </Accordion>

  <Accordion title="Some people cannot connect their account">
    If your Google OAuth app is in testing mode, only approved test users can connect. Publish or move your OAuth app out of testing mode so anyone using your app can connect their own account.
  </Accordion>
</AccordionGroup>

***

## FAQs

<AccordionGroup>
  <Accordion title="How do I change which Gmail account is connected?">
    1. Go to your app's dashboard.
    2. Click **Integrations**.
    3. Click the **My integrations** tab.
    4. Find **Gmail** and click the **More Actions** icon <Icon icon="ellipsis" />, then **Switch account**.
  </Accordion>

  <Accordion title="Can I customize the content of emails sent from my app?">
    Yes. In the AI chat, specify the subject line, message body, formatting, recipients, and any dynamic fields.

    You can also edit the generated backend functions in **Dashboard → Code → Functions** to further customize the email payload.
  </Accordion>

  <Accordion title="Can each person using my app send from their own Gmail inbox?">
    Yes. Use a **connector for app users** so each person connects their own Gmail account. See the [connectors overview](/Integrations/Connectors).
  </Accordion>

  <Accordion title="How do I manage the Gmail connector in my app?">
    Click the **More actions** icon on the connector in your app's **Integrations** tab, then choose an option such as switch account, reconnect, or disconnect. [Learn more about managing connectors](/Integrations/Connectors#managing-your-connectors).
  </Accordion>
</AccordionGroup>
