Skip to content

Integrations

Gmail

Send, read, search, and move Gmail messages or trigger workflows from Gmail events

Use Gmail to send or draft messages, read and search mail, and manage labels and read status. Gmail triggers can start a workflow when new mail arrives.

OAuth scopes

Sim requests these scopes when someone connects a Gmail account. For a self-hosted deployment, register your own app with the provider using the settings below. See Integrations and OAuth for setup.

SettingValue
Redirect URI<NEXT_PUBLIC_APP_URL>/api/auth/oauth2/callback/google-email
Environment variablesGOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
ScopeDescription
https://www.googleapis.com/auth/userinfo.emailView email address
https://www.googleapis.com/auth/userinfo.profileView basic profile info
https://www.googleapis.com/auth/gmail.sendSend emails
https://www.googleapis.com/auth/gmail.modifyRead, compose, send, and modify email messages
https://www.googleapis.com/auth/gmail.labelsView and manage email labels

Use the block

Send or draft messages, read and search mail, and manage labels and read status. New-mail triggers can start workflows.

Actions

Gmail Send

Send emails using Gmail.

Inputs and outputs

Input

ParameterTypeRequiredDescription
tostringYesRecipient email address
subjectstringNoEmail subject
bodystringYesEmail body content
contentTypestringNoContent type for the email body (text or html)
threadIdstringNoThread ID to reply to (for threading)
replyToMessageIdstringNoGmail message ID to reply to - use the "id" field from Gmail Read results (not "rfcMessageId")
ccstringNoCC recipients (comma-separated)
bccstringNoBCC recipients (comma-separated)
replyTostringNoReply-To address that replies should go to (e.g., support@example.com)
attachmentsfile[]NoFiles to attach to the email

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayEmail labels

Gmail Draft

Draft emails using Gmail.

Inputs and outputs

Input

ParameterTypeRequiredDescription
tostringYesRecipient email address
subjectstringNoEmail subject
bodystringYesEmail body content
contentTypestringNoContent type for the email body (text or html)
threadIdstringNoThread ID to reply to (for threading)
replyToMessageIdstringNoGmail message ID to reply to - use the "id" field from Gmail Read results (not "rfcMessageId")
ccstringNoCC recipients (comma-separated)
bccstringNoBCC recipients (comma-separated)
replyTostringNoReply-To address that replies should go to (e.g., support@example.com)
attachmentsfile[]NoFiles to attach to the email draft

Output

ParameterTypeDescription
draftIdstringDraft ID
messageIdstringGmail message ID for the draft
threadIdstringGmail thread ID
labelIdsarrayEmail labels

Gmail Edit Draft

Update an existing Gmail draft in place without deleting and recreating it.

Inputs and outputs

Input

ParameterTypeRequiredDescription
draftIdstringYesID of the draft to update (from Gmail List Drafts or Gmail Get Draft)
tostringYesRecipient email address
subjectstringNoEmail subject
bodystringYesEmail body content
contentTypestringNoContent type for the email body (text or html)
threadIdstringNoThread ID to associate the draft with (for threading)
replyToMessageIdstringNoGmail message ID to reply to - use the "id" field from Gmail Read results (not "rfcMessageId")
ccstringNoCC recipients (comma-separated)
bccstringNoBCC recipients (comma-separated)
replyTostringNoReply-To address that replies should go to (e.g., support@example.com)
attachmentsfile[]NoFiles to attach to the email draft

Output

ParameterTypeDescription
draftIdstringDraft ID
messageIdstringGmail message ID for the draft
threadIdstringGmail thread ID
labelIdsarrayEmail labels

Gmail Read

Read emails from Gmail.

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringNoGmail message ID to read (e.g., 18f1a2b3c4d5e6f7)
folderstringNoFolder/label to read emails from (e.g., INBOX, SENT, DRAFT, TRASH, SPAM, or custom label name)
unreadOnlybooleanNoSet to true to only retrieve unread messages
maxResultsnumberNoMaximum number of messages to retrieve (default: 1, max: 10)
includeAttachmentsbooleanNoSet to true to download and include email attachments

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayEmail labels
fromstringSender email address
tostringRecipient email address
ccstringCc recipients (raw Cc header)
bccstringBcc recipients (only present on messages you sent or drafted)
replyTostringReply-To header
subjectstringEmail subject
datestringEmail date
rfcMessageIdstringRFC Message-ID header (not the Gmail message id)
inReplyTostringIn-Reply-To header
referencesstringReferences header
snippetstringShort excerpt of the message text
internalDatestringGmail internal creation timestamp in epoch milliseconds
bodystringEmail body text (best-effort plain text)
hasAttachmentsbooleanWhether the email has attachments
attachmentCountnumberNumber of attachments
attachmentsfile[]Downloaded attachments (if enabled)
resultsjsonSummary results when reading multiple messages (id, threadId, subject, from, to, cc, bcc, replyTo, date, rfcMessageId, inReplyTo, references, snippet, internalDate)

Search emails in Gmail.

Inputs and outputs

Input

ParameterTypeRequiredDescription
querystringYesSearch query for emails
maxResultsnumberNoMaximum number of results to return (e.g., 10, 25, 50; Gmail default: 100, max: 500)
pageTokenstringNoPage token from a previous search (nextPageToken) to fetch the next page

Output

ParameterTypeDescription
resultsjsonArray of search results (id, threadId, subject, from, to, cc, bcc, replyTo, date, snippet, rfcMessageId, inReplyTo, references, internalDate)
nextPageTokenstringToken for fetching the next page of results
resultSizeEstimatenumberEstimated total number of results

Gmail Move

Move emails between labels/folders in Gmail.

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to move
addLabelIdsstringYesComma-separated label IDs to add (e.g., INBOX, Label_123)
removeLabelIdsstringNoComma-separated label IDs to remove (e.g., INBOX, SPAM)

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayEmail labels

Gmail Mark as Read

Mark a Gmail message as read.

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to mark as read

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayUpdated email labels

Gmail Mark as Unread

Mark a Gmail message as unread.

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to mark as unread

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayUpdated email labels

Gmail Archive

Archive a Gmail message (remove from inbox).

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to archive

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayUpdated email labels

Gmail Unarchive

Unarchive a Gmail message (move back to inbox).

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to unarchive

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayUpdated email labels

Gmail Delete

Delete a Gmail message (move to trash).

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to delete

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayUpdated email labels

Gmail Add Label

Add label(s) to a Gmail message.

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to add labels to
labelIdsstringYesComma-separated label IDs to add (e.g., INBOX, Label_123)

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayUpdated email labels

Gmail Remove Label

Remove label(s) from a Gmail message.

Inputs and outputs

Input

ParameterTypeRequiredDescription
messageIdstringYesID of the message to remove labels from
labelIdsstringYesComma-separated label IDs to remove (e.g., INBOX, Label_123)

Output

ParameterTypeDescription
idstringGmail message ID
threadIdstringGmail thread ID
labelIdsarrayUpdated email labels

Gmail List Labels

List all labels in a Gmail account

Inputs and outputs

Input

ParameterTypeRequiredDescription

Output

ParameterTypeDescription
labelsjsonArray of label objects with id, name, type, and visibility settings

Gmail Create Label

Create a new label in Gmail

Inputs and outputs

Input

ParameterTypeRequiredDescription
namestringYesDisplay name for the new label
messageListVisibilitystringNoVisibility of messages with this label in the message list (show or hide)
labelListVisibilitystringNoVisibility of the label in the label list (labelShow, labelShowIfUnread, or labelHide)

Output

ParameterTypeDescription
idstringLabel ID
namestringLabel display name
messageListVisibilitystringVisibility of messages with this label
labelListVisibilitystringVisibility of the label in the label list
typestringLabel type (system or user)

Gmail Update Label

Update a Gmail label in place (rename or change visibility) without recreating it

Inputs and outputs

Input

ParameterTypeRequiredDescription
labelIdstringYesID of the label to update (from Gmail List Labels)
namestringNoNew display name for the label
messageListVisibilitystringNoVisibility of messages with this label in the message list (show or hide)
labelListVisibilitystringNoVisibility of the label in the label list (labelShow, labelShowIfUnread, or labelHide)

Output

ParameterTypeDescription
idstringLabel ID
namestringLabel display name
messageListVisibilitystringVisibility of messages with this label
labelListVisibilitystringVisibility of the label in the label list
typestringLabel type (system or user)

Gmail Delete Label

Delete a label from Gmail

Inputs and outputs

Input

ParameterTypeRequiredDescription
labelIdstringYesID of the label to delete

Output

ParameterTypeDescription
deletedbooleanWhether the label was successfully deleted
labelIdstringID of the deleted label

Gmail List Drafts

List all drafts in a Gmail account

Inputs and outputs

Input

ParameterTypeRequiredDescription
maxResultsnumberNoMaximum number of drafts to return (default: 100, max: 500)
pageTokenstringNoPage token for paginated results
querystringNoSearch query to filter drafts (same syntax as Gmail search)

Output

ParameterTypeDescription
draftsjsonArray of draft objects with id, messageId, and threadId
resultSizeEstimatenumberEstimated total number of drafts
nextPageTokenstringToken for fetching the next page of results

Gmail Get Draft

Get a specific draft from Gmail by its ID

Inputs and outputs

Input

ParameterTypeRequiredDescription
draftIdstringYesID of the draft to retrieve

Output

ParameterTypeDescription
idstringDraft ID
messageIdstringGmail message ID
threadIdstringGmail thread ID
tostringRecipient email address
fromstringSender email address
ccstringCc recipients
bccstringBcc recipients
replyTostringReply-To header
subjectstringDraft subject
datestringDate header
rfcMessageIdstringRFC Message-ID header (not the Gmail message id)
inReplyTostringIn-Reply-To header
referencesstringReferences header
snippetstringShort excerpt of the draft text
bodystringDraft body text
labelIdsarrayDraft labels

Gmail Delete Draft

Delete a specific draft from Gmail

Inputs and outputs

Input

ParameterTypeRequiredDescription
draftIdstringYesID of the draft to delete

Output

ParameterTypeDescription
deletedbooleanWhether the draft was successfully deleted
draftIdstringID of the deleted draft

Gmail List Threads

List email threads in a Gmail account

Inputs and outputs

Input

ParameterTypeRequiredDescription
maxResultsnumberNoMaximum number of threads to return (default: 100, max: 500)
pageTokenstringNoPage token for paginated results
querystringNoSearch query to filter threads (same syntax as Gmail search)
labelIdsstringNoComma-separated label IDs to filter threads by

Output

ParameterTypeDescription
threadsjsonArray of thread objects with id, snippet, and historyId
resultSizeEstimatenumberEstimated total number of threads
nextPageTokenstringToken for fetching the next page of results

Gmail Get Thread

Get a specific email thread from Gmail, including all messages in the thread

Inputs and outputs

Input

ParameterTypeRequiredDescription
threadIdstringYesID of the thread to retrieve
formatstringNoFormat to return the messages in (full, metadata, or minimal). Defaults to full.

Output

ParameterTypeDescription
idstringThread ID
historyIdstringHistory ID
snippetstringShort excerpt of the thread
messagesjsonArray of messages in the thread with id, threadId, labelIds, snippet, from, to, cc, bcc, replyTo, subject, date, rfcMessageId, inReplyTo, references, internalDate, and body

Gmail Trash Thread

Move an email thread to trash in Gmail

Inputs and outputs

Input

ParameterTypeRequiredDescription
threadIdstringYesID of the thread to trash

Output

ParameterTypeDescription
idstringThread ID
trashedbooleanWhether the thread was successfully trashed

Gmail Untrash Thread

Remove an email thread from trash in Gmail

Inputs and outputs

Input

ParameterTypeRequiredDescription
threadIdstringYesID of the thread to untrash

Output

ParameterTypeDescription
idstringThread ID
untrashedbooleanWhether the thread was successfully removed from trash

Triggers

A trigger starts a workflow when a supported event occurs in this service.

These triggers poll for new data on a schedule.

Gmail Email Trigger

Triggers when new emails are received in Gmail (requires Gmail credentials)

Configuration and outputs

Configuration

ParameterTypeRequiredDescription
triggerCredentialsstringYesThis trigger requires google email credentials to access your account.
labelIdsstringNoChoose which Gmail labels to monitor. Leave empty to monitor all emails.
labelFilterBehaviorstringYesInclude only emails with selected labels, or exclude emails with selected labels
searchQuerystringNoOptional Gmail search query to filter emails. Use the same format as Gmail search box (e.g., "subject:invoice", "from:boss@company.com", "has:attachment"). Leave empty to search all emails.
markAsReadbooleanNoAutomatically mark emails as read after processing
includeAttachmentsbooleanNoDownload and include email attachments in the trigger payload

Output

ParameterTypeDescription
emailobject
↳ idstringGmail message ID
↳ threadIdstringGmail thread ID
↳ subjectstringEmail subject line
↳ fromstringSender email address
↳ tostringRecipient email address
↳ ccstringCC recipients
↳ bccstringBCC recipients (only present on messages you sent)
↳ replyTostringReply-To header
↳ rfcMessageIdstringRFC Message-ID header (not the Gmail message ID)
↳ inReplyTostringIn-Reply-To header (RFC Message-ID of the parent message)
↳ referencesstringReferences header (RFC Message-IDs in the thread)
↳ snippetstringShort excerpt of the message text
↳ datestringEmail date in ISO format
↳ bodyTextstringPlain text email body
↳ bodyHtmlstringHTML email body
↳ labelsarrayEmail labels array
↳ hasAttachmentsbooleanWhether email has attachments
↳ attachmentsfile[]Array of email attachments as files (if includeAttachments is enabled)
timestampstringEvent timestamp
Was this helpful?
Suggest an edit