Mirra
IntegrationsGoogle

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 address
  • subject (string, required): Email subject line
  • body (string, required): Email body content
  • cc (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:

FieldTypeDescription
messageIdstringID of the sent message
tostringRecipient email address
subjectstringEmail subject
sentAtstringISO timestamp when sent

Example:

const result = await mirra.googleGmail.sendEmail({
  to: "example",
  subject: "example",
  body: "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:

FieldTypeDescription
querystringSearch query used
countnumberNumber of results
emailsGoogleGmailEmailSummary[]List of matching emails
emails item fields (GoogleGmailEmailSummary)
FieldTypeDescription
idstringUnique email ID
threadIdstringThread ID
subjectstringEmail subject
fromstringSender email address
tostringRecipient email address
datestringISO timestamp
snippetstringPreview snippet
labelIdsstring[]Gmail label IDs
isUnreadbooleanWhether email is unread
hasAttachmentsbooleanWhether email has attachments

Example:

const result = await mirra.googleGmail.searchEmails({
  query: "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:

FieldTypeDescription
querystringSearch query used
countnumberNumber of results
emailsGoogleGmailEmailSummary[]List of emails
emails item fields (GoogleGmailEmailSummary)
FieldTypeDescription
idstringUnique email ID
threadIdstringThread ID
subjectstringEmail subject
fromstringSender email address
tostringRecipient email address
datestringISO timestamp
snippetstringPreview snippet
labelIdsstring[]Gmail label IDs
isUnreadbooleanWhether email is unread
hasAttachmentsbooleanWhether email has attachments

Example:

const result = await mirra.googleGmail.listEmails({});

getEmail

Get full details of a specific email by ID. Returns normalized flat structure.

Arguments:

  • messageId (string, required): Gmail message ID
  • includeHtml (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:

FieldTypeDescription
idstringUnique email ID
threadIdstringThread ID
subjectstringEmail subject
fromstringSender email address
tostringRecipient email address
ccstringCC recipients (optional)
bccstringBCC recipients (optional)
datestringISO timestamp of email
bodystringPlain text body content
bodyHtmlstringHTML body content (optional)
snippetstringEmail preview snippet
labelIdsstring[]Gmail label IDs
isUnreadbooleanWhether email is unread
hasAttachmentsbooleanWhether email has attachments
attachmentsGoogleGmailAttachment[]Attachment metadata (optional)
attachments item fields (GoogleGmailAttachment)
FieldTypeDescription
filenamestringAttachment filename
mimeTypestringMIME type
sizenumberSize in bytes
attachmentIdstringAttachment ID

Example:

const result = await mirra.googleGmail.getEmail({
  messageId: "abc123"
});

createDraft

Create a draft email in Gmail

Arguments:

  • to (string, required): Valid email address
  • subject (string, required): Email subject line
  • body (string, required): Email body content
  • cc (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:

FieldTypeDescription
draftIdstringID of created draft
subjectstringDraft subject
tostringRecipient email address

Example:

const result = await mirra.googleGmail.createDraft({
  to: "example",
  subject: "example",
  body: "example"
});

updateDraft

Update an existing draft email

Arguments:

  • draftId (string, required): Gmail draft ID to update
  • to (string, optional): Updated recipient email address(es)
  • subject (string, optional): Updated email subject line
  • body (string, optional): Updated email body content
  • cc (string, optional): Updated CC recipients
  • bcc (string, optional): Updated BCC recipients
  • isHtml (boolean, optional): Whether body is HTML format

Returns:

AdapterOperationResult - Draft update confirmation

Response Fields:

FieldTypeDescription
draftIdstringID of updated draft
updatedbooleanWhether update succeeded

Example:

const result = await mirra.googleGmail.updateDraft({
  draftId: "abc123"
});

deleteDraft

Delete a draft email

Arguments:

  • draftId (string, required): Gmail draft ID to delete

Returns:

AdapterOperationResult - Draft deletion confirmation

Response Fields:

FieldTypeDescription
draftIdstringID of deleted draft
deletedbooleanWhether deletion succeeded

Example:

const result = await mirra.googleGmail.deleteDraft({
  draftId: "abc123"
});

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:

FieldTypeDescription
countnumberNumber of drafts
draftsGoogleGmailDraftSummary[]List of drafts
drafts item fields (GoogleGmailDraftSummary)
FieldTypeDescription
idstringDraft ID
messageIdstringAssociated message ID
subjectstringDraft subject
tostringRecipient email
snippetstringPreview snippet

Example:

const result = await mirra.googleGmail.listDrafts({});

deleteEmail

Delete an email

Arguments:

  • messageId (string, required): Gmail message ID to delete

Returns:

AdapterOperationResult - Email deletion confirmation

Response Fields:

FieldTypeDescription
messageIdstringID of deleted email
deleted``'permanent''trash'``

Example:

const result = await mirra.googleGmail.deleteEmail({
  messageId: "abc123"
});

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:

FieldTypeDescription
deletedCountnumberNumber of emails deleted
messageIdsstring[]IDs of deleted emails
deleted``'permanent''trash'``

Example:

const result = await mirra.googleGmail.bulkDeleteEmails({
  messageIds: []
});

On this page