Scale Plan Required: The Gmail connector is available on Scale and Enterprise plans only.
Quick Setup
1. Create Gmail Connection
- TypeScript
- Python
- cURL
2. Handle OAuth Callback
After user grants permissions, Google redirects to your callback URL. The connection is automatically established and the initial sync begins.3. Check Connection Status
- TypeScript
- Python
- cURL
What Gets Synced
Email Threads
Gmail threads (conversations) are synced as individual documents with all messages included:- Thread content converted to structured markdown
- All messages within each thread preserved in order
- Message metadata: subject, from, to, cc, bcc, date
- HTML content converted to clean markdown
- Attachment metadata: filename, mime type, size (attachments are referenced, not stored)
Document Metadata
Each synced thread includes searchable metadata:| Field | Description |
|---|---|
type | Always gmail_thread |
subject | Email subject line |
threadId | Gmail thread ID |
from | Sender email address |
to | Recipient email addresses |
date | Date of first message |
messageCount | Number of messages in thread |
attachmentCount | Number of attachments (if any) |
attachmentNames | List of attachment filenames |
Connection Management
List All Connections
- TypeScript
- Python
- cURL
Delete Connection
- TypeScript
- Python
- cURL
Deleting a connection will:
- Stop all future syncs from Gmail
- Remove the OAuth authorization
- Keep existing synced documents in supermemory (they won’t be deleted)
Manual Sync
Trigger a manual synchronization:- TypeScript
- Python
- cURL
Sync Mechanism
Gmail connector supports multiple sync methods:| Feature | Behavior |
|---|---|
| Real-time sync | Via Google Cloud Pub/Sub webhooks (7-day expiry, auto-renewed) |
| Scheduled sync | Every 4 hours |
| Manual sync | On-demand via API |
| Incremental sync | Uses Gmail historyId to fetch only changed threads |
How Real-time Sync Works
- When a connection is created, supermemory registers a Gmail API “watch” subscription
- Gmail sends notifications to a Google Cloud Pub/Sub topic when emails change
- supermemory receives these notifications and fetches updated threads
- Watch subscriptions expire after 7 days and are automatically renewed
Real-time sync monitors the INBOX label. Emails in other labels are synced via scheduled/manual sync.
Permissions & Scopes
The Gmail connector requests the following OAuth scopes:| Scope | Purpose |
|---|---|
gmail.readonly | Read-only access to Gmail messages and threads |
userinfo.email | Access to user’s email address for connection identification |
Limitations
Troubleshooting
OAuth Fails or Missing Refresh Token
If OAuth fails or the connection stops syncing:- Delete the existing connection
- Create a new connection
- Ensure the user completes the full OAuth flow with consent
Emails Not Syncing in Real-time
If real-time sync isn’t working:- Scheduled sync (every 4 hours) and manual sync still work
- Real-time sync requires supermemory’s Pub/Sub infrastructure
- Check if the connection was created recently (watch registration happens on creation)
- Trigger a manual sync to verify the connection is working
Permission Denied Errors
If you see permission errors:- Ensure the user granted the required Gmail scopes during OAuth
- Verify your organization has Scale Plan or Enterprise Plan access
- Check if the user revoked app access in their Google Account settings