openapi: 3.0.3

info:
  title: Soniqo Cloud API
  description: |
    HTTP API for the Soniqo Cloud speech platform — the same models that
    run on-device in our open-source SDKs, served as a managed cloud
    service.

    ## Capabilities

    - **Transcription (Soniqo Steno)** — async batch (`/v1/transcribe`)
      and synchronous OpenAI-compat (`/v1/audio/transcriptions`). 26 supported
      base languages plus accepted region/dialect tags, with speaker
      diarization and recording-local speaker consistency.
    - **Speech synthesis (Soniqo Vox)** — `/v1/synthesize`, using built-in
      preset voices. The former OpenAI-compatible `/v1/audio/speech` route is
      fail-closed at the production edge until it shares the native route's
      authentication, bounded-input, and credit-settlement authority.
    - **Retired speaker registry cleanup** — cross-meeting voiceprint matching
      is retired. Authenticated `GET` / `DELETE /v1/speakers` remain for one
      cleanup window so existing profiles can be inspected and erased; new
      enrollment returns `410 Gone`.
    - **Realtime streaming (planned)** — `/v1/realtime` is fail-closed at the
      production edge while the authenticated session/capacity path described
      in the architecture is completed.

    ## Authentication

    All `/v1/*` endpoints require either:

    - **API key** — `X-Api-Key: sk_...` header. Long-lived, scoped to one
      account, revocable from the account UI. Best for server-to-server.
    - **Bearer JWT** — `Authorization: Bearer <jwt>` issued by the
      account UI's OIDC login flow. Short-lived (5 min), refreshed
      automatically by the UI. Best for browsers / interactive use.

    The edge proxy validates the credential and forwards a resolved
    user identity to the upstream service. All writes (jobs and usage events)
    are strictly user-scoped — no
    cross-account reads.

    Stenograf desktop licensing endpoints require an interactive OIDC Bearer
    token; API keys cannot prepare trials, activate devices, or manage a
    subscription.

    ## Request body limits

    Body-bearing `/v1/*` methods require an explicit, bounded
    `Content-Length`. Transfer-encoded, close-delimited, and compressed
    (`Content-Encoding`) request bodies are rejected before they are read.
    The public Cloudflare-proxied service supports complete request bodies up
    to 100 MB. The origin keeps a larger defensive ceiling, but that internal
    bound is not part of the public upload contract. Endpoint-specific smaller
    limits are documented below.

    ## Audio format

    Transcribe endpoints accept **raw 32-bit IEEE float PCM,
    little-endian, mono, 16 kHz** in the `audio` / `file` field. The
    server detects common container magic bytes and rejects them with
    `400 unsupported audio format` for WAV / MP3 / M4A / OGG / FLAC /
    WebM — re-encode with `ffmpeg -ar 16000 -ac 1 -f f32le ...` first.

    Synthesis endpoints **return** WAVs (mono PCM int16) in the response
    body with `Content-Type: audio/wav`. The sample rate is model-native
    unless an endpoint documents a compatibility resample.

    ## Compatibility

    - `POST /v1/audio/transcriptions` is shape-compatible with OpenAI's
      [Whisper API](https://platform.openai.com/docs/api-reference/audio/createTranscription)
      (`response_format` of `json`, `text`, `verbose_json`, `srt`, `vtt`).
      Soniqo extensions (speaker diarization metadata) ride along under
      `x_soniqo` / `x_speaker_id` fields, which OpenAI-shape clients
      ignore.
    - `POST /v1/audio/speech` and `/v1/realtime` currently return `503` at
      the production edge. They remain documented below as reserved,
      unavailable compatibility surfaces so clients do not mistake them for
      deployed capabilities.

    ## Pricing

    Free tier: $10 of credit at signup, topped back up to $10 at the
    start of each month; unused free credit does not accumulate.
    Transcription at $0.24 per audio-hour, billed per second with no
    minimum charge.
    Synthesis at $0.22
    per minute of generated audio, billed per second with no minimum.
    Paid tiers and volume discounts are coming soon.

  version: 0.3.0
  contact:
    name: Soniqo
    url: https://cloud.soniqo.audio
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html

servers:
  - url: https://api.soniqo.audio
    description: Production

tags:
  - name: transcription
    description: Audio → transcript jobs.
  - name: audio
    description: OpenAI Whisper-compatible synchronous transcription.
  - name: speakers
    description: Retired user-scoped speaker-profile cleanup surface.
  - name: synthesis
    description: Soniqo Vox preset-voice text-to-speech.
  - name: realtime
    description: Reserved WebSocket streaming surface; unavailable in production.
  - name: api-keys
    description: Long-lived credentials for server-to-server use.
  - name: billing
    description: Balance, ledger, and usage queries.
  - name: stenograf
    description: Subscription, no-card trial, and device-lease authority for the Stenograf desktop app.
  - name: support
    description: Customer support tickets.
  - name: account
    description: Account self-service.
  - name: meta
    description: Health and discovery.

components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: Long-lived API key, prefix `sk_`.
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        `Authorization: Bearer <credential>`. The credential is either
        a long-lived API key (prefix `sk_`) or an OIDC-issued access
        token from the account UI flow. Accepting an API key as a Bearer
        token lets OpenAI-compatible SDK clients — which only emit
        `Authorization: Bearer` — authenticate without setting the
        `X-Api-Key` header. The two schemes are interchangeable.

  parameters:
    StenografClientPlatform:
      in: header
      name: X-Stenograf-Platform
      required: true
      schema: { type: string, enum: [windows, macos] }
    StenografClientAppVersion:
      in: header
      name: X-Stenograf-App-Version
      required: true
      description: Exact distribution identity, including its 12-hex source revision.
      schema:
        type: string
        maxLength: 32
        pattern: "^[A-Za-z0-9.-]+\\+[a-f0-9]{12}$"
    StenografClientSecurityVersion:
      in: header
      name: X-Stenograf-Client-Security-Version
      required: true
      description: Exact capability registered for this platform/build pair; it is not a client-selected minimum.
      schema: { type: integer, minimum: 1, maximum: 1000 }

  schemas:
    Error:
      type: object
      required: [error]
      properties:
        error:
          oneOf:
            - type: string
            - type: object
              properties:
                message: { type: string }
                type:    { type: string }

    Word:
      type: object
      properties:
        text:       { type: string }
        start:
          type: number
          format: float
          description: |
            Seconds from start of audio. The current implementation
            distributes per-word timing proportionally across the
            containing speech region — accurate at the region
            boundaries, approximate within. Frame-level per-word
            timing from the decoder is on the roadmap; the field
            shape will stay stable when precision lands.
        end:        { type: number, format: float }
        confidence: { type: number, format: float }
        speaker:    { type: string, description: Soniqo speaker id within this job. }

    Utterance:
      type: object
      properties:
        text:         { type: string }
        start:        { type: number, format: float }
        end:          { type: number, format: float }
        speaker:      { type: string }
        speaker_name: { type: string, description: Optional name derived from meeting-source participant evidence; absent for anonymous uploads. }
        words:
          type: array
          items: { $ref: "#/components/schemas/Word" }

    Speaker:
      type: object
      properties:
        speaker:        { type: string }
        name:           { type: string }
        total_duration: { type: number, format: float }
        word_count:     { type: integer }
        percentage:     { type: number, format: float }

    MeetingParticipant:
      type: object
      properties:
        participant_id:
          type: string
          description: Opaque meeting-scoped roster identifier when available; never a raw provider account ID.
        name:       { type: string }
        email:      { type: string }
        role:       { type: string }
        first_seen: { type: number, format: float, description: Seconds from the origin named by `timeline`. }
        last_seen:  { type: number, format: float, description: Seconds from the origin named by `timeline`. }
        speaker:    { type: integer, description: Matched diarization speaker index when known. }
        source:
          type: string
          enum: [google_meet_roster, diarization]
          description: Provenance of this participant row.
        timeline:
          type: string
          enum: [scheduled_event, recorder_audio]
          description: Time origin for first_seen and last_seen. Meet REST attendance uses the scheduled event start; speaker-correlation evidence must use recorder_audio separately.
        roster_source:
          type: string
          enum: [google_meet_rest]
          description: Canonical roster authority when source is google_meet_roster.

    ActionItem:
      type: object
      properties:
        text:           { type: string }
        owner:          { type: string }
        due_date:       { type: string }
        source_speaker: { type: integer }
        source_start:   { type: number, format: float }
        source_end:     { type: number, format: float }

    MeetingResult:
      type: object
      properties:
        job_id:              { type: string, example: "job_abc123" }
        status:              { type: string, enum: [completed, failed] }
        duration_audio:      { type: number, format: float, description: Audio length in seconds. }
        duration_processing: { type: number, format: float, description: Processing wall-clock seconds. }
        language:            { type: string, description: Detected ISO-639-1 language code. }
        num_speakers:        { type: integer }
        text:                { type: string, description: Full concatenated transcript. }
        speakers:
          type: array
          items: { $ref: "#/components/schemas/Speaker" }
        utterances:
          type: array
          items: { $ref: "#/components/schemas/Utterance" }
        notes:
          type: string
          description: Generated meeting notes when requested by a meeting agent.
        participants:
          type: array
          items: { $ref: "#/components/schemas/MeetingParticipant" }
        action_items:
          type: array
          items: { $ref: "#/components/schemas/ActionItem" }

    JobStatus:
      type: object
      properties:
        job_id: { type: string }
        status: { type: string, enum: [queued, processing, completed, failed] }
        error:  { type: string }

    JobConfig:
      type: object
      additionalProperties: false
      required: [language]
      properties:
        language:
          type: string
          description: |
            BCP-47 language, e.g. `en`, `es-419`, `pt-BR`. **Required.**
            An Arabic tag selects Steno; a supported European tag selects
            Parakeet when `model` is unset.
            The supported base tags are `ar`, `bg`, `hr`, `cs`, `da`, `nl`,
            `en`, `et`, `fi`, `fr`, `de`, `el`, `hu`, `it`, `lv`, `lt`,
            `mt`, `pl`, `pt`, `ro`, `sk`, `sl`, `es`, `sv`, `ru`, and `uk`.
            A missing, empty, or unsupported tag is rejected with `400`
            before the job is enqueued.

            Acoustic language detection was withdrawn: measured on held-out
            audio it sent about four in ten Arabic-English code-switch clips
            to the European backend, which is not trained for them. Naming
            the language is now the only way to select a backend.
        model:
          type: string
          example: soniqo-steno
          description: |
            Optional public transcription model ID. `soniqo-steno` is the
            umbrella ID; the service selects its exact ASR backend from the
            required `language`. See `GET /v1/models/transcribe` for the
            capability matrix. Omit to let the language choose.
        diarize:
          type: boolean
          default: true
          description: |
            Produce anonymous speaker slots that remain consistent within this
            meeting. Cross-meeting stored-profile matching is not supported.
            Job provenance (`input_source`) is server-owned and is not
            accepted here.
        max_speakers: { type: integer, minimum: 0, maximum: 32 }
        min_speakers: { type: integer, minimum: 0, maximum: 32 }
        create_notes:
          type: boolean
          default: false
        create_action_items:
          type: boolean
          default: false
        identify_participants:
          type: boolean
          default: false

    TranscriptionModel:
      type: object
      required: [id, name, type, modes, features]
      properties:
        id:
          type: string
          description: |
            Public model ID. Pass this on `POST /v1/transcribe`'s
            `model` field. Stable across model refreshes — when we
            upgrade the underlying weights the ID stays, the
            capability fields may change.
        name:
          type: string
          example: "Soniqo Steno"
        type:
          type: string
          enum: [transcription]
        modes:
          type: array
          items:
            type: string
            enum: [batch, realtime]
          description: |
            Which API surfaces this model is wired into. `batch`
            means `POST /v1/transcribe` and `POST /v1/audio/transcriptions`.
            `realtime` means `GET /v1/realtime` (WebSocket).
        languages:
          type: array
          items:
            type: string
            description: BCP-47 language tag.
          description: |
            Full base-language list when the model serves a finite set.
        languages_count:
          type: integer
          description: |
            Total base-language count. It may accompany either an exact
            `languages` list or a sampled wide-coverage description.
        languages_sample:
          type: array
          items: { type: string }
          description: |
            Curated subset of BCP-47 tags from the model's full
            language set, chosen for common usage. Not exhaustive.
        languages_reference:
          type: string
          format: uri
          description: Link to upstream documentation listing the full language set.
        features:
          type: array
          items:
            type: string
            enum:
              - diarization
              - word_timestamps
              - confidence
              - speaker_consistency
              - code_switch
              - language_routing
        description:
          type: string

    TranscriptionModelList:
      type: object
      required: [object, data]
      properties:
        object:
          type: string
          enum: [list]
        data:
          type: array
          items: { $ref: "#/components/schemas/TranscriptionModel" }

    SynthesisModelList:
      type: object
      required: [object, data]
      properties:
        object:
          type: string
          enum: [list]
        data:
          type: array
          items: { $ref: "#/components/schemas/SynthesisModel" }

    SynthesisModel:
      type: object
      required: [id, modes, features]
      properties:
        id:
          type: string
          description: |
            Public model ID. Pass on the `model` field of
            `POST /v1/synthesize`; see `GET /v1/models/synthesize` for the
            valid IDs.
        name:
          type: string
          example: "Soniqo Vox"
        type:
          type: string
          enum: [synthesis]
        modes:
          type: array
          items: { type: string, enum: [batch, realtime] }
        sample_rate:
          type: integer
          description: Output audio sample rate in Hz.
          example: 24000
        realtime:
          type: boolean
          description: Whether the model synthesizes faster than real time.
        features:
          type: array
          items:
            type: string
            enum: [preset_voices]
        languages:
          type: array
          description: |
            Language codes the model can speak. Present on preset-voice
            models.
          items: { type: string }
        voices:
          type: array
          description: |
            Standard (preset) voices available without registration.
            Each entry's `voice_id` is valid in the `voice` / `voice_id`
            field on `POST /v1/synthesize`.
          items:
            type: object
            properties:
              voice_id: { type: string, example: "af_heart" }
              name:     { type: string, example: "Heart" }
        description:
          type: string

    WhisperJsonResponse:
      type: object
      required: [text]
      properties:
        text: { type: string, description: Concatenated transcript. }

    WhisperVerboseJsonResponse:
      type: object
      properties:
        task:     { type: string, example: transcribe }
        language: { type: string, example: en }
        duration: { type: number, format: float }
        text:     { type: string }
        segments:
          type: array
          items:
            type: object
            properties:
              id:             { type: integer }
              start:          { type: number, format: float }
              end:            { type: number, format: float }
              text:           { type: string }
              x_speaker_id:   { type: string, description: Soniqo extension. }
              x_speaker_name: { type: string, description: Soniqo extension. }
        words:
          type: array
          items:
            type: object
            properties:
              word:         { type: string }
              start:        { type: number, format: float }
              end:          { type: number, format: float }
              x_speaker_id: { type: string, description: Soniqo extension. }
        x_soniqo:
          type: object
          description: Soniqo extension; OpenAI-shape clients ignore it.
          properties:
            audio_seconds_processed: { type: number, format: float }
            num_speakers:            { type: integer }

    Balance:
      type: object
      properties:
        balance_cents: { type: integer }
        currency:      { type: string, example: usd }

    BillingEvent:
      type: object
      properties:
        event_id:              { type: string }
        period:                { type: string, example: "2026-04" }
        type:                  { type: string, enum: [credit_debit, correction, subscription, topup, refund] }
        amount_cents:          { type: integer, description: Positive = credit, negative = debit. }
        currency:              { type: string }
        billing_class_at_time: { type: string }
        external_ref:          { type: string }
        created_at:            { type: string, format: date-time }

    UsageEvent:
      type: object
      properties:
        event_id:                { type: string }
        period:                  { type: string }
        kind:                    { type: string }
        quantity:                { type: number }
        unit_cost_cents:         { type: number, description: Cents per unit; fractional for per-second rates. }
        billable_cents:          { type: integer }
        provider:                { type: string }
        region:                  { type: string }
        hardware:                { type: string }
        created_at:              { type: string, format: date-time }

    SpeakerProfile:
      type: object
      description: |
        Legacy stored speaker profile retained only for the authenticated
        cleanup window. Profiles are no longer used for transcription.
      properties:
        speaker_id:     { type: string, example: "spk_a1b2c3d4-..." }
        name:           { type: string }
        embedding_dim:  { type: integer, example: 256 }
        sample_rate_hz: { type: integer, example: 16000 }
        created_at_ms:  { type: integer, format: int64 }

    SynthesisRequest:
      type: object
      required: [text]
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 300
          description: |
            The text to synthesize, as UTF-8. At most 300 Unicode characters;
            split longer narration into separate bounded requests.
        voice:
          type: string
          example: "af_heart"
          description: |
            Built-in preset voice ID (for example `af_heart` or
            `am_adam`). List supported IDs via
            `GET /v1/models/synthesize`. Alias of `voice_id`; if both
            are sent, `voice_id` wins. Defaults to `af_heart`.
        voice_id:
          type: string
          example: "af_heart"
          description: |
            Same as `voice` (retained for backward compatibility).
            Must be one of the built-in preset IDs.
        model:
          type: string
          description: |
            Optional preset synthesis model ID. Supported values are listed
            by `GET /v1/models/synthesize`.
        language:
          type: string
          example: "pt-BR"
          description: |
            Optional BCP-47 language attribution hint. Analytics retain only
            the normalized primary subtag (`pt-BR` becomes `pt`) and mark it
            as caller-submitted. When omitted, the worker may infer a language
            from the request text in memory; the text itself is not retained
            for analytics. This field does not override synthesis model
            routing.
        seed:
          type: integer
          format: int64
          minimum: 0
          maximum: 4294967295
          default: 0
          description: |
            Optional unsigned 32-bit synthesis seed. A nonzero value is used
            exactly. Zero or omission asks the server/worker to select the
            effective seed, reported in `X-Seed-Used`. Idempotent retries keep
            the caller's zero sentinel as operation identity and replay the
            first result even if a deployment default changes.

    ApiKey:
      type: object
      properties:
        id:         { type: string, example: ak_abc123 }
        label:      { type: string }
        created_at: { type: string, format: date-time }
        last_used:  { type: string, format: date-time, nullable: true }
        revoked_at: { type: string, format: date-time, nullable: true }

    StenografRecommendedRelease:
      type: object
      required: [schema, release]
      properties:
        schema: { type: integer, enum: [1] }
        release:
          type: object
          nullable: true
          required: [version, notes]
          properties:
            version:
              type: string
              maxLength: 40
              pattern: "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
            publishedAt:
              type: string
              nullable: true
              pattern: "^\\d{4}-\\d{2}-\\d{2}$"
            notes:
              type: array
              minItems: 1
              maxItems: 24
              items: { type: string, minLength: 1, maxLength: 280 }
            localizedNotes:
              type: object
              description: >-
                The same notes in other languages, keyed by the desktop's
                language tag such as zh-CN. English stays in notes and is the
                fallback; a language is optional and never partial.
              additionalProperties:
                type: array
                minItems: 1
                maxItems: 24
                items: { type: string, minLength: 1, maxLength: 280 }

    StenografLicenseState:
      type: object
      required: [accountId, state, activeDevices, reservedDeviceSlots, cardRequiredForTrial, trialCardState, hasBillingCustomer, nextStep, can]
      properties:
        accountId: { type: string, pattern: "^us_[A-Za-z0-9_-]+$" }
        state:
          type: string
          enum: [none, offer, trial, subscription, expired]
        activeDevices: { type: integer, minimum: 0 }
        reservedDeviceSlots:
          type: integer
          minimum: 0
          description: Active devices plus deactivated devices whose signed offline lease has not expired.
        cardRequiredForTrial:
          type: boolean
          description: >-
            Backward-compatible indication that this account still needs to
            present a payment method. False once one is recorded, and false on
            a deployment that does not ask for one; it is not the setting.
        trialCardState:
          type: string
          enum: [not_required, missing, eligible]
          description: >-
            Result of the free-trial payment-method gate. Missing is a step the
            client can complete; any recorded payment method makes the account
            eligible, including one already recorded on another account.
        hasBillingCustomer:
          type: boolean
          description: Whether a billing profile exists, so the console can offer hosted subscription management even after access ends.
        summary:
          type: object
          required: [code]
          description: >-
            What the account is, as a code and typed parameters rather than a
            sentence, so the client says it in its own language and formats
            dates for the reader. A code cannot be assembled from stale parts:
            there is none meaning "trial active" for an account with no trial.
          properties:
            code:
              type: string
              enum: [offer_card_required, offer_ready, trial_active,
                     trial_with_scheduled_subscription,
                     trial_with_canceling_subscription, subscription_active,
                     subscription_canceling, subscription_past_due, expired,
                     none]
            params: { type: object }
        billing:
          type: object
          nullable: true
          required: [code]
          description: >-
            What will be charged, from the session or subscription that will
            charge it. Null when nothing is pending. An open hosted Checkout
            reports its own recorded terms, so a client cannot promise
            otherwise while that page is open -- which is exactly what happened
            when the client inferred this from account state.
          properties:
            code:
              type: string
              enum: [checkout_open, continuation_scheduled,
                     continuation_canceling, trial_no_payment_scheduled]
            params: { type: object }
        nextStep:
          type: string
          enum: [complete_checkout, add_card, start_trial, choose_plan, none]
          description: >-
            What this account needs next, decided beside the gates that enforce
            it rather than reconstructed by each client. An unfinished hosted
            Checkout outranks the rest: it is already open in a browser, and
            every other action would start something beside it.
        can:
          type: object
          required: [startTrial, subscribe, manageBilling, listen]
          description: >-
            What this account may do now. Clients render these rather than
            deriving them from state; a derivation that disagrees with the gate
            is how a status came to ask for a card that was already recorded.
          properties:
            startTrial:
              type: boolean
              description: An actionable offer exists. False when the recorded card was already used for another trial.
            subscribe: { type: boolean }
            manageBilling:
              type: boolean
              description: A billing profile exists. True for a card saved to start a trial, with no subscription.
            listen: { type: boolean }
        openCheckout:
          type: object
          required: [interval]
          description: >-
            A hosted Checkout this account has open and unfinished. The
            reservation lives for a day; reporting it means a client need not
            remember it across a refresh.
          properties:
            interval: { type: string, enum: [month, year] }
            expiresAt: { type: integer, format: int64 }
        subscriptionStatus:
          type: string
          description: >-
            Billing projection. `trialing` means billing is scheduled after
            the current free trial; `trialing_canceling` means it will not
            begin unless the customer resumes the subscription.
        endsAt: { type: integer, format: int64, description: Unix timestamp. }
        reservationId: { type: string }
        trialPolicyId: { type: string }
        trialPolicyRevision: { type: integer, format: int64 }
        trialDays: { type: integer, minimum: 1 }

    StenografLease:
      type: object
      required: [lease, claims]
      properties:
        lease:
          type: string
          description: Compact Ed25519-signed device-bound capability lease.
        claims:
          $ref: "#/components/schemas/StenografLeaseClaims"

    StenografTelemetryCommonProperties:
      type: object
      additionalProperties: false
      required: [platform, appVersion]
      properties:
        platform: { type: string, enum: [macos, windows, linux] }
        appVersion:
          type: string
          maxLength: 32
          pattern: "^[A-Za-z0-9.+-]+$"

    StenografTelemetryPipelineProperties:
      type: object
      additionalProperties: false
      required: [platform, appVersion, pipeline, modelBundle]
      properties:
        platform: { type: string, enum: [macos, windows, linux] }
        appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
        pipeline: { type: string, enum: [full, lightweight] }
        modelBundle:
          type: string
          enum:
            - full_pipeline_v1
            - nemotron06b_sortformer_redimnetb6_v1
          description: Earlier Full bundle identifiers remain accepted and are normalized to full_pipeline_v1.
        executionProvider: { type: string, enum: [cpu, cuda, hybrid] }
        requestedPipeline: { type: string, enum: [automatic, full, lightweight] }
        pipelineFallback:
          type: string
          enum: [gpu_unavailable, gpu_initialization_failed]
          description: Present only for a validated Lightweight fallback tuple.

    StenografTelemetryAppEvent:
      type: object
      additionalProperties: false
      required: [kind, properties]
      properties:
        kind: { type: string, enum: [app_opened] }
        properties:
          type: object
          additionalProperties: false
          required: [platform, appVersion]
          properties:
            platform: { type: string, enum: [macos, windows, linux] }
            appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
            osVersion: { type: string, maxLength: 64 }
            deviceModel: { type: string, maxLength: 64 }
            cpu: { type: string, maxLength: 64 }
            gpu: { type: string, maxLength: 64 }
            cpuCores: { type: integer, minimum: 0, maximum: 512 }
            memoryGb: { type: integer, minimum: 0, maximum: 4096 }
            locale: { type: string, maxLength: 64 }
            timeZone: { type: string, maxLength: 48, pattern: "^[A-Za-z0-9_+/-]+$" }

    StenografTelemetryPlanStepProperties:
      type: object
      additionalProperties: false
      required: [platform, appVersion, step]
      properties:
        platform: { type: string, enum: [macos, windows, linux] }
        appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
        step:
          type: string
          enum: [registered, trial_started, subscription_started, subscription_resumed]

    StenografTelemetryPlanStepEvent:
      type: object
      additionalProperties: false
      required: [kind, properties]
      properties:
        kind: { type: string, enum: [plan_step] }
        properties: { $ref: "#/components/schemas/StenografTelemetryPlanStepProperties" }

    StenografTelemetryPipelineEvent:
      type: object
      additionalProperties: false
      required: [kind, properties]
      properties:
        kind: { type: string, enum: [models_ready] }
        properties: { $ref: "#/components/schemas/StenografTelemetryPipelineProperties" }

    StenografTelemetryListenStartEvent:
      type: object
      additionalProperties: false
      required: [kind, properties]
      properties:
        kind: { type: string, enum: [listen_started] }
        properties:
          type: object
          additionalProperties: false
          required: [platform, appVersion, pipeline, modelBundle, calendarIntegration]
          properties:
            platform: { type: string, enum: [macos, windows, linux] }
            appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
            pipeline: { type: string, enum: [full, lightweight] }
            modelBundle:
              type: string
              enum: [full_pipeline_v1, nemotron06b_sortformer_redimnetb6_v1]
            calendarIntegration: { type: string, enum: [connected, not_connected] }
            executionProvider: { type: string, enum: [cpu, cuda, hybrid] }
            requestedPipeline: { type: string, enum: [automatic, full, lightweight] }
            pipelineFallback:
              type: string
              enum: [gpu_unavailable, gpu_initialization_failed]

    StenografTelemetryStopEvent:
      type: object
      additionalProperties: false
      required: [kind, properties]
      properties:
        kind: { type: string, enum: [listen_stopped] }
        properties:
          type: object
          additionalProperties: false
          required: [platform, appVersion, pipeline, modelBundle, calendarIntegration, durationBucket, outcome]
          properties:
            platform: { type: string, enum: [macos, windows, linux] }
            appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
            pipeline: { type: string, enum: [full, lightweight] }
            modelBundle:
              type: string
              enum: [full_pipeline_v1, nemotron06b_sortformer_redimnetb6_v1]
            calendarIntegration: { type: string, enum: [connected, not_connected] }
            durationBucket:
              type: string
              enum: [under_5m, 5_to_15m, 15_to_30m, 30_to_60m, 1_to_2h, over_2h]
            outcome: { type: string, enum: [completed, failed] }
            language: { type: string, pattern: "^[a-z]{3}$" }
            asrLatencyBucket:
              type: string
              enum: [under_500ms, 500ms_to_1s, 1_to_2s, 2_to_5s, 5_to_10s, over_10s]
            asrLatencyWorstBucket:
              type: string
              enum: [under_500ms, 500ms_to_1s, 1_to_2s, 2_to_5s, 5_to_10s, over_10s]
            finalQueueWorstBucket:
              type: string
              enum: [under_500ms, 500ms_to_1s, 1_to_2s, 2_to_5s, 5_to_10s, over_10s]
            previewFirstTokenLatencyWorstBucket:
              type: string
              enum: [under_500ms, 500ms_to_1s, 1_to_2s, 2_to_5s, 5_to_10s, over_10s]
            finalThroughputFloorBucket:
              type: string
              enum: [under_0_5x, 0_5_to_1x, 1_to_2x, 2_to_5x, over_5x]
            memoryPeakBucket:
              type: string
              enum: [under_1gb, 1_to_2gb, 2_to_4gb, 4_to_8gb, over_8gb]
            executionProvider: { type: string, enum: [cpu, cuda, hybrid] }
            requestedPipeline: { type: string, enum: [automatic, full, lightweight] }
            pipelineFallback:
              type: string
              enum: [gpu_unavailable, gpu_initialization_failed]

    StenografTelemetryAskStartEvent:
      type: object
      additionalProperties: false
      required: [kind, properties]
      properties:
        kind: { type: string, enum: [ask_started] }
        properties:
          type: object
          additionalProperties: false
          required: [platform, appVersion, askModel, retrieval]
          properties:
            platform: { type: string, enum: [macos, windows, linux] }
            appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
            askModel:
              type: string
              enum: [rig_ollama_gemma4_e4b_it_q4_k_m, rig_ollama_custom]
            retrieval: { type: string, enum: [iresearch_embeddinggemma_v1] }

    StenografTelemetryAskFinishEvent:
      type: object
      additionalProperties: false
      required: [kind, properties]
      properties:
        kind: { type: string, enum: [ask_finished] }
        properties:
          type: object
          additionalProperties: false
          required: [platform, appVersion, askModel, retrieval, durationBucket, outcome]
          properties:
            platform: { type: string, enum: [macos, windows, linux] }
            appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
            askModel:
              type: string
              enum: [rig_ollama_gemma4_e4b_it_q4_k_m, rig_ollama_custom]
            retrieval: { type: string, enum: [iresearch_embeddinggemma_v1] }
            durationBucket:
              type: string
              enum: [under_10s, 10_to_30s, 30_to_60s, 1_to_3m, 3_to_10m, over_10m]
            outcome: { type: string, enum: [answered, clarifying, exhausted, cancelled, failed] }

    StenografAskFeedback:
      type: object
      additionalProperties: false
      required:
        - rating
        - reason
        - platform
        - appVersion
        - askModel
        - traceSchemaVersion
        - runState
        - terminalAction
        - answerAudit
        - evidenceSufficiency
        - scopeKind
        - durationBucket
        - modelPasses
        - controllerSteps
        - retrievalSteps
        - branchCount
        - supportedBranches
        - partialBranches
        - missingBranches
        - conflictingBranches
        - evidenceCount
        - citationCount
        - sentenceCount
        - unsupportedSentenceCount
        - retrievalRoutes
        - clarificationOffered
        - followup
      properties:
        rating: { type: string, enum: [helpful, not_helpful] }
        reason:
          type: string
          enum: [helpful, incorrect, missed_information, wrong_citation, not_useful, too_slow, other]
        platform: { type: string, enum: [macos, windows, linux] }
        appVersion: { type: string, maxLength: 32, pattern: "^[A-Za-z0-9.+-]+$" }
        askModel:
          type: string
          minLength: 12
          maxLength: 211
          pattern: "^rig_ollama:(?!\\.{1,2}(?:/|$))[A-Za-z0-9._:+-]+(?:/(?!\\.{1,2}(?:/|$))[A-Za-z0-9._:+-]+)*$"
          description: Exact user-selected Ollama model identifier approved in the feedback confirmation.
        traceSchemaVersion: { type: integer, enum: [1] }
        runState:
          type: string
          enum: [answered, clarifying, exhausted, cancelled, failed]
        terminalAction:
          type: string
          enum: [answer, clarify, abstain, none]
        answerAudit:
          type: string
          enum: [answered, refused, evaded, unknown]
        evidenceSufficiency:
          type: string
          enum: [pending, undetermined, insufficient, partial, sufficient, conflicting]
        scopeKind:
          type: string
          enum: [all, sessions, about, selected]
        durationBucket:
          type: string
          enum: [under_10s, 10_to_30s, 30_to_60s, 1_to_3m, 3_to_10m, over_10m, unknown]
        modelPasses: { type: integer, minimum: 0, maximum: 128 }
        controllerSteps: { type: integer, minimum: 0, maximum: 64 }
        retrievalSteps: { type: integer, minimum: 0, maximum: 64 }
        branchCount: { type: integer, minimum: 0, maximum: 64 }
        supportedBranches: { type: integer, minimum: 0, maximum: 64 }
        partialBranches: { type: integer, minimum: 0, maximum: 64 }
        missingBranches: { type: integer, minimum: 0, maximum: 64 }
        conflictingBranches: { type: integer, minimum: 0, maximum: 64 }
        evidenceCount: { type: integer, minimum: 0, maximum: 64 }
        citationCount: { type: integer, minimum: 0, maximum: 64 }
        sentenceCount: { type: integer, minimum: 0, maximum: 64 }
        unsupportedSentenceCount: { type: integer, minimum: 0, maximum: 64 }
        retrievalRoutes:
          type: array
          maxItems: 5
          uniqueItems: true
          description: Lexicographically sorted set of bounded retrieval-route categories.
          items:
            type: string
            enum: [lexical, variant, bridged, recording, similar]
        clarificationOffered: { type: boolean }
        followup: { type: boolean }
        runContent:
          allOf:
            - $ref: "#/components/schemas/StenografDiscoverRunContent"
          description: |
            The rated run, shown to the user in the confirmation before they
            sent it. Optional so a desktop older than this field keeps rating
            with the trace alone.

    StenografDiscoverRunContent:
      type: object
      additionalProperties: false
      description: |
        The question asked, the answer written, and the passages that answer
        quoted. This is the only Console request that carries meeting content,
        and it carries it only for the one run a user explicitly rated after
        being shown it. Recording, session and local Discover-run identifiers,
        audio, prompts, tool results, model reasoning, error strings, free text,
        and any passage the answer did not cite remain forbidden.
      required: [question, answer, passages, truncated]
      properties:
        question:
          type: string
          minLength: 1
          maxLength: 8192
          description: The question as the user typed it.
        resolvedQuestion:
          type: string
          minLength: 1
          maxLength: 8192
          description: |
            The self-contained restatement the planner searched as, present only
            when it differs from the typed question.
        answer:
          type: array
          maxItems: 12
          description: The answer's lines, in the order they were written.
          items:
            type: object
            additionalProperties: false
            required: [text, evidence, supported, bullet]
            properties:
              text: { type: string, minLength: 1, maxLength: 6144 }
              evidence:
                type: array
                maxItems: 16
                description: |
                  Opaque per-run evidence labels joining this line to the
                  passages below. They are meaningless outside this payload.
                items: { type: string, minLength: 1, maxLength: 16, pattern: "^[A-Za-z0-9_-]+$" }
              supported: { type: boolean }
              bullet: { type: boolean }
        passages:
          type: array
          maxItems: 16
          description: The canonical transcript passages the answer cited.
          items:
            type: object
            additionalProperties: false
            required: [key, startMs, text]
            properties:
              key: { type: string, minLength: 1, maxLength: 16, pattern: "^[A-Za-z0-9_-]+$" }
              recordingTitle: { type: string, minLength: 1, maxLength: 512 }
              speaker: { type: string, minLength: 1, maxLength: 256 }
              startMs:
                type: integer
                minimum: 0
                maximum: 86400000
                description: Offset within its recording, never a wall-clock time.
              text: { type: string, minLength: 1, maxLength: 8192 }
        truncated:
          type: boolean
          description: |
            Whether a desktop bound shortened or dropped any of the above, so a
            partial attachment is never read as a complete one.

    StenografLeaseClaims:
      type: object
      additionalProperties: false
      required:
        - leaseVersion
        - minimumClientSecurityVersion
        - iss
        - aud
        - sub
        - product
        - activationId
        - deviceKeySha256
        - entitlementKind
        - entitlementStatus
        - serial
        - iat
        - refreshAfter
        - offlineUntil
        - entitlementEndsAt
        - maxActivations
      properties:
        leaseVersion: { type: integer, enum: [1] }
        minimumClientSecurityVersion: { type: integer, minimum: 1 }
        iss: { type: string }
        aud: { type: string, enum: [stenograf-desktop] }
        sub: { type: string }
        product: { type: string, enum: [stenograf] }
        activationId: { type: string }
        deviceKeySha256: { type: string, pattern: "^[a-f0-9]{64}$" }
        entitlementKind: { type: string, enum: [trial, subscription] }
        entitlementStatus: { type: string, enum: [active, grace] }
        serial: { type: integer, format: int64, minimum: 1 }
        iat: { type: integer, format: int64 }
        refreshAfter: { type: integer, format: int64 }
        offlineUntil: { type: integer, format: int64 }
        entitlementEndsAt: { type: integer, format: int64 }
        maxActivations: { type: integer, minimum: 1, maximum: 2 }
        trialPolicyRevision: { type: integer, format: int64, minimum: 1 }

    SupportTicket:
      type: object
      properties:
        id:         { type: string, example: st_abc123 }
        subject:    { type: string }
        status:     { type: string, enum: [open, closed] }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
        messages:
          type: array
          items:
            type: object
            properties:
              id:         { type: string }
              author:     { type: string, enum: [user, ops, system] }
              content:    { type: string }
              created_at: { type: string, format: date-time }

  requestBodies:
    StenografDeviceProof:
      required: true
      content:
        application/json:
          schema:
            type: object
            required: [challengeId, signature, deviceName]
            properties:
              challengeId: { type: string }
              signature:
                type: string
                description: Unpadded base64url Ed25519 signature over the versioned challenge message.
              deviceName: { type: string, maxLength: 120 }
              activationId:
                type: string
                description: Required only when refreshing an existing lease.

  responses:
    Unauthorized:
      description: Missing or invalid credential.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    PaymentRequired:
      description: Out of credits.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    BadRequest:
      description: Malformed input.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }

security:
  - ApiKeyAuth: []
  - BearerAuth: []

paths:

  /health:
    get:
      tags: [meta]
      summary: Liveness probe.
      security: []
      responses:
        "200":
          description: OK.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status: { type: string, example: ok }

  /v1/models/transcribe:
    get:
      operationId: listTranscriptionModels
      tags: [meta]
      summary: List the transcription models served and their language coverage.
      description: |
        Capability discovery endpoint. Returns the public model IDs
        accepted by the `model` parameter on `POST /v1/transcribe`
        and `POST /v1/audio/transcriptions`, the modes each model
        supports (batch vs realtime), and the language coverage.

        Models with a finite language list expose `languages` directly and may
        include `languages_count` plus a curated `languages_sample` for quick
        reference. Wide-coverage models may instead pair the count/sample with
        a `languages_reference` URL. Both shapes share the same `features`
        enum.

        This endpoint is the authoritative source for clients picking
        a model — the OpenAPI enum on the `model` field reflects
        the current set, but the response here carries the per-model
        capability details that the enum cannot.
      responses:
        "200":
          description: Available transcription models.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TranscriptionModelList"
        "401": { $ref: "#/components/responses/Unauthorized" }

  /v1/models/synthesize:
    get:
      operationId: listSynthesisModels
      tags: [meta]
      summary: List the synthesis models served and the standard voice catalog.
      description: |
        Capability discovery for `POST /v1/synthesize`. Returns the
        public model IDs accepted by the `model` parameter, the modes
        each supports, the output sample rate, and the catalog of
        built-in preset voices. Every returned `voice_id` is ready to
        use without registration and is valid in the `voice` /
        `voice_id` field on `POST /v1/synthesize`.
      responses:
        "200":
          description: Available synthesis models and standard voices.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SynthesisModelList"
        "401": { $ref: "#/components/responses/Unauthorized" }

  /v1/transcribe:
    post:
      tags: [transcription]
      summary: Submit an audio file for asynchronous transcription.
      description: |
        Returns a `job_id`; poll `GET /v1/transcribe/{job_id}` until
        `status` is `completed` or `failed`. Audio must be raw
        PCM float32 little-endian at 16 kHz mono. Container formats
        (mp3, wav, m4a, ogg, flac, webm) return `400` — re-encode
        with `ffmpeg -ar 16000 -ac 1 -f f32le ...`.

        The complete HTTP request body, including multipart overhead, must be
        no larger than 100 MB and must carry `Content-Length`;
        transfer-encoded and close-delimited request bodies are rejected.
        Concurrent uploads share a bounded server-side admission budget; a
        temporarily unavailable slot returns retryable `503` with
        `Retry-After`.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [audio, config]
              properties:
                audio:
                  type: string
                  format: binary
                  description: |
                    Audio bytes — raw PCM float32 LE 16 kHz. The complete
                    multipart request is limited to 100 MB.
                config:
                  type: string
                  description: |
                    **Required.** JSON-encoded `JobConfig` controlling the
                    pipeline (language, model, diarization). It carries the
                    language, which is required, so a request without this
                    part returns `400`.

                    This part used to be optional. A request that omitted it
                    was accepted with no language at all and left the backend
                    to be guessed acoustically — the behaviour that was
                    withdrawn — so omitting it is now the same error as
                    sending a config with no language in it.
                  example: '{"language":"en","diarize":true}'
      responses:
        "200":
          description: Job queued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  job_id:         { type: string }
                  status:         { type: string, example: queued }
                  reserved_cents: { type: integer, description: Present only when a nonzero amount was reserved; short clips can round to zero and reserve nothing. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/PaymentRequired" }
        "411":
          description: A transfer-encoded or close-delimited request was rejected; send a bounded Content-Length.
        "413":
          description: The complete request body exceeds the public 100 MB limit.
        "503":
          description: Queue unreachable or bounded upload capacity is temporarily occupied; retry according to `Retry-After` when present.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Error" }

  /v1/transcribe/{job_id}:
    get:
      tags: [transcription]
      summary: Poll the status / result of an async transcription job.
      parameters:
        - in: path
          name: job_id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Job state.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/JobStatus"
                  - $ref: "#/components/schemas/MeetingResult"
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
        "410":
          description: The owner permanently deleted this transcript.
          content:
            application/json:
              schema:
                type: object
                properties:
                  job_id: { type: string }
                  status: { type: string, enum: [deleted] }
                  transcript_deleted_at: { type: string }
    delete:
      tags: [transcription]
      summary: Permanently delete a terminal transcript and its input audio.
      description: |
        Immediately scrubs the transcript, speaker timeline, saved participant
        list, notes, and action items. Exact input objects are then removed by
        the trusted cleanup outbox after the bound WorkQueue source is proven
        absent. Billing and meeting lifecycle records remain. The operation is
        owner-scoped and idempotent.
      parameters:
        - in: path
          name: job_id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Transcript and input audio are deleted.
        "202":
          description: Transcript is deleted and exact input-audio cleanup is durably pending or blocked for operator review.
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/NotFound" }
        "409":
          description: The job or one of its Meet children is not terminal.
        "503":
          description: An exact cleanup manifest is unavailable; no transcript data was changed.

  /v1/audio/transcriptions:
    post:
      tags: [audio]
      summary: Synchronous OpenAI Whisper-compatible transcription.
      description: |
        Drop-in replacement for OpenAI's
        `POST https://api.openai.com/v1/audio/transcriptions` — same
        `multipart/form-data` shape, same `response_format` values,
        same response bodies. Blocks for up to 5 minutes; for longer
        audio use the async `POST /v1/transcribe`.

        Soniqo extensions (`x_speaker_id`, `x_soniqo`) appear when
        `response_format=verbose_json`; they're additive and ignored
        by vanilla OpenAI clients.

        The complete HTTP request body, including multipart overhead, must be
        no larger than 100 MB and must carry `Content-Length`;
        transfer-encoded and close-delimited request bodies are rejected.
        Concurrent uploads share a bounded server-side admission budget; a
        temporarily unavailable slot returns retryable `503` with
        `Retry-After`.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [file]
              properties:
                file:
                  type: string
                  format: binary
                  description: |
                    Audio bytes — raw PCM float32 LE 16 kHz mono.
                    Container formats (mp3/wav/m4a/ogg/flac/webm)
                    return `400`; re-encode client-side. The complete
                    multipart request is limited to 100 MB.
                model:
                  type: string
                  example: whisper-1
                  description: |
                    OpenAI-compat field, accepted for migration ease.
                    Routing is driven by the required `language` field (the
                    right model is selected automatically for the language).
                    See `GET /v1/models/transcribe` for the capability
                    matrix and the public model IDs you can pass to the
                    native `POST /v1/transcribe`.
                language:
                  type: string
                  description: |
                    **Required.** Supported BCP-47 tag, e.g. `en`, `es-419`.
                    OpenAI treats this field as optional; this API does not.
                    Omitting it returns `400`, as does an unsupported tag.

                    It used to be optional, with an empty value meaning
                    "detect it acoustically". That detector was withdrawn: on
                    held-out audio it sent about four in ten Arabic-English
                    code-switch clips to the European model, which scores
                    around 90 WER on them. See
                    `GET /v1/models/transcribe` for the exact base-language
                    list.
                  example: en
                response_format:
                  type: string
                  enum: [json, text, verbose_json, srt, vtt]
                  default: json
                temperature:
                  type: number
                  description: Accepted for compat; currently ignored.
                prompt:
                  type: string
                  description: Accepted for compat; currently ignored.
                diarize:
                  type: string
                  enum: [true, false]
                  default: "true"
                  description: Soniqo extension — turn off speaker labels.
      responses:
        "200":
          description: |
            Transcription complete. Body shape depends on `response_format`.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/WhisperJsonResponse"
                  - $ref: "#/components/schemas/WhisperVerboseJsonResponse"
            text/plain:
              schema: { type: string, example: "Hello world..." }
            text/vtt:
              schema: { type: string, example: "WEBVTT\n\n00:00:00.000 --> 00:00:02.500\nHello world...\n" }
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/PaymentRequired" }
        "411":
          description: A transfer-encoded or close-delimited request was rejected; send a bounded Content-Length.
        "413":
          description: The complete request body exceeds the public 100 MB limit.
        "503":
          description: Bounded upload capacity is temporarily occupied; retry according to `Retry-After`.
        "504":
          description: Transcription took longer than 5 minutes; use the async endpoint.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Error" }

  /v1/speakers:
    get:
      tags: [speakers]
      deprecated: true
      summary: List legacy speaker profiles pending deletion.
      description: |
        Transitional cleanup surface. Returns profiles owned by the calling
        user, newest first; stored embeddings are never returned. These
        profiles are no longer consulted by transcription.
      responses:
        "200":
          description: Profiles owned by the calling user.
          content:
            application/json:
              schema:
                type: array
                items: { $ref: "#/components/schemas/SpeakerProfile" }
        "401": { $ref: "#/components/responses/Unauthorized" }
    post:
      tags: [speakers]
      deprecated: true
      summary: Retired speaker-profile enrollment surface.
      description: |
        New enrollment is disabled. Speaker embeddings used for meeting-local
        consistency are ephemeral and cannot be enrolled through this API.
      responses:
        "410":
          description: Stored speaker profiles have been retired.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "401": { $ref: "#/components/responses/Unauthorized" }

  /v1/speakers/{speaker_id}:
    delete:
      tags: [speakers]
      deprecated: true
      summary: Delete one legacy speaker profile during the cleanup window.
      parameters:
        - in: path
          name: speaker_id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Removed.
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404":
          description: Speaker not found, or not owned by the calling user.

  /v1/synthesize:
    post:
      tags: [synthesis]
      summary: Native synthesis — text → WAV.
      description: |
        Preset text-to-speech. Returns a WAV (mono 24 kHz PCM int16) in the
        response body with `Content-Type: audio/wav`.

        Pass a built-in `voice_id` returned by
        `GET /v1/models/synthesize`; omit it to use `af_heart`.

        Text is limited to 300 Unicode characters and the complete JSON body
        is limited to 16 KiB. Split longer narration into separate bounded
        requests.

        A conservative credit hold is taken before dispatch and atomically
        corrected to the generated duration before audio is released.
        Billing is $0.22/min of generated audio, metered per second with no
        minimum.

        Synthesis is request-idempotent for 24 hours. Supplying
        `Idempotency-Key` is strongly recommended: the key is scoped to the
        authenticated user, is never stored in plaintext, and is bound to the
        normalized synthesis request before worker dispatch. Retrying a
        completed request returns the exact retained WAV with
        `Idempotency-Replayed: true` and does not dispatch or charge again.
        Reusing the key with different normalized input returns `409`.

        When the header is omitted, the server still deduplicates an identical
        normalized request from the same user for 24 hours. This keyless safety
        net means an intentional repeat within that window also replays the
        first result; use a distinct `Idempotency-Key` when separate operations
        must remain independently identifiable.
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          description: |
            Caller-generated operation key. It must be one 1-200 character
            visible-ASCII value. The same key and normalized request replay
            the original outcome; the same key with different input returns
            `409`. Keys are user-scoped and retained only as secret-keyed
            digests.
          schema:
            type: string
            minLength: 1
            maxLength: 200
            pattern: '^[!-~]+$'
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/SynthesisRequest" }
      responses:
        "200":
          description: Synthesis complete; body is a WAV.
          headers:
            X-Synthesis-Request-Id:
              schema: { type: string }
              description: |
                Durable operation identifier. It is identical on the first
                response and every replay of that operation.
            Idempotency-Replayed:
              schema: { type: boolean }
              description: |
                Present with value `true` only when this response replayed a
                previously completed operation without worker dispatch.
            X-Duration-Seconds:
              schema: { type: number, format: float }
              description: Length of the returned audio.
            X-Sample-Rate:
              schema: { type: integer, example: 24000 }
            X-Seed-Used:
              schema: { type: integer, format: int64 }
              description: |
                The actual seed used. Equal to the request's nonzero `seed`
                when set; otherwise the server-selected default or worker
                random draw.
            X-Tokens-Generated:
              schema: { type: integer }
            X-Chunks-Synthesized:
              schema: { type: integer }
              description: Number of server-side synthesis chunks joined into the response.
            X-Max-Steps-Used:
              schema: { type: integer }
              description: Highest autoregressive step budget used by any synthesis chunk.
            X-Stopped-On-Stop-Token:
              schema: { type: boolean }
          content:
            audio/wav:
              schema:
                type: string
                format: binary
        "400": { $ref: "#/components/responses/BadRequest" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/PaymentRequired" }
        "409":
          description: |
            The key is bound to different normalized input, the identical
            operation is still pending, or its terminal 24-hour replay window
            has expired. A pending response includes `Retry-After`; no worker
            dispatch or additional credit hold occurs.
          headers:
            X-Synthesis-Request-Id:
              schema: { type: string }
              description: Durable identifier of the already-bound operation.
            Retry-After:
              schema: { type: integer, minimum: 1 }
              description: Seconds before retrying a still-pending operation.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Error" }
        "413":
          description: |
            The text exceeds 300 Unicode characters or the complete JSON body
            exceeds 16 KiB.
        "500":
          description: |
            Durable billing/result commit or replay integrity verification
            failed. Retrying with the same `Idempotency-Key` is safe and must
            not create a second worker dispatch.
        "503":
          description: |
            Synthesis dispatch, billing authority, or retained replay storage
            is temporarily unavailable. Retry according to `Retry-After` when
            present, using the same `Idempotency-Key`.

  /v1/audio/speech:
    post:
      deprecated: true
      tags: [synthesis]
      summary: Reserved OpenAI-compatible synthesis surface (unavailable).
      description: |
        This compatibility surface is intentionally fail-closed at the
        production edge and currently returns `503`. Use the authenticated,
        bounded, credit-settled `POST /v1/synthesize` endpoint instead.

        The request shape below is reserved for a future implementation that
        delegates to exactly the same native synthesis authority.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [input]
              properties:
                model:
                  type: string
                  example: tts-1
                  description: Advisory; we route to Soniqo Vox.
                input:
                  type: string
                  description: The text to synthesize.
                language:
                  type: string
                  example: "de-DE"
                  description: |
                    Optional Soniqo BCP-47 attribution hint. Only the
                    normalized primary language and its submitted provenance
                    are retained; it does not change model routing.
                voice:
                  type: string
                  description: |
                    A built-in Soniqo preset ID from
                    `GET /v1/models/synthesize`, or one of the OpenAI
                    voice names (`alloy`, `echo`, `fable`, ...). OpenAI
                    names use the Soniqo default preset.
                instructions:
                  type: string
                  description: |
                    Accepted for OpenAI request-shape compatibility;
                    currently ignored by preset synthesis.
                response_format:
                  type: string
                  enum: [wav, pcm]
                  default: wav
                  description: |
                    `wav` (default) returns a complete WAV body at the
                    model's native rate. `pcm` returns a chunked
                    `audio/pcm` body of signed 16-bit little-endian mono
                    samples at **24 kHz** — matching OpenAI's pcm output,
                    so the stock OpenAI- / LiveKit-style TTS clients
                    (which assume 24 kHz) play it at the correct pitch.
                    The `X-Sample-Rate` and `X-Format: s16le` response
                    headers state the format. `mp3` / `opus` / `aac` /
                    `flac` are accepted by OpenAI but require server-side
                    encoding not wired yet — they fall back to `wav`.
                speed:
                  type: number
                  description: Accepted for compat; currently ignored.
      responses:
        "503":
          description: Compatibility surface unavailable; use `/v1/synthesize`.

  /v1/realtime:
    get:
      deprecated: true
      tags: [realtime]
      summary: Reserved realtime streaming surface (unavailable).
      description: |
        **This route is intentionally fail-closed at the production edge and
        currently returns `503`.** The wire shape below is reserved; it is not
        a deployed production capability.

        **This is a WebSocket endpoint, not HTTP.** OpenAPI 3.0
        doesn't model WS natively, so it's documented here as a `GET`
        with `Upgrade` semantics for client tooling.

        Upgrade to a WebSocket at
        `wss://api.soniqo.audio/v1/realtime?language=en` with the same
        `X-Api-Key` / `Bearer` auth as the HTTP endpoints.

        **`language` is a required query parameter on the upgrade.** It takes
        the same tags as the batch endpoints, and the upgrade is refused with
        `400` when it is missing or unsupported. It is checked on the upgrade
        rather than per-backend deliberately: the near-live path forwards it to
        `POST /v1/audio/transcriptions`, which requires it, while the streaming
        path does not need it — enforcing it in only one would make identical
        client code work or fail depending on server configuration the client
        cannot see.

        The wire protocol follows
        [OpenAI's Realtime API](https://platform.openai.com/docs/guides/realtime):

        **Client → server** (JSON frames):
        - `{"type":"input_audio_buffer.append","audio":"<base64-pcm16-24k>"}`
          — append a chunk of audio (PCM16 mono 24 kHz, base64-encoded).
        - `{"type":"input_audio_buffer.commit"}` — flush; closes the
          current utterance and triggers a final transcription.

        **Server → client** (JSON frames):
        - `{"type":"conversation.item.input_audio_transcription.delta", "delta":"...partial words...", "x_soniqo":{"words":[...]}}`
        - `{"type":"conversation.item.input_audio_transcription.completed", "transcript":"...final...", "x_soniqo":{"words":[...]}}`
        - `{"type":"session.migrate", "resume_token":"..."}` — sent
          if the server needs to migrate your session; reconnect and
          pass the token in the next session to resume without an
          audio gap.
        - `{"type":"error", "code":"...", "message":"..."}`

        **`x_soniqo.words` extension** — Soniqo addition not in the
        OpenAI Realtime spec. Per-word timing surfaced for clients
        building captions / lipsync / per-word UIs. Same shape as the
        batch `Word` schema (`text`, `start`, `end`, `confidence`).
        Delta events carry the words emitted by this chunk; the
        `.completed` event carries the cumulative set across the
        utterance. Timing is approximate today (proportional within
        each chunk window) — see the batch `Word.start` note. Clients
        on the OpenAI client SDK ignore the `x_` extension and see
        only the standard `delta` / `transcript` fields.

        Billing: 1¢/audio-second, debited every 30 s of audio
        processed, same rate as batch transcription.
      responses:
        "503":
          description: Realtime service is not available in production.

  /v1/api-keys:
    get:
      tags: [api-keys]
      summary: List the caller's API keys.
      responses:
        "200":
          description: Keys.
          content:
            application/json:
              schema:
                type: array
                items: { $ref: "#/components/schemas/ApiKey" }
    post:
      tags: [api-keys]
      summary: Mint a new API key.
      description: |
        The plaintext `key` value is returned **once** at creation
        and never again — store it immediately, or revoke and
        re-mint. Hashes (Argon2id) live in the database.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                label: { type: string }
      responses:
        "201":
          description: Key created.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiKey"
                  - type: object
                    properties:
                      key: { type: string, example: "sk_..." }

  /v1/api-keys/{id}:
    delete:
      tags: [api-keys]
      summary: Revoke an API key.
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Revoked.

  /v1/balance:
    get:
      tags: [billing]
      summary: Total credit balance, in cents, summed over the ledger.
      responses:
        "200":
          description: Balance.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Balance" }

  /v1/billing/events:
    get:
      tags: [billing]
      summary: Paginated ledger history.
      parameters:
        - in: query
          name: limit
          schema: { type: integer, default: 50, maximum: 200 }
        - in: query
          name: offset
          schema: { type: integer, default: 0 }
      responses:
        "200":
          description: Events.
          content:
            application/json:
              schema:
                type: array
                items: { $ref: "#/components/schemas/BillingEvent" }

  /v1/billing/usage:
    get:
      tags: [billing]
      summary: Paginated cost-of-service usage events.
      parameters:
        - in: query
          name: limit
          schema: { type: integer, default: 50 }
        - in: query
          name: offset
          schema: { type: integer, default: 0 }
      responses:
        "200":
          description: Usage events.
          content:
            application/json:
              schema:
                type: array
                items: { $ref: "#/components/schemas/UsageEvent" }

  /v1/cloud/enroll:
    post:
      tags: [billing]
      summary: Explicitly enroll the shared account in speech-cloud credits.
      description: |
        Idempotently creates the signup credit. Generic OIDC identity resolution
        and Stenograf desktop sign-in do not grant cloud transcription credit.
      responses:
        "200":
          description: Cloud enrollment state.
          content:
            application/json:
              schema:
                type: object
                required: [enrolled, grantCreated]
                properties:
                  enrolled: { type: boolean }
                  grantCreated: { type: boolean }

  /v1/stenograf/release:
    get:
      tags: [stenograf]
      security: []
      summary: The one desktop release currently recommended, with its notes.
      description: >-
        Public and unauthenticated, so an install that cannot sign in still
        learns about it. Returns the recommended release after both platform
        builds have been validated, or null while nothing is announced. It
        never carries a download URL; the desktop opens the console's
        Download page.
      responses:
        "200":
          description: The recommended release, or null while nothing is announced.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/StenografRecommendedRelease" }

  /v1/stenograf/license:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    get:
      tags: [stenograf]
      summary: Read the caller's Stenograf offer or subscription state.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Current server-owned entitlement state.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/StenografLicenseState" }

  /v1/stenograf/trial/prepare:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Freeze the current no-card trial policy for this account.
      description: Does not start the trial clock.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Prepared or previously prepared offer.

  /v1/stenograf/telemetry:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Accept one automatic, closed-schema desktop activity event.
      description: |
        Account-linked product diagnostics only. The schema is closed and
        never accepts audio, transcripts, meeting or session identifiers,
        speaker names, file paths, device identifiers, or free text.
        Current builds send no participant count; earlier bounded counts are
        accepted and discarded. A successful response confirms durable
        acceptance; delivery failures return an error.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: "#/components/schemas/StenografTelemetryAppEvent"
                - $ref: "#/components/schemas/StenografTelemetryPlanStepEvent"
                - $ref: "#/components/schemas/StenografTelemetryPipelineEvent"
                - $ref: "#/components/schemas/StenografTelemetryListenStartEvent"
                - $ref: "#/components/schemas/StenografTelemetryStopEvent"
                - $ref: "#/components/schemas/StenografTelemetryAskStartEvent"
                - $ref: "#/components/schemas/StenografTelemetryAskFinishEvent"
      responses:
        "202": { description: Event durably queued for analytics delivery. }
        "400": { description: Event is outside the closed telemetry schema. }
        "429": { description: Per-account daily diagnostics quota exhausted. }
        "503": { description: Event could not be durably accepted. }

  /v1/stenograf/ask-feedback:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Record one explicitly approved Discover rating, its trace and the rated run.
      description: |
        Every call follows a user confirmation for that single response, in
        which the exact attachment was shown before it could be sent. The closed
        schema accepts rating/reason/state categories, capped counters, booleans,
        sorted retrieval-route categories, public build identifiers including
        the selected Ollama model, and `runContent`: the question, the answer as
        written, and the passages that answer quoted. The trace alone cannot
        separate a retrieval miss from a writing failure -- both report the same
        healthy counts -- which is why the run travels with it. The route and
        `askModel` field retain the Console API's historical Ask vocabulary while
        the product calls the feature Discover. Audio, transcript the answer did
        not cite, recording/session/Discover-run identifiers, language, prompts,
        tool results, error strings, and free text remain forbidden.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: true
          schema: { type: string, minLength: 16, maxLength: 128, pattern: "^[A-Za-z0-9_-]+$" }
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/StenografAskFeedback" }
      responses:
        "202": { description: The one approved rating received a durable queue acknowledgement. }
        "400": { description: Feedback is outside the closed schema. }
        "401": { description: Interactive OIDC sign-in is required. }
        "426": { description: The desktop build is no longer supported. }
        "429": { description: Per-account daily feedback quota exhausted. }
        "409": { description: The idempotency key is in flight or belongs to another payload. }
        "503": { description: Feedback could not be durably accepted. }

  /v1/stenograf/device-challenges:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Create a short-lived device proof challenge.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [purpose, devicePublicKey]
              properties:
                purpose: { type: string, enum: [trial_start, activate, refresh] }
                devicePublicKey:
                  type: string
                  description: Unpadded base64url raw Ed25519 public key.
      responses:
        "200":
          description: Device challenge.
          content:
            application/json:
              schema:
                type: object
                required: [challengeId, nonce, purpose, expiresAt]
                properties:
                  challengeId: { type: string }
                  nonce: { type: string }
                  purpose: { type: string }
                  expiresAt: { type: integer, format: int64 }
        "429": { description: Too many outstanding challenges for this account. }

  /v1/stenograf/trial/start:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Start the prepared trial and issue its first device lease.
      description: Called only after the models are ready and the user explicitly confirms Start trial & Listen; an ordinary Listen request cannot start the clock and no card is requested.
      security:
        - BearerAuth: []
      requestBody:
        $ref: "#/components/requestBodies/StenografDeviceProof"
      responses:
        "200":
          description: Signed lease.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/StenografLease" }

  /v1/stenograf/activations:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Activate a paid subscription device and issue a lease.
      security:
        - BearerAuth: []
      requestBody:
        $ref: "#/components/requestBodies/StenografDeviceProof"
      responses:
        "200":
          description: Signed lease.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/StenografLease" }

  /v1/stenograf/leases/refresh:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Refresh an existing device-bound lease.
      security:
        - BearerAuth: []
      requestBody:
        $ref: "#/components/requestBodies/StenografDeviceProof"
      responses:
        "200":
          description: Refreshed signed lease.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/StenografLease" }

  /v1/stenograf/activations/{id}:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    delete:
      tags: [stenograf]
      summary: Deactivate one of the caller's devices.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Device deactivated. An unexpired offline lease continues reserving its slot.
          content:
            application/json:
              schema:
                type: object
                required: [deactivated]
                properties:
                  deactivated: { type: boolean, enum: [true] }
                  slotReservedUntil:
                    type: integer
                    format: int64
                    description: Unix time when the already-issued offline lease releases this slot.

  /v1/stenograf/billing/checkout:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Create a hosted monthly or annual subscription checkout.
      description: >-
        Promotion codes are enabled. The no-card trial is not created here.
        When the account already has an active trial with at least 48 hours
        remaining, Checkout collects a payment method without charging and
        preserves that exact server-owned trial end as the first billing date.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: true
          schema: { type: string, minLength: 8, maxLength: 128 }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [interval]
              properties:
                interval: { type: string, enum: [month, year] }
      responses:
        "200":
          description: Hosted checkout URL.

  /v1/stenograf/billing/portal:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Create a hosted subscription-management session.
      description: >-
        The pinned Stenograf Portal configuration is verified before use. Plan
        changes must continue an existing trial rather than ending it early.
      security:
        - BearerAuth: []
      responses:
        "200": { description: Hosted portal URL. }

  /v1/stenograf/billing/resume:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Resume a subscription that is scheduled to cancel.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: The subscription remains active and will renew.

  /v1/stenograf/billing/checkout/status:
    parameters:
      - $ref: "#/components/parameters/StenografClientPlatform"
      - $ref: "#/components/parameters/StenografClientAppVersion"
      - $ref: "#/components/parameters/StenografClientSecurityVersion"
    post:
      tags: [stenograf]
      summary: Verify and project one hosted Stenograf Checkout completion.
      description: >-
        The authenticated account must own the exact Checkout Session. The
        response is derived from the payment provider rather than from the
        browser success redirect.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [sessionId]
              properties:
                sessionId: { type: string, pattern: '^cs_[A-Za-z0-9_.-]+$' }
      responses:
        "200": { description: Authoritative Checkout state. }

  /v1/support/tickets:
    get:
      tags: [support]
      summary: List the caller's support tickets.
      responses:
        "200":
          description: Tickets.
          content:
            application/json:
              schema:
                type: array
                items: { $ref: "#/components/schemas/SupportTicket" }
    post:
      tags: [support]
      summary: Open a support ticket. Auto-creates a Discord forum thread if the webhook is wired.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [subject, body]
              properties:
                subject: { type: string, minLength: 1, maxLength: 200 }
                body:    { type: string, minLength: 1, maxLength: 8000 }
      responses:
        "201":
          description: Created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:                 { type: string }
                  subject:            { type: string }
                  status:             { type: string }
                  discord_thread_id:  { type: string, nullable: true }

  /v1/support/tickets/{id}:
    get:
      tags: [support]
      summary: Get a single ticket with its messages.
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Ticket detail.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/SupportTicket" }
        "404": { $ref: "#/components/responses/NotFound" }

  /v1/support/tickets/{id}/messages:
    post:
      tags: [support]
      summary: Append a follow-up to an open ticket.
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [content]
              properties:
                content: { type: string, maxLength: 8000 }
      responses:
        "201":
          description: Posted.

  /v1/account/delete:
    post:
      tags: [account]
      summary: Soft-delete the calling user's account.
      description: |
        Idempotent. Soft-deletes the account (financial ledger is
        preserved), revokes all API keys, and fails any queued or
        in-flight jobs. Sign-in is disabled after this call returns.
      responses:
        "200":
          description: Deleted (or already deleted).
          content:
            application/json:
              schema:
                type: object
                properties:
                  status: { type: string, enum: [deleted, already_deleted] }
