> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tetherai.ca/llms.txt
> Use this file to discover all available pages before exploring further.

# Initiate email OAuth authorization flow

> Returns the provider-hosted authorization URL the user must visit to grant mailbox access. The server packs `{ userId, organizationId, provider }` into the OAuth `state` parameter so the callback can attribute the resulting tokens. Supports Gmail and Outlook.



## OpenAPI

````yaml /api-reference/openapi.yaml get /api/email/oauth/authorize
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/email/oauth/authorize:
    get:
      tags:
        - Email
      summary: Initiate email OAuth authorization flow
      description: >-
        Returns the provider-hosted authorization URL the user must visit to
        grant mailbox access. The server packs `{ userId, organizationId,
        provider }` into the OAuth `state` parameter so the callback can
        attribute the resulting tokens. Supports Gmail and Outlook.
      operationId: get_email_oauth_authorize
      parameters:
        - in: query
          name: provider
          required: false
          schema:
            type: string
            enum:
              - gmail
              - outlook
            default: gmail
          description: Email provider to authorize against. Defaults to `gmail`.
      responses:
        '200':
          description: Authorization URL returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailAuthorizeUrlResponse'
        '400':
          description: Unsupported email provider
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    EmailAuthorizeUrlResponse:
      type: object
      description: Response from `GET /api/email/oauth/authorize`.
      properties:
        authUrl:
          type: string
          format: uri
          description: >-
            Fully-qualified provider-hosted authorization URL. Frontends open
            this in a new window or top-level navigation; the provider will
            redirect to `/api/email/oauth/callback` once the user consents.
      required:
        - authUrl
      additionalProperties: true
      example:
        authUrl: >-
          https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=https%3A%2F%2Frelay.example%2Fapi%2Femail%2Foauth%2Fcallback&scope=...&state=...
    EmailErrorResponse:
      type: object
      description: >-
        Error envelope returned by Email feature endpoints. Most paths only set
        `error`; a few include `code` for diagnostic context (e.g. provider
        mismatches).
      properties:
        error:
          type: string
        message:
          type: string
        code:
          type: string
      required:
        - error
      additionalProperties: true
      example:
        error: Email account not found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````