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

# Start TOTP setup

> Returns otpauth URL + shared secret — render as a QR code, then confirm via verify.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/users/me/mfa/setup
openapi: 3.0.1
info:
  title: TKTChurch Identity (TKTAuth)
  version: v1
  description: >-
    Authorization server at prod-auth.tktchurch.com. Public OAuth2/OIDC
    endpoints need no auth; /api/v1 self routes need a Bearer access token
    issued to the user. the listed resource:action permission. Management lists
    return `{ metadata: { total, page, per }, items: [...] }`.
servers:
  - url: https://prod-auth.tktchurch.com
    description: Production
  - url: http://localhost:8080
    description: Local backchannel
  - url: https://calendar.tktchurch.net
    description: Calendar (Events)
security: []
tags:
  - name: authentication
    description: >-
      OAuth2 (RFC 6749), PAR (9126), revocation/introspection (7009/7662),
      device flow (8628), OIDC, registration (7591), sign-in flows, password
      reset and federated identity.
  - name: users
    description: >-
      Signed-in profile, identities, recovery, membership and Member Pass.
      Bearer only.
  - name: membership
    description: Membership matching, Member Pass, invite claims and family join codes.
  - name: sessions
    description: List, inspect and revoke your own sessions. Bearer only.
  - name: security
    description: TOTP setup and passkey management. Bearer only.
  - name: consents-privacy
    description: Your consent grants, privacy notices, data requests and exports.
  - name: family
    description: >-
      Families, dependents and guardian delegation. Bearer; delegation needs
      guardian:act_as.
  - name: system
    description: Liveness, readiness, build info and public maintenance status.
  - name: events
    description: >-
      Public church events listing, search and detail on calendar.tktchurch.net.
      No auth.
paths:
  /api/v1/users/me/mfa/setup:
    post:
      tags:
        - security
      summary: Start TOTP setup
      description: >-
        Returns otpauth URL + shared secret — render as a QR code, then confirm
        via verify.
      operationId: setupMfa
      responses:
        '200':
          description: Success
          content:
            application/json:
              example:
                otpauth_url: >-
                  otpauth://totp/TKTChurch:amina?secret=JBSWY3DPEHPK3PXP&issuer=TKTChurch
              schema:
                $ref: '#/components/schemas/MFASetupResult'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: invalid_request
                error_description: Redirect URI not registered for this client
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: invalid_token
                error_description: Access token is invalid or malformed
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Swift
          label: Swift (mfa setup)
          source: >-
            import Foundation


            // Step 1: returns otpauth:// URL + shared secret — render as QR
            code.

            var request = URLRequest(url: URL(string:
            "https://prod-auth.tktchurch.com/api/v1/users/me/mfa/setup")!)

            request.httpMethod = "POST"

            request.setValue("Bearer \(accessToken)", forHTTPHeaderField:
            "Authorization")

            let (data, _) = try await URLSession.shared.data(for: request)

            // Step 2: POST /mfa/verify with {"code": "<6-digit TOTP>"} to
            confirm.

            struct MFASetup: Decodable { let otpauthURL: String }

            let setup = try JSONDecoder().decode(MFASetup.self, from: data)

            print(setup.otpauthURL)
components:
  schemas:
    MFASetupResult:
      type: object
      properties:
        otpauth_url:
          type: string
          description: otpauth:// URL — render as QR code
    Error:
      type: object
      required:
        - error
        - error_description
      properties:
        error:
          type: string
          description: Machine-readable code
        error_description:
          type: string
          description: Human-readable detail
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````