Gmail

REST Provider
email
6 methods

Send, read, search, and list email messages. List labels and get the user's profile.

See SDK Overview for installation and initialization.

listMessages

List recent messages from the user's inbox. Supports filtering by query, label IDs, and pagination.

TypeScript
const gmail = integrations.gmail
// List recent messages
const messages = await gmail.listMessages({ maxResults: 10 })
// Filter by label
const starred = await gmail.listMessages({
labelIds: ['STARRED'],
maxResults: 5,
})
// With query filter
const unread = await gmail.listMessages({
query: 'is:unread',
maxResults: 20,
})
// Paginate
const nextPage = await gmail.listMessages({
pageToken: messages.nextPageToken,
})

getMessage

Retrieve a single message by ID. Supports format options: full, metadata, minimal, or raw.

TypeScript
// Full message with body
const msg = await gmail.getMessage(messageId)
// Metadata only (headers, no body)
const headers = await gmail.getMessage(messageId, 'metadata')

sendMessage

Send an email on behalf of the user. Supports to, subject, body, cc, and bcc fields.

TypeScript
await gmail.sendMessage({
to: 'recipient@example.com',
subject: 'Hello from my Leash app',
body: 'This email was sent via the Leash SDK.',
cc: 'teammate@example.com', // optional
bcc: 'archive@example.com', // optional
})

searchMessages

Search messages using Gmail search syntax. Returns a paginated list.

TypeScript
const results = await gmail.searchMessages(
'from:boss@company.com is:unread',
10 // maxResults (optional)
)

listLabels

List all Gmail labels for the authenticated user.

TypeScript
const labels = await gmail.listLabels()

getProfile

Get the authenticated user's profile info (email address, messages total, threads total).

TypeScript
const profile = await gmail.getProfile()