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

# Create calendar sync authorization URL

> Create a short-lived OAuth authorization URL for Google or Microsoft calendar sync. The frontend should redirect the browser to `data.authorization_url`; after provider approval, the provider calls the public callback endpoint and the backend redirects back to the supplied safe `return_url`.



## OpenAPI

````yaml /api/consumer.openapi.yaml post /calendar-sync/{provider}/authorization-url
openapi: 3.1.0
info:
  title: YouNegotiate Consumer API
  version: '2.0'
  description: >-
    Stateless API endpoints for consumer portal authentication and account
    access.
servers:
  - url: https://api.consumer.younegotiate.com
    description: Production
security: []
tags:
  - name: System
    description: Public consumer domain system and health endpoints.
  - name: Authentication
    description: >-
      Consumer identity matching, contact capture, OTP verification, token
      creation, and logout endpoints.
  - name: Profile - My ecoAddress
    description: Consumer profile tab for signed-in identity / ecoAddress context.
  - name: Profile - Communication Controls
    description: >-
      Consumer profile tab for communication permissions, email/mobile changes,
      and email/mobile verification.
  - name: Profile - My Billing Details
    description: >-
      Consumer profile tab for billing name and billing address details used for
      payment verification.
  - name: Profile - Personalize My Portal
    description: Consumer profile tab for portal colors and profile image personalization.
  - name: Accounts
    description: Consumer-owned account list and account detail endpoints.
  - name: Bill Pay Wallet
    description: >-
      Consumer Bill Pay Wallet saved payment profiles and scheduled payment
      method update endpoints.
  - name: Upcoming Payments
    description: >-
      Consumer My Bill Pay Calendar upcoming-payment rows and calendar display
      data.
  - name: Calendar Sync
    description: >-
      Consumer Google and Microsoft calendar connection, OAuth callback, and
      live-update endpoints.
  - name: Gift Registry
    description: >-
      Consumer Bill Pay Gift Registry account list, shared registry, and Helping
      Hand link endpoints.
  - name: EcoMailbox
    description: Consumer MyEcoMailBox list endpoints and unread sidebar badge state.
  - name: Notice Responses
    description: >-
      Consumer My Account notice-response wizard endpoints for sender details
      and account details.
paths:
  /calendar-sync/{provider}/authorization-url:
    post:
      tags:
        - Calendar Sync
      summary: Create calendar sync authorization URL
      description: >-
        Create a short-lived OAuth authorization URL for Google or Microsoft
        calendar sync. The frontend should redirect the browser to
        `data.authorization_url`; after provider approval, the provider calls
        the public callback endpoint and the backend redirects back to the
        supplied safe `return_url`.
      operationId: consumerCreateCalendarSyncAuthorizationUrl
      parameters:
        - $ref: '#/components/parameters/CalendarSyncProvider'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCalendarSyncAuthorizationUrlRequest'
      responses:
        '200':
          description: Authorization URL returned.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/ConsumerCalendarSyncAuthorizationUrlResponse
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/ProfileIncomplete'
        '422':
          $ref: '#/components/responses/ValidationError'
      security:
        - bearerAuth: []
components:
  parameters:
    CalendarSyncProvider:
      name: provider
      in: path
      required: true
      description: Calendar provider slug.
      schema:
        type: string
        enum:
          - google
          - microsoft
  schemas:
    CreateCalendarSyncAuthorizationUrlRequest:
      type: object
      required:
        - mode
      properties:
        mode:
          type: string
          enum:
            - connect
            - reconnect
          example: connect
        return_url:
          type:
            - string
            - 'null'
          format: uri
          maxLength: 2048
          description: >-
            Optional consumer frontend URL to return to after provider approval.
            Unsafe origins are ignored and replaced with the configured Upcoming
            Payments URL.
          example: https://consumer.younegotiate.com/upcoming-payments
    ConsumerCalendarSyncAuthorizationUrlResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - provider
            - mode
            - authorization_url
            - expires_in
          properties:
            provider:
              type: string
              enum:
                - google
                - microsoft
              example: google
            mode:
              type: string
              enum:
                - connect
                - reconnect
              example: connect
            authorization_url:
              type: string
              format: uri
              description: Provider URL the frontend should redirect the browser to.
              example: https://accounts.google.com/o/oauth2/auth?client_id=...
            expires_in:
              type: integer
              description: Number of seconds before the cached OAuth state expires.
              example: 600
    MessageResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    ProfileIncompleteResponse:
      type: object
      required:
        - code
        - message
        - required_steps
      properties:
        code:
          type: string
          example: profile_incomplete
        message:
          type: string
          example: Please complete your communication profile before viewing accounts.
        required_steps:
          type: array
          items:
            type: string
          example:
            - profile_communication
    ValidationErrorResponse:
      type: object
      required:
        - message
        - errors
      properties:
        message:
          type: string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
  responses:
    Unauthenticated:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    ProfileIncomplete:
      description: >-
        The authenticated consumer profile must complete communication setup
        before My Account can be shown.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ProfileIncompleteResponse'
    ValidationError:
      description: Request validation failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Sanctum token

````