Gmail
This page contains the setup guide and reference information for the Gmail source connector.
Gmail is the email service provided by Google. The Gmail source connector replicates messages, drafts, threads, labels, and the authenticated user's profile from Gmail's REST API.
Prerequisites
- A Google account with access to the mailbox you want to replicate.
- A Gmail API scope that allows reading mail. Airbyte Cloud's OAuth flow requests
https://www.googleapis.com/auth/gmail.modify, which includes read access. An OAuth client you manage yourself can grant the narrowerhttps://www.googleapis.com/auth/gmail.readonlyscope. In either case, the connector only issues read requests.
- For Airbyte Open Source: a Google Cloud project with the Gmail API enabled, plus an OAuth 2.0 client and refresh token.
Setup guide
Step 1: Set up authentication
The Gmail source connector offers two authentication methods: OAuth and Service Account Key. Use OAuth. Service Account Key authentication can't currently read a mailbox.
OAuth (recommended for Airbyte Cloud)
In Airbyte Cloud, sign in with the Google account whose mailbox you want to replicate. Airbyte Cloud handles the OAuth flow for you — you only need to authorize Airbyte through the standard Google consent screen when configuring the source. The consent screen requests https://www.googleapis.com/auth/gmail.modify, so it asks you to let Airbyte read, compose, and send mail. The connector only issues read requests.
Sources that were authorized before connector version 0.1.11 keep the scope Google granted at consent time. You don't need to re-authenticate them.
OAuth for Airbyte Open Source
To authenticate with OAuth in Airbyte Open Source, create your own OAuth client in your Google Cloud project and complete the authorization code flow yourself to obtain a refresh token. You will need the resulting Client ID, Client Secret, and Refresh Token to configure the connector.
-
In the Google Cloud console, enable the Gmail API for your project.
-
Configure your OAuth consent screen and add a Gmail scope. Which scope you add depends on how you complete the flow:
- If you obtain the refresh token yourself, add
https://www.googleapis.com/auth/gmail.readonly. - If you register your OAuth client with your Airbyte instance and click Authenticate your account, add
https://www.googleapis.com/auth/gmail.modify. Airbyte builds that consent URL from the connector, which requestsgmail.modify, and the scope has to be configured on your consent screen.
- If you obtain the refresh token yourself, add
-
Follow Google's web server OAuth 2.0 guide to create a Web application OAuth client and exchange the authorization code for a refresh token.
If you configured this source before version 0.1.1, Client ID, Client Secret, and Refresh Token were top-level fields. The connector moves them into the nested Authentication object automatically the first time it runs on a newer version, as long as all three values are present. You don't need to re-enter them. Sources that already use the nested OAuth or Service Account Key configuration aren't changed.
Service Account Key for Airbyte Open Source
Service Account Key authentication can't currently read a mailbox. To read a user's mailbox, Google requires the token request to name the user to impersonate in the sub claim, and only applies domain-wide delegation when that claim is set. The connector doesn't set sub and has no field for the user to impersonate, so Google issues a token for the service account itself. A service account has no Gmail mailbox, so the connection test and syncs fail with Precondition check failed, whether or not domain-wide delegation is configured. Use OAuth instead.
Step 2: Set up the Gmail connector in Airbyte
- Log into your Airbyte instance, click Sources, and click + New source.
- Select Gmail from the source type dropdown.
- Choose your authentication method:
- Authenticate via Google (OAuth) — Click Authenticate your account and complete the Google sign-in flow. Airbyte Cloud users authenticate against Airbyte's pre-registered OAuth app. Airbyte Open Source users provide their own Client ID, Client Secret, and Refresh Token.
- Service Account Key Authentication — Not currently usable. The connector authenticates as the service account itself, which has no mailbox. Use OAuth instead.
- (Optional) Set Start date in
YYYY-MM-DDTHH:MM:SSZformat. Only messages, drafts, and threads received on or after this date are replicated. If you leave it blank, the connector replicates the full mailbox history. - (Optional) Toggle Include Spam & Trash to include drafts and messages from the Spam and Trash folders. Defaults to off.
- (Optional) Adjust Number of concurrent workers (between
2and10, default5) to control how many requests the connector issues in parallel. Lower this value if you see frequent rate-limit errors. - Click Set up source to test the connection and save the configuration. The connection test reads the authenticated user's Gmail profile.
Supported sync modes
The Gmail source connector supports the following sync modes:
| Sync mode | Supported |
|---|---|
| Full Refresh | Overwrite | Yes |
| Full Refresh | Append | Yes |
| Incremental | Append | Yes |
| Incremental | Append + Deduped | Yes |
Only the messages_details stream supports incremental sync. All other streams run in full refresh mode on every sync.
Streams
| Stream | Primary Key | Sync Mode | Description |
|---|---|---|---|
profile | (none) | Full Refresh | The authenticated user's Gmail profile, including email address and history ID. |
drafts | id | Full Refresh | Stub records (id, message.id, message.threadId) returned by users.drafts.list. |
labels | id | Full Refresh | All Gmail labels, including system labels (e.g. INBOX, SENT) and user-created labels. |
labels_details | id | Full Refresh | Per-label metadata such as message and thread counts. Substream of labels. |
messages | id | Full Refresh | Stub records (id, threadId) returned by users.messages.list. |
messages_details | id | Incremental on internalDate | Full message payloads, headers, snippet, and labels. Substream of messages. |
threads | id | Full Refresh | Stub records (id, historyId) returned by users.threads.list. |
threads_details | id | Full Refresh | Per-thread details and the messages in each thread. Substream of threads. |
The messages_details cursor is the message's internalDate field — the Unix epoch in milliseconds when Gmail received the message. Other streams expose only id and threadId from the upstream list calls and have no record-level cursor field, so they run as full refresh.
On incremental syncs of messages_details, the connector still lists every message in the parent messages stream, then drops the messages whose internalDate predates the stored cursor. Incremental sync reduces what lands in your destination, not the API quota the list calls consume. If you leave Start date blank, the cursor starts at 2004-04-01, the date Gmail launched.
When Start date is set, the connector applies the Gmail after:<epoch_seconds> search operator to the messages, drafts, and threads list requests so the API skips records older than that date.
Performance considerations
The Gmail API enforces two simultaneous quota limits, measured in quota units:
| Limit type | Limit | Error code |
|---|---|---|
| Per project rate limit | 1,200,000 quota units per minute | rateLimitExceeded |
| Per user rate limit | 6,000 quota units per minute per user | userRateLimitExceeded |
Each threads.get call costs 40 units, messages.get 20, threads.list 10, messages.list and drafts.list 5, and labels and profile calls 1. The messages_details and threads_details substreams issue one get call per parent record, so high-volume mailboxes consume quota quickly.
These are the quotas for Google Cloud projects created on or after May 1, 2026. Projects that used the Gmail API between November 2025 and April 2026 keep their previous quotas: 15,000 units per minute per user, with messages.get and messages.list at 5 units and threads.get and threads.list at 10. Because the limit depends on the project, the connector doesn't throttle its calls up front and relies on Gmail's rate-limit responses instead.
The connector retries 429 Too Many Requests and 403 quota-saturation errors with backoff, up to 10 times over roughly 10 to 13 minutes. After a 429, every request waits up to a minute for the current quota window to clear. If you see frequent rate-limit warnings in sync logs, lower the Number of concurrent workers setting.
Limitations & troubleshooting
messagesandthreadsare stub-only. The Gmail API'susers.messages.listandusers.threads.listendpoints return only{id, threadId}(or{id, historyId}) per record. To replicate the full message body, headers, or labels, sync themessages_detailsorthreads_detailssubstream alongside its parent.- Service account keys can't read a mailbox. The connector doesn't set the
subclaim that Google requires for a service account to impersonate a user, so the token belongs to the service account, which has no mailbox. Domain-wide delegation doesn't change this. Use OAuth instead. Precondition check failed. The authenticated account has no Gmail mailbox. Either you used Service Account Key authentication, or you authorized a Google Workspace user who doesn't have Gmail enabled. Authenticate with OAuth as the user whose mailbox you want to sync.- The Gmail API isn't enabled. On Airbyte Open Source with your own OAuth client, the connector fails with a configuration error until you enable the Gmail API in the Google Cloud project that owns the client.
- The authorized account lacks the required scope. If Gmail returns
insufficientPermissions, re-authenticate and granthttps://www.googleapis.com/auth/gmail.readonly(a refresh token you obtained yourself) orhttps://www.googleapis.com/auth/gmail.modify(the Authenticate your account flow). - Your Workspace administrator has disabled Gmail apps. If Gmail returns
domainPolicy, ask your Google Workspace administrator to allow Gmail API access for the app, then retry. - The Cloud consent screen asks for more access than the connector uses.
https://www.googleapis.com/auth/gmail.modifylets an app read, compose, and send mail, change labels, and trash messages. This connector only issues GET requests. To grant the narrowerhttps://www.googleapis.com/auth/gmail.readonlyscope instead, use your own OAuth client on a self-managed Airbyte instance.
Configuration
| Input | Type | Description | Default Value |
|---|---|---|---|
credentials | object | Authentication. Credentials for connecting to the Gmail API. | |
credentials.client_id | string | Client ID. Enter your Google application's Client ID. See Google's documentation for more information. | |
credentials.client_secret | string | Client Secret. Enter your Google application's Client Secret. See Google's documentation for more information. | |
credentials.client_refresh_token | string | Refresh Token. Enter your Google application's refresh token. See Google's documentation for more information. | |
credentials.service_account_info | string | Service Account Information. The JSON key of the service account to use for authorization. | |
include_spam_and_trash | boolean | Include Spam & Trash. Include drafts/messages from SPAM and TRASH in the results. Defaults to false. | false |
num_workers | integer | Number of concurrent workers. Higher values result in faster syncs but may trigger rate limiting on lower-tier Gmail API quotas. Reduce this value if you see frequent rate-limit errors in sync logs. | 5 |
start_date | string | UTC date and time in the format YYYY-MM-DDTHH:MM:SSZ. Only messages, threads, and drafts received on or after this date will be replicated. If unset, the full history is replicated. |
IP allow list
If you use Airbyte Cloud and your organization restricts access to specific IPs, add the Airbyte Cloud IP addresses to your allow list.
Reference
Config fields reference
Changelog
Expand to review
| Version | Date | Pull Request | Subject |
|---|---|---|---|
| 0.1.21 | 2026-10-13 | 88403 | Check connection via profile and retry rate limits; add actionable Gmail API errors, API budget and missing schema fields |
| 0.1.20 | 2026-10-13 | 88635 | Update dependencies |
| 0.1.19 | 2026-10-06 | 87854 | Update dependencies |
| 0.1.18 | 2026-09-29 | 87179 | Update dependencies |
| 0.1.17 | 2026-09-22 | 86632 | Update dependencies |
| 0.1.16 | 2026-09-15 | 86066 | Update dependencies |
| 0.1.15 | 2026-09-11 | 85800 | Fix config migration copying empty or incomplete legacy OAuth fields into nested credentials |
| 0.1.14 | 2026-09-08 | 85497 | Update dependencies |
| 0.1.13 | 2026-08-18 | 84554 | Update dependencies |
| 0.1.12 | 2026-08-11 | 83951 | Update dependencies |
| 0.1.11 | 2026-08-04 | 83308 | Use gmail.modify for Airbyte Cloud's managed OAuth flow; self-managed OAuth clients and service accounts continue to use gmail.readonly |
| 0.1.10 | 2026-08-04 | 83463 | Update dependencies |
| 0.1.9 | 2026-07-28 | 82922 | Update dependencies |
| 0.1.8 | 2026-07-21 | 82425 | Update dependencies |
| 0.1.7 | 2026-07-14 | 81816 | Update dependencies |
| 0.1.6 | 2026-06-30 | 81079 | Update dependencies |
| 0.1.5 | 2026-06-23 | 80468 | Update dependencies |
| 0.1.4 | 2026-06-16 | 79869 | Update dependencies |
| 0.1.3 | 2026-06-09 | 79310 | Update dependencies |
| 0.1.2 | 2026-06-02 | 78732 | Update dependencies |
| 0.1.1 | 2026-05-04 | 76065 | Add OAuth flow with credentials wrapper, config migration, and Service Account auth |
| 0.1.0 | 2026-04-29 | 76431 | Add messages_details incremental sync, optional start_date server-side filtering on messages/drafts/threads, configurable concurrency via num_workers, and Gmail-aware rate-limit handling (429 + 403 quota-saturation) |
| 0.0.52 | 2026-04-28 | 77264 | Update dependencies |
| 0.0.51 | 2026-04-21 | 76616 | Update dependencies |
| 0.0.50 | 2026-03-24 | 75387 | Update dependencies |
| 0.0.49 | 2026-03-10 | 74532 | Update dependencies |
| 0.0.48 | 2026-03-03 | 74205 | Update dependencies |
| 0.0.47 | 2026-02-11 | 73300 | Revert OAuth authentication support |
| 0.0.46 | 2026-02-11 | 73273 | Add OAuth authentication support (reverted in 0.0.47) |
| 0.0.45 | 2026-02-10 | 72593 | Update dependencies |
| 0.0.44 | 2026-01-20 | 71967 | Update dependencies |
| 0.0.43 | 2026-01-14 | 71388 | Update dependencies |
| 0.0.42 | 2025-12-18 | 70726 | Update dependencies |
| 0.0.41 | 2025-11-25 | 69871 | Update dependencies |
| 0.0.40 | 2025-11-18 | 69412 | Update dependencies |
| 0.0.39 | 2025-10-29 | 69004 | Update dependencies |
| 0.0.38 | 2025-10-21 | 68299 | Update dependencies |
| 0.0.37 | 2025-10-14 | 67999 | Update dependencies |
| 0.0.36 | 2025-10-07 | 67258 | Update dependencies |
| 0.0.35 | 2025-09-30 | 66299 | Update dependencies |
| 0.0.34 | 2025-09-09 | 66063 | Update dependencies |
| 0.0.33 | 2025-08-23 | 65371 | Update dependencies |
| 0.0.32 | 2025-08-09 | 64626 | Update dependencies |
| 0.0.31 | 2025-08-02 | 64194 | Update dependencies |
| 0.0.30 | 2025-07-26 | 63861 | Update dependencies |
| 0.0.29 | 2025-07-19 | 63463 | Update dependencies |
| 0.0.28 | 2025-07-12 | 63123 | Update dependencies |
| 0.0.27 | 2025-07-05 | 62624 | Update dependencies |
| 0.0.26 | 2025-06-28 | 62169 | Update dependencies |
| 0.0.25 | 2025-06-21 | 61834 | Update dependencies |
| 0.0.24 | 2025-06-14 | 61134 | Update dependencies |
| 0.0.23 | 2025-05-24 | 60608 | Update dependencies |
| 0.0.22 | 2025-05-10 | 59895 | Update dependencies |
| 0.0.21 | 2025-05-03 | 59276 | Update dependencies |
| 0.0.20 | 2025-04-26 | 58813 | Update dependencies |
| 0.0.19 | 2025-04-19 | 58184 | Update dependencies |
| 0.0.18 | 2025-04-12 | 57732 | Update dependencies |
| 0.0.17 | 2025-04-05 | 57214 | Update dependencies |
| 0.0.16 | 2025-03-29 | 55947 | Update dependencies |
| 0.0.15 | 2025-03-08 | 55265 | Update dependencies |
| 0.0.14 | 2025-03-01 | 54937 | Update dependencies |
| 0.0.13 | 2025-02-22 | 54417 | Update dependencies |
| 0.0.12 | 2025-02-15 | 53369 | Update dependencies |
| 0.0.11 | 2025-02-01 | 52831 | Update dependencies |
| 0.0.10 | 2025-01-25 | 52329 | Update dependencies |
| 0.0.9 | 2025-01-18 | 51700 | Update dependencies |
| 0.0.8 | 2025-01-11 | 51110 | Update dependencies |
| 0.0.7 | 2024-12-28 | 50536 | Update dependencies |
| 0.0.6 | 2024-12-21 | 50008 | Update dependencies |
| 0.0.5 | 2024-12-14 | 49474 | Update dependencies |
| 0.0.4 | 2024-12-12 | 49185 | Update dependencies |
| 0.0.3 | 2024-10-29 | 47852 | Update dependencies |
| 0.0.2 | 2024-10-28 | 47570 | Update dependencies |
| 0.0.1 | 2024-10-09 | Initial release by @topefolorunso via Connector Builder |