Email
Research
Email engineering guide

Gmail API integration from consent to recovery

A complete Gmail connector joins OAuth, MIME messages, labels, threads, history-based sync, Pub/Sub watches, and recovery into one account lifecycle.

Research surface only. This guide documents architecture and evaluation criteria; it does not describe a released DewEngine connector.
01
Authorization

Map features to the smallest Gmail scopes

Sending alone can use gmail.send, while mailbox reads, drafts, and label changes need different access. Document the reason for each requested scope and complete the applicable Google verification before production onboarding.

  • Send-only workflow
  • Read-only mailbox workflow
  • Draft and modify workflow
  • Disconnect and revoke path
02
Resource model

Preserve Gmail's message, thread, and label identities

Normalize common fields without discarding threadId, historyId, label IDs, or raw MIME structure. Gmail labels are not identical to hierarchical folders, and a message can carry several labels at once.

03
Synchronization

Combine full sync, history, and mailbox watches

Create the baseline first, then consume history records after a Pub/Sub wake-up. Renew watches before expiration and keep a periodic reconciliation path because notifications can be delayed or dropped.

04
Failure model

Recover explicitly from stale state

A history cursor outside Gmail's available range returns HTTP 404 and requires a fresh full sync. Token revocation, quota responses, MIME parse errors, and missing messages should each produce a distinct, actionable account or item state.

  • Cursor-expired resync
  • Credential reconnect
  • Provider throttling
  • Per-message parse diagnostics
Questions

Before you build.

Are Gmail labels the same as folders?+

No. Labels can overlap on one message, while many folder models imply a single location. A unified schema should retain the Gmail label set instead of forcing a lossy conversion.

Can Gmail webhooks replace synchronization?+

No. Pub/Sub tells the service that mailbox history advanced; history.list and resource retrieval provide the actual changes.

Can I use DewEngine's email connectors today?+

Not yet. Gmail, Microsoft Graph, and IMAP/SMTP connectors are planned. This guide documents the intended architecture and the provider requirements a production release must satisfy.

Build with us

Does this match the workflow your users need?

DewEngine is in development. Real use cases decide what ships first.

Share your use case