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

# Begin Gmail OAuth

> Starts a Gmail OAuth flow (Pattern B, Dolfin-hosted redirect). Returns the Google authorization URL to send the browser to; Google redirects back to Dolfin's fixed callback, which finalises the connection and 302s to the supplied returnUrl with gmailStatus + connectionId.



## OpenAPI

````yaml post /gmail-connections
openapi: 3.1.1
info:
  title: Dolfin API
  description: >-
    Dolfin API for AR & AP. Authenticate using the `x-dolfin-api-key` header
    with the API key distributed to your organisation.
  version: v1
servers:
  - url: https://api.dolfinai.co
    description: Production
security:
  - {}
tags:
  - name: Webhooks
  - name: Users
  - name: TaxRates
  - name: Suppliers
  - name: Supplier Credit Notes
  - name: Bills
  - name: SpendCategories
  - name: Payables
  - name: RecurringInvoices
  - name: Receivables
  - name: Purchase Orders
  - name: Products
  - name: Payments
  - name: Invoices
  - name: Organisations
  - name: Members
  - name: MCP
  - name: Matching
  - name: Invoice Reminders
  - name: Industries
  - name: Gmail
  - name: Delivery Notes
  - name: Customers
  - name: Currencies
  - name: Credit Notes
  - name: Clients
  - name: ClientInvites
  - name: BankPayments
  - name: Bank details
  - name: Auth
  - name: ApprovalPolicies
  - name: ApiKeys
  - name: Agent
paths:
  /gmail-connections:
    post:
      tags:
        - Gmail
      summary: Begin Gmail OAuth
      description: >-
        Starts a Gmail OAuth flow (Pattern B, Dolfin-hosted redirect). Returns
        the Google authorization URL to send the browser to; Google redirects
        back to Dolfin's fixed callback, which finalises the connection and 302s
        to the supplied returnUrl with gmailStatus + connectionId.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiateGmailConnectionRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitiateGmailConnectionResponse'
        '400':
          description: >-
            Gmail.InvalidRedirectUri — returnUrl is not a valid absolute https
            URL


            Gmail.RedirectHostNotAllowed — returnUrl host is not on the client's
            allowlist
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: >-
            Client.GmailConnectorNotEnabled — the calling client does not have
            the Gmail connector enabled
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: >-
            Organisation.NotFound — the organisation does not exist or could not
            be resolved
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '500':
          description: >-
            Gmail.CallbackUrlNotConfigured — the environment has no Gmail OAuth
            callback URL configured
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
components:
  schemas:
    InitiateGmailConnectionRequest:
      required:
        - returnUrl
      type: object
      properties:
        returnUrl:
          type: string
    InitiateGmailConnectionResponse:
      required:
        - authUrl
        - state
        - connectionId
      type: object
      properties:
        authUrl:
          type: string
        state:
          type: string
        connectionId:
          type: string
          format: uuid
    ProblemDetails:
      type: object
      properties:
        type:
          type:
            - 'null'
            - string
        title:
          type:
            - 'null'
            - string
        status:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - 'null'
            - integer
            - string
          format: int32
        detail:
          type:
            - 'null'
            - string
        instance:
          type:
            - 'null'
            - string

````