Skip to main content

The short answer

Yes. Commune OAuth connects your agent to your existing Gmail, Outlook, or any IMAP-compatible email account. Your agent reads and sends email through the Commune API, and Commune syncs with your actual mailbox in the background. You keep your address. Your contacts see no difference.

Why you’d want this

Most agent-native email tutorials start with “create a new inbox.” That’s fine for purpose-built agents. But a whole class of use cases needs the agent to work with an existing email account:
  • Personal AI assistants — “Read my inbox and draft replies” requires your actual inbox
  • Executive agents — the CEO’s agent needs to send as the CEO, not as ceo-agent@commune.email
  • CRM agents — parsing email threads from a sales rep’s existing Outlook account
  • Support migration — connecting an agent to your existing support@company.com without changing the address
Commune OAuth solves this. Your agent gets API access to a real mailbox. The email address stays the same.

How it works

Commune acts as a middleware layer between your agent and the email provider. Your agent never talks to Gmail or Outlook directly — it uses the same Commune API it would use with a Commune-native inbox. The connection is established once through an OAuth flow. After that, your agent uses the standard Commune SDK — commune.messages.send(), commune.messages.list(), webhooks for inbound — and Commune handles the provider sync.

Setting up the connection

Step 1: Register your app with Commune OAuth

Step 2: Initiate the OAuth flow

Direct the user (or agent operator) to connect their email account:

Step 3: Handle the callback

After the user grants access, the provider redirects to your callback URL with an authorization code:

Step 4: Use the connection

Once connected, your agent uses the standard Commune API with the connection_id:

Supported providers

Gmail and Outlook connections use official OAuth APIs and sync in real-time. IMAP connections poll every 30 seconds for new messages and use SMTP for sending.

What’s different from a Commune inbox

A Commune-native inbox (like agent@yourdomain.com with DNS pointed at Commune) gives you full control: warmup, reputation management, delivery monitoring, and domain-level settings. A connected account is your existing mailbox accessed through Commune’s API layer. Here’s how they compare: The API surface is identical. Code you write for a Commune inbox works with a connected account — just swap inboxId for connectionId.

Privacy and data handling

Commune processes email in transit but does not store email content permanently for connected accounts:
  • Email content is parsed, processed (extraction, threading, prompt injection scanning), and delivered to your webhook. It is not retained after delivery.
  • Metadata (sender, recipient, subject, timestamps, thread IDs) is stored for thread resolution and API queries.
  • OAuth tokens are encrypted at rest and used only for syncing with the provider.
  • You can disconnect at any time. Revoking the connection deletes Commune’s access tokens and stops all syncing immediately.
Connected account data handling follows your Commune plan’s data retention policy. Check your plan details for specifics on metadata retention periods.

Commune OAuth Overview

Full OAuth architecture, token lifecycle, and integration patterns.

OAuth Quickstart

Working example in about 30 lines of code.

Inboxes

Creating Commune-native inboxes when you want a dedicated agent address.

Do agents need their own email infrastructure?

When to use a Commune inbox vs. connecting an existing account.
Last modified on March 19, 2026