Gmail
SDK reference for gmail operations
Overview
Gmail email management and automation
- Category:
communication - Auth Required: Yes
- Supported Modes: standard, delegated
Operations
sendEmail
Send an email via Gmail
Arguments:
to(string, required): Valid email addresssubject(string, required): Email subject linebody(string, required): Email body contentcc(string, optional): CC recipients (comma-separated email addresses)bcc(string, optional): BCC recipients (comma-separated email addresses)isHtml(boolean, optional): Whether body is HTML format
Returns:
AdapterOperationResult - Email send confirmation with message ID
Response Fields:
| Field | Type | Description |
|---|---|---|
messageId | string | ID of the sent message |
to | string | Recipient email address |
subject | string | Email subject |
sentAt | string | ISO timestamp when sent |
Example:
searchEmails
Search emails with Gmail query syntax. Returns normalized email summaries.
Arguments:
query(string, required): Gmail search query (e.g., "from:user@example.com is:unread")maxResults(number, optional): Maximum number of results to return (default: 50, max: 100)
Returns:
AdapterOperationResult - Array of normalized email summaries with flat structure
Response Fields:
| Field | Type | Description |
|---|---|---|
query | string | Search query used |
count | number | Number of results |
emails | GoogleGmailEmailSummary[] | List of matching emails |
emails item fields (GoogleGmailEmailSummary)
| Field | Type | Description |
|---|---|---|
id | string | Unique email ID |
threadId | string | Thread ID |
subject | string | Email subject |
from | string | Sender email address |
to | string | Recipient email address |
date | string | ISO timestamp |
snippet | string | Preview snippet |
labelIds | string[] | Gmail label IDs |
isUnread | boolean | Whether email is unread |
hasAttachments | boolean | Whether email has attachments |
Example:
listEmails
List recent emails from inbox. Returns normalized email summaries.
Arguments:
maxResults(number, optional): Maximum number of results to return (default: 50, max: 100)
Returns:
AdapterOperationResult - Array of normalized email summaries
Response Fields:
| Field | Type | Description |
|---|---|---|
query | string | Search query used |
count | number | Number of results |
emails | GoogleGmailEmailSummary[] | List of emails |
emails item fields (GoogleGmailEmailSummary)
| Field | Type | Description |
|---|---|---|
id | string | Unique email ID |
threadId | string | Thread ID |
subject | string | Email subject |
from | string | Sender email address |
to | string | Recipient email address |
date | string | ISO timestamp |
snippet | string | Preview snippet |
labelIds | string[] | Gmail label IDs |
isUnread | boolean | Whether email is unread |
hasAttachments | boolean | Whether email has attachments |
Example:
getEmail
Get full details of a specific email by ID. Returns normalized flat structure.
Arguments:
messageId(string, required): Gmail message IDincludeHtml(boolean, optional): Include HTML body content (default: false)includeAttachments(boolean, optional): Include attachment metadata (default: false)
Returns:
AdapterOperationResult - Normalized email with all fields extracted to flat structure
Response Fields:
| Field | Type | Description |
|---|---|---|
id | string | Unique email ID |
threadId | string | Thread ID |
subject | string | Email subject |
from | string | Sender email address |
to | string | Recipient email address |
cc | string | CC recipients (optional) |
bcc | string | BCC recipients (optional) |
date | string | ISO timestamp of email |
body | string | Plain text body content |
bodyHtml | string | HTML body content (optional) |
snippet | string | Email preview snippet |
labelIds | string[] | Gmail label IDs |
isUnread | boolean | Whether email is unread |
hasAttachments | boolean | Whether email has attachments |
attachments | GoogleGmailAttachment[] | Attachment metadata (optional) |
attachments item fields (GoogleGmailAttachment)
| Field | Type | Description |
|---|---|---|
filename | string | Attachment filename |
mimeType | string | MIME type |
size | number | Size in bytes |
attachmentId | string | Attachment ID |
Example:
createDraft
Create a draft email in Gmail
Arguments:
to(string, required): Valid email addresssubject(string, required): Email subject linebody(string, required): Email body contentcc(string, optional): CC recipients (comma-separated email addresses)bcc(string, optional): BCC recipients (comma-separated email addresses)isHtml(boolean, optional): Whether body is HTML format
Returns:
AdapterOperationResult - Draft creation confirmation with draft ID
Response Fields:
| Field | Type | Description |
|---|---|---|
draftId | string | ID of created draft |
subject | string | Draft subject |
to | string | Recipient email address |
Example:
updateDraft
Update an existing draft email
Arguments:
draftId(string, required): Gmail draft ID to updateto(string, optional): Updated recipient email address(es)subject(string, optional): Updated email subject linebody(string, optional): Updated email body contentcc(string, optional): Updated CC recipientsbcc(string, optional): Updated BCC recipientsisHtml(boolean, optional): Whether body is HTML format
Returns:
AdapterOperationResult - Draft update confirmation
Response Fields:
| Field | Type | Description |
|---|---|---|
draftId | string | ID of updated draft |
updated | boolean | Whether update succeeded |
Example:
deleteDraft
Delete a draft email
Arguments:
draftId(string, required): Gmail draft ID to delete
Returns:
AdapterOperationResult - Draft deletion confirmation
Response Fields:
| Field | Type | Description |
|---|---|---|
draftId | string | ID of deleted draft |
deleted | boolean | Whether deletion succeeded |
Example:
listDrafts
List all draft emails. Returns normalized draft summaries.
Arguments:
maxResults(number, optional): Maximum number of drafts to return (default: 10)
Returns:
AdapterOperationResult - Array of normalized draft summaries
Response Fields:
| Field | Type | Description |
|---|---|---|
count | number | Number of drafts |
drafts | GoogleGmailDraftSummary[] | List of drafts |
drafts item fields (GoogleGmailDraftSummary)
| Field | Type | Description |
|---|---|---|
id | string | Draft ID |
messageId | string | Associated message ID |
subject | string | Draft subject |
to | string | Recipient email |
snippet | string | Preview snippet |
Example:
deleteEmail
Delete an email
Arguments:
messageId(string, required): Gmail message ID to delete
Returns:
AdapterOperationResult - Email deletion confirmation
Response Fields:
| Field | Type | Description |
|---|---|---|
messageId | string | ID of deleted email |
deleted | ``'permanent' | 'trash'`` |
Example:
bulkDeleteEmails
Delete multiple emails at once. Uses Gmail batchDelete API for efficiency.
Arguments:
messageIds(array, required): Array of Gmail message IDs to delete (max 1000 per request)permanently(boolean, optional): If true, permanently delete. If false (default), move to trash.
Returns:
AdapterOperationResult - Bulk deletion confirmation with count of deleted emails
Response Fields:
| Field | Type | Description |
|---|---|---|
deletedCount | number | Number of emails deleted |
messageIds | string[] | IDs of deleted emails |
deleted | ``'permanent' | 'trash'`` |
Example: