Topolo Docs Topolo Platform
Open workspace

Start Mail provider authorization

Prepare a Gmail or Microsoft 365 consent URL for an existing external mailbox.

Outcome

Prepare a Gmail or Microsoft 365 consent URL for an existing external mailbox.

Before you start

  • Verify the intended environment, credential and authorized organization context before discovery.
  • Discover Mail, the exact action and its mailboxes:manage permission. Pass the accessible workspace resource binding separately from action input.
  • Review the actual change, recipients, provider/AI costs and any irreversible effects before confirmation; fixture IDs authorize no live operation.

Discover the target

  • Run credential-scoped Mail discovery and topolo workspaces list topolo-mail; select an authorized canonical workspace.
  • Resolve mailbox IDs through mailboxes.collection.list in that workspace. Resolve message, draft, thread, folder and scheduled IDs through the related published reads; never reuse fixture IDs or another context.
topolo whoami --json
topolo apps get topolo-mail --json
topolo actions get app_topolo_mail.connections.oauth.start --json
topolo workspaces list topolo-mail --json

Request

Create payload.json using the current input schema and discovered identifiers. Plan the unchanged request before execution.

topolo actions validate app_topolo_mail.connections.oauth.start --data @payload.json --json
topolo actions plan app_topolo_mail.connections.oauth.start --resource-type workspace --resource-id <discovered-workspace-id> --data @payload.json --confirm --json
topolo actions call app_topolo_mail.connections.oauth.start --resource-type workspace --resource-id <discovered-workspace-id> --data @payload.json --confirm --json

For MCP, use topolo_get_action, topolo_validate_action and topolo_plan_action; execute with topolo_call_action with confirm:true only after approval. Pass resourceType workspace and the discovered resourceId separately from input. An absent service/action or non-executable plan blocks that operation.

Input fields

FieldRequiredMeaning
mailboxIdYesMailbox ID from mailboxes.collection.list in the selected workspace; it is distinct from the workspace resource ID.
providerYesgmail or graph for the existing external mailbox; readiness and consent are separate checks.
redirectToNoOptional post-consent destination passed through provider URL generation; use the current approved flow, not a guessed provider URL.

Effects

  • Requests a provider consent URL; does not establish a completed provider connection.

Interpret the response

data.authUrl and provider identify the authorization start. Hosted mailboxes are refused with HTTP 409. Nothing is connected until the human completes provider consent and the callback/exchange succeeds. The capture uses a synthetic URL-generation port.

Worked requests and responses

Successful fixture request · HTTP 200

Input

{
  "mailboxId": "mbx_mail_fixture",
  "provider": "gmail",
  "redirectTo": "/mailboxes"
}

SDK response or error

{
  "success": true,
  "data": {
    "authUrl": "https://provider.example.test/oauth?fixture=true",
    "provider": "gmail"
  }
}

Refused requests

Unauthenticated caller · HTTP 401

Input

{
  "mailboxId": "mbx_mail_fixture",
  "provider": "gmail",
  "redirectTo": "/mailboxes"
}

SDK response or error

{
  "code": "auth_error",
  "status": 401,
  "message": "Fixture authentication refused"
}

Service HTTP body

{
  "success": false,
  "error": {
    "message": "Fixture authentication refused"
  }
}

Permission denied · HTTP 403

Input

{
  "mailboxId": "mbx_mail_fixture",
  "provider": "gmail",
  "redirectTo": "/mailboxes"
}

SDK response or error

{
  "code": "permission_denied",
  "status": 403,
  "message": "TopoloMail permission denied"
}

Service HTTP body

{
  "success": false,
  "error": {
    "message": "TopoloMail permission denied"
  }
}

Other organization · HTTP 403

Input

{
  "mailboxId": "mbx_mail_fixture",
  "provider": "gmail",
  "redirectTo": "/mailboxes"
}

SDK response or error

{
  "code": "permission_denied",
  "status": 403,
  "message": "Mailbox does not belong to your organization"
}

Service HTTP body

{
  "success": false,
  "error": {
    "message": "Mailbox does not belong to your organization"
  }
}

Other verified workspace · HTTP 404

Input

{
  "mailboxId": "mbx_mail_fixture",
  "provider": "gmail",
  "redirectTo": "/mailboxes"
}

SDK response or error

{
  "code": "http_error",
  "status": 404,
  "message": "Mailbox not found"
}

Service HTTP body

{
  "success": false,
  "error": {
    "message": "Mailbox not found"
  }
}

Refused semantic request · HTTP 409

Input

{
  "mailboxId": "mbx_mail_fixture",
  "provider": "gmail"
}

SDK response or error

{
  "code": "http_error",
  "status": 409,
  "message": "Create an external mailbox before connecting a provider."
}

Service HTTP body

{
  "success": false,
  "error": {
    "message": "Create an external mailbox before connecting a provider."
  }
}

Verify the result

  • Show the returned real consent URL to the authorized human. After consent, read connections.get and verify the selected mailbox/provider is active.

Recover

An unused consent URL connects nothing. Preserve setup failures and inspect provider readiness; do not change credentials or complete consent without authorization.

  • HTTP 401 auth_error: Authenticate again in the intended environment and context, then repeat identity and action discovery.
  • HTTP 403 permission_denied: Stop for the exact permission, organization, sender or Reply-To refusal. Do not broaden access or switch credentials automatically.
  • HTTP 404 http_error: Rediscover the exact mailbox and child IDs in the same authorized workspace; do not guess another ID.
  • HTTP 409 http_error: Inspect this captured refusal: Create an external mailbox before connecting a provider.. Correct only the reviewed request or prerequisite, revalidate it, and plan again. Do not repeat an uncertain send, paid generation or deletion.

The captured SDK errors preserve the service code when structured, otherwise http_error and HTTP status. Do not invent a more specific code. Preserve the live request ID and inspect actual diagnostics for uncaptured failures.

Evidence and limits

  • Actual exported Mail handler dispatcher, widget handler, domain handlers, SDK transport/projection and shipped SQLite control/delivery/tracking migrations.

  • Identity, permissions, verified workspace grants, provider connection state, OAuth URL generation, mailbox Durable Object operations and content protection are synthetic ports.

  • Nexus AI and Auth archive are allowlisted in-process responses. No paid generation, billing, live OAuth, encryption custody, email delivery, asynchronous delivery or deployed outcome is proved. External network egress is refused.

The captured requests use synthetic identities and .test recipients. They demonstrate handler and SDK response behavior; they do not authorize delivery, provider consent, paid generation, deletion or other live effects. Current catalog discovery and environment proof remain separate release requirements.