Gmail
connector.gmail · connector.gmail_trigger · communication, email
Send, reply to, search and organize Gmail messages, threads, drafts and labels.
Vendor API documentation: https://developers.google.com/gmail/api/reference/rest
Authentication
| Method | Credential kind | Auth kind | Fields | Test request |
|---|---|---|---|---|
| Google account (OAuth2) | gmail/oauth2 | oauth2_auth_code | client_id, client_secret (secret), scopes | yes |
| Service account (Workspace) | gmail/service_account | jwt_service_account | client_email, private_key (secret), subject, scopes | yes |
Actions
Node type connector.gmail. Choose a resource and an operation; each operation has its own parameters.
Message
| Operation | ID | Effect | Paginated | Cassette tests |
|---|---|---|---|---|
| Send an email | message.send | writes | 4 | |
| Reply to an email | message.reply | writes | 1 | |
| Get an email | message.get | reads | 2 | |
| Get email attachments | message.get_attachments | reads | 1 | |
| Search emails | message.list | reads | yes | 2 |
| Add labels to an email | message.add_labels | writes | 1 | |
| Remove labels from an email | message.remove_labels | writes | 1 | |
| Mark as read | message.mark_read | writes | 1 | |
| Mark as unread | message.mark_unread | writes | 1 | |
| Move to trash | message.trash | writes | 1 | |
| Restore from trash | message.untrash | writes | 1 | |
| Delete permanently | message.delete | writes | 1 |
Send an email
Operation message.send.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
to | string | yes | Comma-separated recipients. | ||
subject | string | ||||
email_type | options | "html" | Body format. One of html, text. | ||
message | string | Body. Message body in the chosen format. | |||
text_alternative | string | email_type = html | Plain-text alternative. Optional plain-text version sent alongside the HTML. | ||
cc | string | Comma-separated recipients. | |||
bcc | string | Comma-separated recipients. | |||
from | string | A send-as alias configured in Gmail (default: the account address). | |||
reply_to | string | Reply-To. | |||
attachments | string | Comma-separated binary property names to attach (a list of names also works). | |||
headers | json | Extra headers. Object of additional header names and values. | |||
thread_id | string | Thread ID. Add the message to an existing thread (subject must match). |
Reply to an email
Operation message.reply. Replies in the original thread with In-Reply-To and References set, to the Reply-To or From address (optionally everyone).
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. | ||
email_type | options | "html" | Body format. One of html, text. | ||
message | string | Body. Message body in the chosen format. | |||
text_alternative | string | email_type = html | Plain-text alternative. Optional plain-text version sent alongside the HTML. | ||
reply_all | boolean | false | Reply to all. Also copy the original To and Cc recipients (except yourself). | ||
cc | string | Comma-separated recipients. | |||
bcc | string | Comma-separated recipients. | |||
from | string | A send-as alias configured in Gmail (default: the account address). | |||
attachments | string | Comma-separated binary property names to attach (a list of names also works). |
Get an email
Operation message.get. Returns headers, plain-text and HTML bodies and the attachment list of a message.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. | ||
format | options | "full" | One of full, metadata, raw. |
Get email attachments
Operation message.get_attachments. Returns one item per attachment with its content as standard base64 in data (use a convert-to-file step to turn it into binary data).
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. |
Search emails
Operation message.list. Lists messages matching a Gmail search query and labels, newest first.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
query | string | Search. Gmail search syntax. | |||
label_ids | multi_options | Labels. Only messages that have all of these labels. Values from lookup labels. | |||
include_spam_trash | boolean | false | Include spam and trash. | ||
format | options | "metadata" | One of metadata, full, minimal. | ||
return_all | boolean | false | |||
limit | number | 50 | return_all = false |
Add labels to an email
Operation message.add_labels.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. | ||
label_ids | multi_options | yes | Labels. Values from lookup labels. |
Remove labels from an email
Operation message.remove_labels.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. | ||
label_ids | multi_options | yes | Labels. Values from lookup labels. |
Mark as read
Operation message.mark_read.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. |
Mark as unread
Operation message.mark_unread.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. |
Move to trash
Operation message.trash.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. |
Restore from trash
Operation message.untrash.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. |
Delete permanently
Operation message.delete. Deletes the message immediately, skipping the trash. Needs the https://mail.google.com/ scope.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
message_id | string | yes | Message ID. |
Thread
| Operation | ID | Effect | Paginated | Cassette tests |
|---|---|---|---|---|
| Get a thread | thread.get | reads | 1 | |
| Search threads | thread.list | reads | yes | 1 |
| Add labels to a thread | thread.add_labels | writes | 1 | |
| Remove labels from a thread | thread.remove_labels | writes | 1 | |
| Move a thread to trash | thread.trash | writes | 1 | |
| Restore a thread from trash | thread.untrash | writes | 1 | |
| Delete a thread permanently | thread.delete | writes | 1 |
Get a thread
Operation thread.get. Returns one item per message in the thread, oldest first.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
thread | string | yes | Thread ID. | ||
format | options | "full" | One of full, metadata, raw. |
Search threads
Operation thread.list.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
query | string | Search. Gmail search syntax. | |||
label_ids | multi_options | Labels. Only messages that have all of these labels. Values from lookup labels. | |||
include_spam_trash | boolean | false | Include spam and trash. | ||
return_all | boolean | false | |||
limit | number | 50 | return_all = false |
Add labels to a thread
Operation thread.add_labels.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
thread | string | yes | Thread ID. | ||
label_ids | multi_options | yes | Labels. Values from lookup labels. |
Remove labels from a thread
Operation thread.remove_labels.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
thread | string | yes | Thread ID. | ||
label_ids | multi_options | yes | Labels. Values from lookup labels. |
Move a thread to trash
Operation thread.trash.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
thread | string | yes | Thread ID. |
Restore a thread from trash
Operation thread.untrash.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
thread | string | yes | Thread ID. |
Delete a thread permanently
Operation thread.delete. Needs the https://mail.google.com/ scope.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
thread | string | yes | Thread ID. |
Draft
| Operation | ID | Effect | Paginated | Cassette tests |
|---|---|---|---|---|
| Create a draft | draft.create | writes | 1 | |
| Get a draft | draft.get | reads | 1 | |
| List drafts | draft.list | reads | yes | 1 |
| Send a draft | draft.send | writes | 1 | |
| Delete a draft | draft.delete | writes | 1 |
Create a draft
Operation draft.create.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
to | string | Comma-separated recipients. | |||
subject | string | ||||
email_type | options | "html" | Body format. One of html, text. | ||
message | string | Body. Message body in the chosen format. | |||
text_alternative | string | email_type = html | Plain-text alternative. Optional plain-text version sent alongside the HTML. | ||
cc | string | Comma-separated recipients. | |||
bcc | string | Comma-separated recipients. | |||
from | string | A send-as alias configured in Gmail (default: the account address). | |||
reply_to | string | Reply-To. | |||
attachments | string | Comma-separated binary property names to attach (a list of names also works). | |||
thread_id | string | Thread ID. Create the draft as a reply inside this thread. |
Get a draft
Operation draft.get.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
draft | string | yes | Draft ID. | ||
format | options | "full" | One of full, metadata. |
List drafts
Operation draft.list.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
query | string | Search. Gmail search syntax. | |||
include_spam_trash | boolean | false | Include spam and trash. | ||
return_all | boolean | false | |||
limit | number | 50 | return_all = false |
Send a draft
Operation draft.send.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
draft | string | yes | Draft ID. |
Delete a draft
Operation draft.delete.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
draft | string | yes | Draft ID. |
Label
| Operation | ID | Effect | Paginated | Cassette tests |
|---|---|---|---|---|
| Create a label | label.create | writes | 1 | |
| Get a label | label.get | reads | 1 | |
| List labels | label.list | reads | 2 | |
| Update a label | label.update | writes | 1 | |
| Delete a label | label.delete | writes | 1 |
Create a label
Operation label.create.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
name | string | yes | Use slashes for nesting, e.g. Clients/Acme. | ||
label_list_visibility | options | "labelShow" | Show in label list. One of labelShow, labelShowIfUnread, labelHide. | ||
message_list_visibility | options | "show" | Show in message list. One of show, hide. | ||
background_color | string | One of the colors Gmail offers. | |||
text_color | string |
Get a label
Operation label.get.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
label | options | yes | Values from lookup labels. |
List labels
Operation label.list.
This node has no parameters.
Update a label
Operation label.update.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
label | options | yes | Values from lookup labels. | ||
name | string | New name. | |||
label_list_visibility | options | Show in label list. One of labelShow, labelShowIfUnread, labelHide. | |||
message_list_visibility | options | Show in message list. One of show, hide. | |||
background_color | string | One of the colors Gmail offers. | |||
text_color | string |
Delete a label
Operation label.delete. Removes the label from all messages and deletes it.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
label | options | yes | Values from lookup labels. |
Lookups
Lookups fill dropdowns and resource pickers in the editor from the vendor API.
| Lookup | Depends on | Search | Description |
|---|---|---|---|
labels | client-side | {{ ‘System label’ if item.type == ‘system’ else ‘Your label’ }} |
Triggers
Node type connector.gmail_trigger.
| Trigger | ID | Kind | Deduplication key | Signature | Webhook registration | Cassette tests |
|---|---|---|---|---|---|---|
| New email | message_received | poll | {{ '' if item.id == '_cursor' else item.id }} | 0 |
Trigger: New email
Emits each message added to the mailbox since the previous poll (from the Gmail history, so nothing is missed between polls). Items carry the message, thread and label IDs; use Get an email to read the content.
| Name | Type | Default | Required | Shown when | Description |
|---|---|---|---|---|---|
label | options | Only with label. For example INBOX; leave empty to watch every new message. Values from lookup labels. | |||
include_sent | boolean | false | Include messages you send. | ||
include_spam_trash | boolean | false | Include spam and trash. |
Import
Exported workflows that use these node types import to this node. Unverified ranges import with a parameter warning until parity fixtures confirm them; see Migrating.
| Source type | Version range | Status | Fixtures |
|---|---|---|---|
n8n-nodes-base.gmail | >=2 <3 | unverified | |
n8n-nodes-base.gmailTrigger | >=1 <2 | unverified |
Provenance
Written from the vendor’s documentation:
- https://developers.google.com/gmail/api/reference/rest
- https://developers.google.com/gmail/api/reference/rest/v1/users.messages
- https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send
- https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get
- https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list
- https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify
- https://developers.google.com/gmail/api/reference/rest/v1/users.messages.attachments/get
- https://developers.google.com/gmail/api/reference/rest/v1/users.threads
- https://developers.google.com/gmail/api/reference/rest/v1/users.drafts
- https://developers.google.com/gmail/api/reference/rest/v1/users.labels
- https://developers.google.com/gmail/api/reference/rest/v1/users.history/list
- https://developers.google.com/gmail/api/reference/rest/v1/users/getProfile
- https://developers.google.com/gmail/api/guides/sending
- https://developers.google.com/gmail/api/guides/threads
- https://developers.google.com/gmail/api/guides/sync
- https://developers.google.com/gmail/api/guides/filtering
- https://developers.google.com/gmail/api/guides/handle-errors
- https://developers.google.com/gmail/api/reference/quota
- https://developers.google.com/gmail/api/auth/scopes
- https://developers.google.com/identity/protocols/oauth2/web-server
- https://developers.google.com/identity/protocols/oauth2/service-account
- https://www.rfc-editor.org/rfc/rfc2822