# Gmail API — card for AI agents

Read, search, label and send mail in Gmail mailboxes via REST with OAuth user consent.

Maker: Google · category: Email sending

## Price (official page)
- Free tier: Usage under 80,000,000 quota units per day per project isn't billed
- Free tier terms: free allowance · daily (read from the wording above and the pricing page; empty = not stated)
- Usage price: Quota-unit based: messages.send = 100 units; 1,200,000 units per minute per project; 6,000 units per minute per user
- Pricing page: https://developers.google.com/workspace/gmail/api/reference/quota (checked 2026-10-09)
- Note: Quotas changed May 1, 2026 for new Cloud projects; Google says full billing details for usage above the daily threshold come later in 2026 with 90 days' notice. Limit of 500 recipients per message.

## Connect
- Official MCP server: https://developers.google.com/workspace/gmail/api/reference/mcp
- npm: `npm install @googleapis/gmail`
- PyPI: `pip install google-api-python-client`
- Repository: https://github.com/googleapis/google-api-nodejs-client

## For AI agents on Google's own site (AgentGid check 2026-11-13: 4 of 6)
- llms.txt: none found
- OpenAPI description: none found at the usual places
- Official MCP server: yes · official SDK: yes · status page: yes
- robots.txt lets AI assistants (ChatGPT-User, Claude-User) read the site: yes

## Price history in AgentGid's catalog (since 2026-10-10)
- Changes recorded: 0 (a vendor price change or an editor's correction; the evidence archive keeps the pricing page of each date)

## Other APIs in this category
- SparkPost: https://agentgid.com/apis/sparkpost/agent.md
- Mailtrap Email API/SMTP: https://agentgid.com/apis/mailtrap/agent.md
- SMTP2GO: https://agentgid.com/apis/smtp2go/agent.md
- MailerSend: https://agentgid.com/apis/mailersend/agent.md
- Courier: https://agentgid.com/apis/courier/agent.md

## Links
- AgentGid page: https://agentgid.com/apis/gmail-api/


## Gmail API: read, sort and send mail in Gmail

The Gmail API lets your app work with a person's own Gmail mailbox after they sign in with Google and approve access. The app can search and read messages, add labels, write drafts and send mail from that address. It is for working with real mailboxes, not for sending newsletters or receipts from your own domain.

### Where to use it
- Send mail from the user's own address: Your app writes and sends a message, or saves a draft, from the signed-in person's Gmail, so replies come back to their inbox.
- Find messages like in the Gmail search box: Pull out invoices, order confirmations or messages from one sender with the same search words people type in Gmail.
- Back up or index a mailbox: Copy someone's mail into an archive or a search index, with read-only access so nothing can be changed or deleted.
- Sort and label incoming mail: Put labels such as "Invoices" on matching messages, or set up filters that act on new mail automatically.
- React the moment new mail arrives: Get a notice on your server when a watched mailbox changes, instead of checking it again and again.
- AI assistant that drafts replies: An assistant reads a customer's message and leaves a suggested reply as a draft, which the person checks and sends themselves. (idea, not from the official pages)

### How to start
- In a Google Cloud project, turn on the Gmail API, set up the consent screen and create an OAuth client; save the downloaded file as credentials.json.
- Install the client libraries used by the Node.js quickstart.

```
npm install googleapis@105 @google-cloud/local-auth@2.1.0 --save
```

- Run the sample; the first run opens a browser to sign in and approve, then it lists the mailbox labels.

```
node .
```


### License
Free to call within Google's limits for any app, including paid ones, under the Google APIs Terms. Apps that read people's mail must follow Google's user data rules, and may not use that mail to train general AI models.

### Good to know
- Every user must sign in with Google and approve access. A public app that reads mail must pass Google's app check first.
- Reading or changing mail counts as restricted access; such apps may need a yearly security assessment by a firm Google names.
- Usage is counted in quota units; sending one message costs 100. Above 80 million units a day charges are planned, with 90 days' notice.
- One message can go to at most 500 recipients, and the normal daily Gmail sending limits of that account apply.
- A successful answer does not prove the mail went out; over the sending limit errors can start minutes later.

Checked 2026-11-10 against: https://developers.google.com/workspace/gmail/api, https://developers.google.com/workspace/gmail/api/guides, https://developers.google.com/workspace/gmail/api/reference/quota, https://developers.google.com/workspace/gmail/api/reference/mcp, https://developers.google.com/workspace/gmail/api/quickstart/nodejs, https://developers.google.com/workspace/gmail/api/quickstart/python, https://developers.google.com/workspace/gmail/api/quickstart/js, https://developers.google.com/workspace/gmail/api/auth/scopes, https://developers.google.com/workspace/gmail/api/guides/handle-errors, https://developers.google.com/workspace/gmail/api/guides/sending, https://developers.google.com/workspace/gmail/api/guides/push, https://developers.google.com/workspace/gmail/api/guides/filtering, https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages/send, https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages/list, https://developers.google.com/workspace/tools-safety, https://developers.google.com/terms/api-services-user-data-policy, https://developers.google.com/workspace/workspace-api-user-data-developer-policy, http://workspaceupdates.googleblog.com/2026/05/agent-tools-and-security-updates-for-workspace-developers.html, https://registry.npmjs.org/@googleapis/gmail/latest, https://registry.npmjs.org/googleapis/latest, https://pypi.org/pypi/google-api-python-client/json

### Mistakes to avoid
- Don't: Asking for https://mail.google.com/ (full access) when the app only sends or reads. → Do: Ask for gmail.send to send, or gmail.readonly to read; use full access only for permanent deletion. (Broader scopes are restricted and mean more review, and users trust narrow requests more.)
- Don't: Putting plain text or JSON fields like to and subject into messages.send. → Do: Build a full email (RFC 2822 MIME), encode it as base64url and put it in the raw field. (The API only accepts the message as one encoded raw string.)
- Don't: Treating a 200 answer from messages.send as proof the mail was delivered. → Do: Watch for later 429 "Mail sending" errors and check the Sent label or bounces. (Over the daily limit, errors can start several minutes after successful-looking sends.)
- Don't: Sending many requests at once for the same user to go faster. → Do: Limit parallel requests per user and retry 429 and 403 rate errors with exponential backoff. (Gmail has a per-user concurrent request limit on top of the rate limits.)
- Don't: Running the desktop quickstart on a remote server over SSH. → Do: Run it on a computer with a browser, or use a web OAuth flow for server apps. (The local sign-in needs a browser on the same machine.)

### Questions
- Does the Gmail API cost money? Not below the daily threshold of 80 million quota units per project; Google says billing details for usage above it come later in 2026 with at least 90 days' notice.
- Can I use it to send newsletters to thousands of people? It sends from a person's own Gmail with that account's daily limits and at most 500 recipients per message; for bulk mail from your domain an email-sending service fits better.
- Which permission should my app ask for? The narrowest one that works, for example gmail.send to only send; broad ones like full mail access are restricted and need extra review.
- Can an AI assistant use Gmail directly? Google offers a Gmail MCP server in Developer Preview with tools such as search threads and create draft.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
