> ## 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 emails, alerts, and automated updates from your app.

Connect your Base44 app to Gmail to send emails based on events, data changes, or schedules in your app. Use Gmail to deliver alerts, approvals, digests, and reports, 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 event alerts" icon="bell">
    Email the right people when something happens in your app, such as a new ticket, approval, or failure.
  </Card>

  <Card title="Send scheduled digests" icon="calendar">
    Generate daily or weekly summaries of activity, metrics, or changes and email them automatically.
  </Card>

  <Card title="Notify your users" icon="envelope">
    Email a person when their own record changes, such as a document approval or status update.
  </Card>
</CardGroup>

**Example prompts for the AI chat**

```text theme={null}
Email me when a new high-priority ticket is created, including the ticket ID, title, and link.
```

```text theme={null}
Send a daily summary at 5pm with new signups grouped by plan.
```

```text theme={null}
Notify a user by email when their document is approved, with a link to the document page.
```

***

## 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 the **Action required** and **Required permissions** in the side panel.
    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, then each person connects their own account inside your app.

    **To prepare your connector details:**

    1. Create a Google OAuth app in [Google Cloud](https://cloud.google.com/) to get a Client ID and Client Secret.
    2. Add your Base44 redirect URIs to the OAuth app. See the card below.
    3. Note the scopes your app needs.

    <Card title="Redirect URIs" icon="link">
      Open **Connectors** in your workspace settings, click **View redirect URIs for your apps** under **Connectors For App Users**, and select your app. Add every redirect URI shown to your OAuth app. Each app has its own set (live, preview, and custom domain), so add all of them.
    </Card>

    **To add the connector:**

    1. In your workspace settings, open **Connectors**.
    2. Under **Connectors For App Users**, add Gmail and enter your **Client ID**, **Client Secret**, and **Scopes**.

    You can also add the connector from the AI chat in 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>

    **To connect an account:**

    Each person connects their own Gmail account inside your app. Prompt the AI chat to add a feature where people connect 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.
```

This is a simplified example. The setup and full code patterns are the same for every connector. See the developer guides for the complete pattern:

<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">
  * `gmail.send`: Send email messages.
  * `gmail.readonly`: Read email messages and metadata.
  * `gmail.modify`: Modify messages, for example mark as read or move to folders.
  * `gmail.compose`: Create draft messages.
</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">
    The redirect URI registered in your Google OAuth app must exactly match one shown in **View redirect URIs for your apps** for that app. Each app has its own set of redirect URIs, so add every URI shown 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 dashboard and click **Integrations**.
    2. Click the **My integrations** tab.
    3. 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-connectors).
  </Accordion>
</AccordionGroup>
