Connect a Google Mailbox (OAuth)

Connect a Gmail or Google Workspace mailbox (campaign) using the OAuth 2.0 refresh-token flow. Unlike Connect a Google Mailbox (App Password), the mailbox owner authorizes through Google's consent screen and never generates or shares an app password.

The partner performs the Google OAuth consent flow and supplies Mailivery with a long-lived google_refresh_token plus an initial google_token. Partners do not need to push fresh access tokens over the lifetime of the campaign.

Before you start — save your Google OAuth credentials in Mailivery. Token refresh uses your own Google Cloud OAuth app, so Mailivery needs that app's credentials on file. In the Mailivery app, go to Settings → Team Settings → API Access and fill in the Google OAuth Credentials form: paste the Client ID and Client Secret from your Google OAuth app, then click Save Credentials. The values are stored encrypted and are not displayed again after saving. Save them before you create your first OAuth mailbox — a mailbox created beforehand connects successfully, but cannot refresh its access token once the initial one expires.

Technical detail. Mailivery authenticates to Gmail's IMAP and SMTP servers using the XOAUTH2 SASL mechanism, exchanging the stored refresh token for short-lived access tokens as needed. The Google scope must be the full https://mail.google.com/ scope; narrower scopes are not sufficient for IMAP XOAUTH2.

Body Params
string
required

Google OAuth2 access token. May be short-lived — Mailivery refreshes it before every send, read, and connection check.

string
required

Long-lived OAuth2 refresh token issued with the full https://mail.google.com/ scope.

string
required
string
required
string
required
string
string
string
required
boolean
Defaults to false
enum
Defaults to normal
Allowed:
string
Defaults to America/Chicago

If no timezone is passed, Mailivery will use the default timezone set at the team level.

enum
Allowed:
string
enum
Defaults to inherit

Optional. Warm-up audience for the mailbox being created.

  • all -> warm up with both business and consumer mailboxes.
  • business -> warm up with business mailboxes only.
  • consumer -> warm up with consumer mailboxes only.
  • inherit -> follow the team-level setting. This is the default when the field is omitted.
Allowed:
string
enum
Defaults to inherit

Optional. Warm-up topics for the mailbox being created. See the Warm-Up Topics endpoints for the catalogue and the selection rules.

  • inherit -> follow the team setting. This is the default when the field is omitted.
  • general -> General content only for this mailbox. Send no warmup_topic_selections.
  • custom -> use warmup_topic_selections, which is then required.

To confirm what was saved, call GET /campaigns/{campaignId}/preferences/warmup-topics with the new id.

Allowed:
warmup_topic_selections
array of objects | null

Required when warmup_topic_mode is custom; omit it, or send [], otherwise. Sending industries in it without warmup_topic_mode returns 400 VALIDATION_ERROR.

Same rules as PATCH /campaigns/{campaignId}/preferences/warmup-topics: at most 5 industries with 1 to 5 topics each, names exactly as GET /warmup-topics returns them. Every industry must be available: true, because a new mailbox has nothing saved yet.

In multipart/form-data, send it in bracket notation, not as a JSON-encoded string (a string is rejected):
warmup_topic_selections[0][industry]=marketing_agencies and warmup_topic_selections[0][topics][]=Campaign performance reporting.

warmup_topic_selections
string | null
Responses

WARMUP_TOPICS_NOT_ENABLED when warmup_topic_mode is general or custom and warm-up topic selection is not enabled for the team the new mailbox inherits from. No mailbox is created.

Language
Credentials
Bearer
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json