> ## Documentation Index
> Fetch the complete documentation index at: https://sure-917046f5-mintlify-docs-update-1787373087256.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Link an existing account via SSO

> Authenticates with email/password and links the SSO identity from a previously issued linking code. Creates an OidcIdentity, logs the link via SsoAuditLog, and issues mobile OAuth tokens.



## OpenAPI

````yaml /openapi.yaml post /api/v1/auth/sso_link
openapi: 3.0.3
info:
  title: Sure API
  version: v1
  description: OpenAPI documentation generated from executable request specs.
servers:
  - url: https://app.sure.am
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
paths:
  /api/v1/auth/sso_link:
    post:
      tags:
        - Auth
      summary: Link an existing account via SSO
      description: >-
        Authenticates with email/password and links the SSO identity from a
        previously issued linking code. Creates an OidcIdentity, logs the link
        via SsoAuditLog, and issues mobile OAuth tokens.
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                linking_code:
                  type: string
                  description: One-time linking code from mobile SSO onboarding redirect
                email:
                  type: string
                  format: email
                  description: Email of the existing account to link
                password:
                  type: string
                  description: Password for the existing account
              required:
                - linking_code
                - email
                - password
        required: true
      responses:
        '200':
          description: account linked and tokens issued
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                  refresh_token:
                    type: string
                  token_type:
                    type: string
                  expires_in:
                    type: integer
                  created_at:
                    type: integer
                  user:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      email:
                        type: string
                      first_name:
                        type: string
                      last_name:
                        type: string
                      ui_layout:
                        type: string
                        enum:
                          - dashboard
                          - intro
                      ai_enabled:
                        type: boolean
        '400':
          description: missing linking code
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: invalid credentials or expired linking code
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ErrorResponse'
                  - $ref: '#/components/schemas/MfaRequiredResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
          nullable: true
        details:
          oneOf:
            - type: array
              items:
                type: string
            - type: object
          nullable: true
        errors:
          type: array
          items:
            type: string
          nullable: true
          description: >-
            Validation error messages (alternative to details used by trades,
            valuations, etc.)
    MfaRequiredResponse:
      type: object
      required:
        - error
        - mfa_required
      properties:
        error:
          type: string
        mfa_required:
          type: boolean

````