Gmail
Full Gmail API integration with managed OAuth β read, send, search, label, and manage emails, threads, and drafts directly from your AI agent.
by
byungkyu
Gmail Overview
Gmail gives your AI agent full access to the Gmail API through managed OAuth authentication via the Maton gateway.
Read and send emails, manage threads and labels, create and send drafts, trash messages, and search your inbox using Gmail query operators β all without manual OAuth token management.
How It Works
Create a Google OAuth connection in the Maton control panel and authorize it in your browser.
Requests go through the Maton gateway at `https://gateway.maton.ai/google-mail/{native-api-path}` with tokens injected automatically.
Switch accounts by setting the Maton-Connection header to a specific OAuth connection.
Use standard Gmail API endpoints to read, send, label, draft, and search messages.
Key Features
Managed OAuth
No manual token refresh or OAuth flow handling; the Maton gateway manages authentication automatically.
Full Gmail API Access
List, read, send, trash, and modify messages; manage threads, labels, and drafts.
Query Operators
Use Gmail search syntax like `is:unread`, `from:`, `subject:`, `has:attachment`, and date ranges.
Multi-Account Support
Connect multiple Gmail accounts and switch between them using the Maton-Connection header.
Connection Management
Create, list, and delete OAuth connections through the Maton control panel API.
Draft Management
Create drafts and send them programmatically.
Requirements
- No VM required.
- Maton API Key: required for authentication. Sign up at maton.ai and copy your key from the settings page.
- Google OAuth connection: create a Gmail OAuth connection via ctrl.maton.ai and authorize it in a browser.
Use Cases
Email Triage
Have your AI agent scan unread emails and summarize or prioritize them.
Automated Responses
Draft and send replies based on email content and context.
Email Search
Find specific emails by sender, subject, date range, or attachment status.
Label Management
Automatically organize emails by applying or removing labels.
Draft Preparation
Create email drafts for review before sending.
How to Install
npx clawhub@latest install gmailRun in your terminal, or click the Install button at the top of this page for one-click setup.
FAQ
How do I get a Maton API key?
Sign in to maton.ai, open the settings page, and copy your Maton API key.
How do I connect my Gmail account?
Create a Gmail OAuth connection in the Maton control panel (ctrl.maton.ai), then open the authorization URL to complete OAuth.
Can I use multiple Gmail accounts?
Yes. Create multiple connections and pass the Maton-Connection header to select the account.
What are the rate limits?
The gateway rate limits at roughly 10 requests per second per connection.
Do I need to manage OAuth tokens myself?
No. The Maton gateway injects the OAuth token automatically on each request.
Which Gmail API endpoints can I use?
All standard Gmail API endpoints are available through the Maton gateway URL pattern.