3 endpoints. Send your API key as Authorization: Bearer <key> on each request; see The API and AI assistants for keys, errors, idempotency and the conventions every endpoint shares.
GET /api/gmail-postmaster
Whether the organisation has connected Gmail Postmaster Tools; never the token or anything about the Google account
While Gmail Postmaster is switched on, a monitor of type gmail_postmaster (POST /api/monitors with name, domain, optional spam_max in per cent from 0.01 to 100 (0.3 when left out), project_id and public_name) reads the domain's daily figures from Google once a day from Postmaster Tools API v2: spam rate and SPF, DKIM and DMARC pass rates (v2 gives no domain reputation, so reputation in postmaster_last is null). Saving the monitor asks Google for the domain's figures: 400 if the connected Google account cannot see the domain, 409 if it is not connected or must be connected again (a connection made for v1), 503 while Google is limiting requests. A spam rate above spam_max is failed (reason postmaster_spam_rate) and opens an incident. A monitor lists its newest day as postmaster_last. Only the daily figures and their day are kept, for the plan's history period.
Responses:
| Status | Meaning |
|---|---|
| 200 | connected, connected_at, connected_by and connected_by_name (the member who connected it), last_read_at, agreement_text (shown beside Connect) and scope |
| 401 | Missing or invalid API key (Error) |
DELETE /api/gmail-postmaster
Disconnect (owners and admins). The token is deleted at once and Google is asked to revoke it
Responses:
| Status | Meaning |
|---|---|
| 200 | deleted true, and revoked (whether Google confirmed the revocation; the token is deleted either way) |
| 401 | Missing or invalid API key (Error) |
| 403 | Not an owner or admin |
| 404 | Not connected |
POST /api/gmail-postmaster/connect
Start connecting the organisation's Google account (owners and admins, signed in to the web app)
Returns the Google address to send the browser to. The scope asked for is postmaster.traffic.readonly only (the figures; not the domain list, which would need a scope that can also manage domains). Needs a browser session (not an API key); a browser-binding cookie af_postmaster is set for 10 minutes. Google sends the browser back to /auth/google-postmaster/callback, which keeps the refresh token encrypted and returns to the Monitors page.
Request body (application/json, required).
| Field | Type | Required | Description |
|---|---|---|---|
agreed | boolean | Yes | Must be true. |
Responses:
| Status | Meaning |
|---|---|
| 200 | url: the Google consent address |
| 400 | agreed is not true |
| 401 | Missing or invalid API key (Error) |
| 403 | Not an owner or admin |