Sapilon becomes publicly available on 1 December 2026: 42 days to go. The core goes open source the same day →

Gmail integration

In short

Read and search mail, and send or draft email. Connect it on the Integrations page; your app then calls Gmail through Sapilon without ever holding a Google credential.

Lets your app search and read the connected Gmail account’s messages and threads, and — with the permissions you choose — save drafts and send email as that account.

Connecting

On the Integrations page choose Connect on Gmail, sign in to Google and allow access. Under Advanced you can use your own Google OAuth app instead of Sapilon’s.

You choose these permissions while connecting:

  • Send email (on by default)

  • Save drafts

  • Your app can read every message in this mailbox.

  • Reading mail is a restricted Google permission: until Sapilon’s Google app passes Google’s assessment, use Advanced → Bring your own OAuth app. To only send email from your app, use the Email service instead.

What your app can do

Only these requests are available; anything else is refused.

  • GET /users/me/profile
  • GET /users/me/messages
  • GET /users/me/messages/*
  • POST /users/me/messages/send
  • GET /users/me/threads
  • GET /users/me/threads/*
  • GET|POST /users/me/drafts
  • GET /users/me/labels

How the agent uses it

Use integrations.request('gmail', …); paths are relative to https://gmail.googleapis.com/gmail/v1.

  • GET /users/me/profile, GET /users/me/labels.
  • GET /users/me/messages — ids only. Example: { method: 'GET', path: '/users/me/messages', query: { q: 'from:billing@acme.com newer_than:7d', maxResults: '20' } } (Gmail search syntax).
  • GET /users/me/messages/{id} — query: { format: 'metadata', metadataHeaders: 'Subject' } or format: 'full'; bodies are base64url in payload.parts.
  • GET /users/me/threads, GET /users/me/threads/{id}.
  • POST /users/me/messages/send — body: { raw }, where raw is a base64url RFC 2822 message (To:, Subject:, blank line, text). Add threadId to reply in a thread.
  • GET|POST /users/me/drafts — body: { message: { raw } }.

Sending needs the “Send email” permission. Deleting and changing labels are not allowed.

More from Google: https://developers.google.com/workspace/gmail/api

Last updated .

Was this page helpful?