{
 "kind": "api",
 "slug": "gmail-api",
 "path": "apis/gmail-api/",
 "name": "Gmail API",
 "logo": "https://agentgid.com/media/avatars/googleapis.png",
 "maker": "Google",
 "density": "full",
 "crumbs": [
  [
   "APIs",
   "apis/"
  ],
  [
   "Email sending",
   "apis/email/"
  ]
 ],
 "lead": "Read, sort and send mail in Gmail.",
 "chips": [
  {
   "label": "Email sending",
   "path": "apis/email/"
  },
  {
   "label": "Official MCP server"
  }
 ],
 "primary": {
  "label": "Copy prompt for your agent",
  "copy": "Connect Gmail with OAuth using googleapis on my server: ask only for gmail.readonly (or gmail.send if we only send), keep credentials.json and tokens out of git, search with the q parameter, and retry 429 and 5xx errors with exponential backoff."
 },
 "links": [
  {
   "label": "Website",
   "href": "https://developers.google.com/workspace/gmail/api"
  },
  {
   "label": "Pricing",
   "href": "https://developers.google.com/workspace/gmail/api/reference/quota"
  },
  {
   "label": "GitHub",
   "href": "https://github.com/googleapis/google-api-nodejs-client"
  }
 ],
 "track": "Outages, price changes and new versions on your dashboard",
 "verdicts": [
  {
   "key": "price",
   "label": "Price",
   "value": "Free credits",
   "status": "cond",
   "sub": "One-time or needs a card",
   "quote": null,
   "note": "Free tier: Usage under 80,000,000 quota units per day per project isn't billed. As reported on the official pricing page, checked Oct 10, 2026.",
   "src": "https://developers.google.com/workspace/gmail/api/reference/quota"
  },
  {
   "key": "commercial",
   "label": "Commercial use",
   "value": "With conditions",
   "status": "cond",
   "sub": null,
   "quote": "If your public application uses scopes that permit access to certain user data, it must complete a verification process.",
   "note": "Allowed under the Google APIs Terms and the Workspace user data policy; public apps need verification, and restricted scopes may need a yearly security assessment. Data: Rule for your app, not Google's own use; you may not use Gmail user data to train general AI models.",
   "src": "https://developers.google.com/workspace/gmail/api/auth/scopes"
  },
  {
   "key": "key",
   "label": "Key & sign-up",
   "value": "API key",
   "status": "info",
   "sub": "Env var none fixed; the quickstart reads credentials.json, and Python samples use google.auth.default() (GOOGLE_APPLICATION_CREDENTIALS)",
   "quote": "Note that client secrets aren't used for Web applications.",
   "note": "OAuth 2.0 user consent with scopes (each user signs in with Google); the access token goes in the Authorization header.",
   "src": "https://developers.google.com/workspace/gmail/api/quickstart/js"
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Official MCP server",
   "status": "yes",
   "sub": "SDK",
   "quote": "This is an MCP server provided by Gmail API.",
   "note": " Our agent check: 4 of 6 (Nov 13, 2026).",
   "src": "https://developers.google.com/workspace/gmail/api/reference/mcp"
  }
 ],
 "vfoot": "Checked against the maker's official pages, pricing on Oct 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Gmail API does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "list",
     "items": [
      "Gmail API is one of 23 APIs in the Email sending category on AgentGid.",
      "It is one of 21 that can be started for free.",
      "It ships an official MCP server, like 9 others here.",
      "Its official SDK is the 1st most downloaded in the category (32.1M a week)."
     ],
     "muted": true
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Send mail from the user's own address",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Find messages like in the Gmail search box",
       "text": "Pull out invoices, order confirmations or messages from one sender with the same search words people type in Gmail.",
       "idea": false
      },
      {
       "title": "Back up or index a mailbox",
       "text": "Copy someone's mail into an archive or a search index, with read-only access so nothing can be changed or deleted.",
       "idea": false
      },
      {
       "title": "Sort and label incoming mail",
       "text": "Put labels such as \"Invoices\" on matching messages, or set up filters that act on new mail automatically.",
       "idea": false
      },
      {
       "title": "React the moment new mail arrives",
       "text": "Get a notice on your server when a watched mailbox changes, instead of checking it again and again.",
       "idea": false
      },
      {
       "title": "AI assistant that drafts replies",
       "text": "An assistant reads a customer's message and leaves a suggested reply as a draft, which the person checks and sends themselves.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Gmail API popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "30.8M",
       "l": "SDK downloads a week",
       "d": "+3.7% on the 4-week average",
       "up": true
      },
      {
       "n": "573",
       "l": "public agent repos use its SDK"
      },
      {
       "n": "12.3K",
       "l": "GitHub stars, googleapis/google-api-nodejs-client"
      }
     ]
    },
    {
     "t": "small",
     "text": "SDK downloads from npm and PyPI, weekly. Numbers as of Nov 17, 2026."
    }
   ]
  },
  {
   "id": "pricing",
   "nav": "Pricing and limits",
   "h2": "Pricing",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "Free tier",
       "v": "Usage under 80,000,000 quota units per day per project isn't billed"
      },
      {
       "l": "Cheapest plan",
       "v": "No monthly plan"
      },
      {
       "l": "Usage price",
       "v": "Quota-unit based: messages.send = 100 units; 1,200,000 units per minute per project; 6,000 units per minute per user"
      },
      {
       "l": "Plans",
       "v": "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."
      }
     ]
    },
    {
     "t": "small",
     "text": "As reported on the official pricing page, checked Oct 10, 2026. Prices change: confirm before you buy.",
     "link": "developers.google.com/workspace/gmail/api/reference/quota",
     "href": "https://developers.google.com/workspace/gmail/api/reference/quota"
    }
   ]
  },
  {
   "id": "limits",
   "nav": null,
   "spy_as": "pricing",
   "h2": "Limits",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "All projects created from May 1, 2026",
       "v": "1,200,000 quota units per minute per project; 6,000 per minute per user",
       "src": "https://developers.google.com/workspace/gmail/api/reference/quota"
      },
      {
       "l": "All projects",
       "v": "80,000,000 quota units per day before charges apply (cannot be raised)",
       "src": "https://developers.google.com/workspace/gmail/api/reference/quota"
      },
      {
       "l": "All projects",
       "v": "Costs per call: messages.send 100 units, messages.list 5, messages.get 20",
       "src": "https://developers.google.com/workspace/gmail/api/reference/quota"
      },
      {
       "l": "All accounts",
       "v": "500 recipients per message",
       "src": "https://developers.google.com/workspace/gmail/api/reference/quota"
      }
     ]
    },
    {
     "t": "small",
     "text": "From the official docs.",
     "link": "developers.google.com/workspace/gmail/api/reference/quota",
     "href": "https://developers.google.com/workspace/gmail/api/reference/quota"
    }
   ]
  },
  {
   "id": "access",
   "nav": "Access and terms",
   "h2": "Key and access",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "How it signs in",
       "v": "OAuth 2.0 user consent with scopes (each user signs in with Google); the access token goes in the Authorization header."
      },
      {
       "l": "Environment variable",
       "v": "none fixed; the quickstart reads credentials.json, and Python samples use google.auth.default() (GOOGLE_APPLICATION_CREDENTIALS)",
       "code": true
      },
      {
       "l": "Safe in browser code",
       "v": "Yes",
       "status": "yes"
      },
      {
       "l": "Card at sign-up",
       "v": "No"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Steps only a person can do"
    },
    {
     "t": "list",
     "items": [
      "Create or pick a Google Cloud project, turn on the Gmail API and set up the OAuth consent screen (app name, support e-mail, audience). Read the client ID and secret from credentials.json on the server, kept out of git.",
      "Create an OAuth client; if the app is an AI agent acting for users, tick the AI-powered agent option (it cannot be changed later). Use that client in the sign-in flow and store each user's refresh token encrypted.",
      "Before a public launch, submit the app for Google verification, and the security assessment if restricted scopes are used. Until then, keep the app in testing with listed test users.",
      "Each user signs in and approves the requested access. Call the API with userId 'me' for that user."
     ]
    }
   ]
  },
  {
   "id": "terms",
   "nav": null,
   "spy_as": "access",
   "h2": "Commercial use and your data",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In a paid app",
       "v": "With conditions",
       "status": "cond",
       "sub": "Allowed under the Google APIs Terms and the Workspace user data policy; public apps need verification, and restricted scopes may need a yearly security assessment.",
       "quote": "If your public application uses scopes that permit access to certain user data, it must complete a verification process.",
       "src": "https://developers.google.com/workspace/gmail/api/auth/scopes"
      },
      {
       "l": "To train your own AI",
       "v": "No",
       "status": "no",
       "sub": "Mail data may not be used to train or improve general AI models beyond that user's own personalized model.",
       "quote": "Transferring, selling, or using user data to create, train, or improve a machine learning or artificial intelligence model beyond that specific user's personalized model for the appropriate use case or user-facing feature.",
       "src": "https://developers.google.com/workspace/workspace-api-user-data-developer-policy"
      },
      {
       "l": "client-work",
       "v": "With conditions",
       "status": "cond",
       "sub": "Fine for internal tools in a client's own Workspace (internal apps skip some review); public apps follow the same verification rules.",
       "quote": "Note: If your app is only used by users within your own domain,",
       "src": "https://developers.google.com/terms/api-services-user-data-policy"
      },
      {
       "l": "Trains on what you send",
       "v": "Rule for your app, not Google's own use; you may not use Gmail user data to train general AI models.",
       "quote": "Transferring, selling, or using user data to create, train, or improve a machine learning or artificial intelligence model beyond that specific user's personalized model for the appropriate use case or user-facing feature.",
       "src": "https://developers.google.com/workspace/workspace-api-user-data-developer-policy"
      },
      {
       "l": "Keeps your data",
       "v": "Your app must publish a privacy policy that says how it uses, stores and shares the Google user data it gets.",
       "quote": "You must publish a privacy policy that fully documents how your application interacts with user data.",
       "src": "https://developers.google.com/terms/api-services-user-data-policy"
      }
     ]
    }
   ]
  },
  {
   "id": "errors",
   "nav": null,
   "spy_as": "access",
   "h2": "Errors to handle",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "401 authError",
       "v": "The access token is expired or invalid, or lacks the needed scope.",
       "sub": "Refresh the token with the refresh token (client libraries do this); if that fails, send the user through sign-in again."
      },
      {
       "l": "403 rateLimitExceeded / userRateLimitExceeded",
       "v": "The user or project hit a rate limit.",
       "sub": "Retry with exponential backoff and make fewer requests."
      },
      {
       "l": "403 domainPolicy",
       "v": "The user's Workspace admin does not allow apps to access Gmail.",
       "sub": "Tell the user to ask their domain administrator to allow your app."
      },
      {
       "l": "429",
       "v": "Daily sending limit, bandwidth limit or too many parallel requests for one user.",
       "sub": "Wait for the retry time and back off; per-user limits cannot be raised."
      },
      {
       "l": "500 backendError (also 502, 503, 504)",
       "v": "An unexpected error on Google's side.",
       "sub": "Retry with exponential backoff."
      }
     ]
    }
   ]
  },
  {
   "id": "agent",
   "nav": "For agents",
   "h2": "Use it from an agent",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "Our agent check",
       "v": "4 of 6: llms.txt no, OpenAPI no, SDK yes, MCP yes, status page yes, AI assistants allowed yes",
       "sub": "Checked Nov 13, 2026."
      },
      {
       "l": "MCP server",
       "v": "Gmail MCP server (gmailmcp.googleapis.com), Developer Preview",
       "sub": "https://gmailmcp.googleapis.com/mcp/v1"
      },
      {
       "l": "npm",
       "v": "npm install @googleapis/gmail",
       "code": true
      },
      {
       "l": "PyPI",
       "v": "pip install google-api-python-client",
       "code": true
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Gmail API",
       "me": true,
       "facts": [
        "Free plan",
        "Free tier",
        "Official MCP"
       ]
      },
      {
       "name": "Resend",
       "why": "Pick Resend to send transactional or marketing mail from your own domain, without users signing in to Gmail.",
       "path": "apis/resend/",
       "facts": [
        "See its page",
        "No free tier"
       ]
      },
      {
       "name": "Postmark",
       "why": "Pick Postmark for receipts and password resets from your domain, with handling of incoming mail.",
       "path": "apis/postmark/",
       "facts": [
        "See its page",
        "No free tier"
       ]
      },
      {
       "name": "AgentMail",
       "why": "Pick AgentMail when an AI agent needs its own inboxes to send, receive and reply, instead of a person's Gmail.",
       "path": "apis/agentmail/",
       "facts": [
        "See its page",
        "No free tier"
       ]
      }
     ],
     "more": "All email sending APIs",
     "more_path": "apis/email/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Connect Gmail with OAuth using googleapis on my server: ask only for gmail.readonly (or gmail.send if we only send), keep credentials.json and tokens out of git, search with the q parameter, and retry 429 and 5xx errors with exponential backoff."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "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.",
       "code": null,
       "src": "https://developers.google.com/workspace/gmail/api/quickstart/nodejs"
      },
      {
       "text": "Install the client libraries used by the Node.js quickstart.",
       "code": "npm install googleapis@105 @google-cloud/local-auth@2.1.0 --save",
       "src": "https://developers.google.com/workspace/gmail/api/quickstart/nodejs"
      },
      {
       "text": "Run the sample; the first run opens a browser to sign in and approve, then it lists the mailbox labels.",
       "code": "node .",
       "src": "https://developers.google.com/workspace/gmail/api/quickstart/nodejs"
      }
     ]
    },
    {
     "t": "h3",
     "text": "First request"
    },
    {
     "t": "tabs",
     "label": "First request",
     "items": [
      {
       "tab": "Request",
       "code": "GET https://www.googleapis.com/gmail/v1/users/me/messages?q=in:sent after:2014/01/01 before:2014/02/01",
       "intro": "Request from the search guide (needs an OAuth access token); response is the structure from the messages.list reference, where each message carries only an id and a threadId."
      },
      {
       "tab": "Response",
       "code": "{\n  \"messages\": [\n    {\n      object (Message)\n    }\n  ],\n  \"nextPageToken\": string,\n  \"resultSizeEstimate\": integer\n}"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "Asking for https://mail.google.com/ (full access) when the app only sends or reads.",
       "fix": "Ask for gmail.send to send, or gmail.readonly to read; use full access only for permanent deletion.",
       "why": "Broader scopes are restricted and mean more review, and users trust narrow requests more."
      },
      {
       "dont": "Putting plain text or JSON fields like to and subject into messages.send.",
       "fix": "Build a full email (RFC 2822 MIME), encode it as base64url and put it in the raw field.",
       "why": "The API only accepts the message as one encoded raw string."
      },
      {
       "dont": "Treating a 200 answer from messages.send as proof the mail was delivered.",
       "fix": "Watch for later 429 \"Mail sending\" errors and check the Sent label or bounces.",
       "why": "Over the daily limit, errors can start several minutes after successful-looking sends."
      },
      {
       "dont": "Sending many requests at once for the same user to go faster.",
       "fix": "Limit parallel requests per user and retry 429 and 403 rate errors with exponential backoff.",
       "why": "Gmail has a per-user concurrent request limit on top of the rate limits."
      },
      {
       "dont": "Running the desktop quickstart on a remote server over SSH.",
       "fix": "Run it on a computer with a browser, or use a web OAuth flow for server apps.",
       "why": "The local sign-in needs a browser on the same machine."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Does the Gmail API cost money?",
       "a": "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.",
       "evidence": {
        "url": "https://developers.google.com/workspace/gmail/api/reference/quota",
        "quote": "Usage under this threshold doesn't incur extra charges and your Google Cloud account isn't billed."
       }
      },
      {
       "q": "Can I use it to send newsletters to thousands of people?",
       "a": "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.",
       "evidence": {
        "url": "https://developers.google.com/workspace/gmail/api/guides/handle-errors",
        "quote": "The Gmail API enforces the standard daily mail sending limits."
       }
      },
      {
       "q": "Which permission should my app ask for?",
       "a": "The narrowest one that works, for example gmail.send to only send; broad ones like full mail access are restricted and need extra review.",
       "evidence": {
        "url": "https://developers.google.com/workspace/gmail/api/auth/scopes",
        "quote": "Whenever possible, use non-sensitive scopes to narrow access to only the specific features needed by an app."
       }
      },
      {
       "q": "Can an AI assistant use Gmail directly?",
       "a": "Google offers a Gmail MCP server in Developer Preview with tools such as search threads and create draft.",
       "evidence": {
        "url": "https://developers.google.com/workspace/gmail/api/reference/mcp",
        "quote": "The server provides tools for developers to build LLM applications on top of Gmail."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Maker",
   "Google"
  ],
  [
   "Category",
   "Email sending"
  ],
  [
   "Price",
   "Free plan"
  ],
  [
   "Official SDK",
   "npm @googleapis/gmail, PyPI google-api-python-client"
  ],
  [
   "Latest SDK",
   "22.0.2 on npm"
  ],
  [
   "Agent check",
   "4 of 6"
  ],
  [
   "Pricing checked",
   "Oct 10, 2026"
  ]
 ],
 "good": [
  "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."
 ],
 "checked_line": "Read by AgentGid from 21 official pages, card checked Nov 10, 2026; usage numbers update daily."
}