openapi: 3.0.3
info:
  title: XTranslator API
  version: 1.0.0
  description: "Initial OpenAPI specification generated mechanically from the NestJS controller source (apps/orchestrator). Schemas are intentionally minimal (type: object); request body and query DTO names are recorded under x-dto / x-query-dto for follow-up enrichment. Auth: bearer (Firebase ID token) is required unless an operation carries x-auth: public or x-auth: optional."
servers:
  - url: "https://api.xtranslator.app"
tags:
  - name: auth
  - name: audio
  - name: checkout
  - name: credits
  - name: document
  - name: email
  - name: glossaries
  - name: health
  - name: image
  - name: jobs
  - name: ocr
  - name: plans
  - name: root
  - name: speech
  - name: subscription
  - name: translations
  - name: webhooks
securitySchemes:
  bearerAuth:
    type: http
    scheme: bearer
    description: Firebase ID token (JWT)
paths:
  /:
    get:
      tags:
        - root
      summary: root root
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/auth/signup:
    post:
      tags:
        - auth
      summary: signup
      x-auth: public
      description: Creates a new user account (Firebase Auth + Firestore). Rate limited to 5 requests/hour/IP. Mirrors SignupDto.
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - email
                - password
                - turnstileToken
              properties:
                email:
                  type: string
                  format: email
                password:
                  type: string
                  minLength: 6
                turnstileToken:
                  type: string
                  description: Cloudflare Turnstile captcha token
      responses:
        201:
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  uid:
                    type: string
                  email:
                    type: string
  /api/v1/audio/translate:
    post:
      tags:
        - audio
      summary: translate
      security:
        - bearerAuth: []
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: TranslateAudioDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/credits:
    get:
      tags:
        - credits
      summary: credits root
      x-auth: optional — works without token; Firebase ID token honoured if sent
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/credits/calculate:
    post:
      tags:
        - credits
      summary: calculate
      x-auth: optional — works without token; Firebase ID token honoured if sent
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: CalculateCreditsDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/credits/check:
    post:
      tags:
        - credits
      summary: check
      x-auth: optional — works without token; Firebase ID token honoured if sent
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: CheckCreditsDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/credits/quota:
    get:
      tags:
        - credits
      summary: quota
      x-auth: optional — works without token; Firebase ID token honoured if sent
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/document/translate:
    post:
      tags:
        - document
      summary: translate
      security:
        - bearerAuth: []
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: TranslateArtifactDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/document/{trackingId}/unlock:
    post:
      tags:
        - document
      summary: unlock
      description: |
        Requests a Lemon Squeezy checkout for the watermark-free version of a
        COMPLETED free-preview document job (owner only). x-enabled: false —
        requires unlock rollout (UNLOCK_ENABLED kill switch is off in
        production until FE and BE are flipped together; endpoint answers 503).
      x-enabled: false
      security:
        - bearerAuth: []
      parameters:
        - name: trackingId
          in: path
          required: true
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  checkoutUrl:
                    type: string
                  trackingId:
                    type: string
                  jobId:
                    type: string
                  orderId:
                    type: string
  /api/v1/document/{trackingId}/unlock/status:
    get:
      tags:
        - document
      summary: unlock status
      description: |
        Polls the unlock entitlement lifecycle for a document (owner only).
        x-enabled: false — requires unlock rollout (UNLOCK_ENABLED kill
        switch; endpoint answers 503 while disabled).
      x-enabled: false
      security:
        - bearerAuth: []
      parameters:
        - name: trackingId
          in: path
          required: true
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  enabled:
                    type: boolean
                  state:
                    type: string
                    enum:
                      - none
                      - pending
                      - active
                  orderId:
                    type: string
                    nullable: true
                  activatedAt:
                    type: string
                    format: date-time
                    nullable: true
  /api/v1/email/account-verification/request:
    post:
      tags:
        - email
      summary: account verification request
      security:
        - bearerAuth: []
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/email/contact:
    post:
      tags:
        - email
      summary: contact
      x-auth: public
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: ContactSupportDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/email/newsletter-subscriptions:
    post:
      tags:
        - email
      summary: newsletter subscriptions
      x-auth: public
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: RequestNewsletterSubscriptionDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/email/newsletter-subscriptions/verify:
    post:
      tags:
        - email
      summary: newsletter subscriptions verify
      x-auth: public
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: VerifyNewsletterSubscriptionDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/email/password-reset/request:
    post:
      tags:
        - email
      summary: password reset request
      x-auth: public
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: RequestPasswordResetDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/glossaries:
    get:
      tags:
        - glossaries
      summary: glossaries root
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
    post:
      tags:
        - glossaries
      summary: glossaries root
      x-auth: public
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: CreateGlossaryDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/glossaries/{id}:
    put:
      tags:
        - glossaries
      summary: glossaries root
      x-auth: public
      parameters:
        - name: id
          in: path
          required: True
          schema:
            type: string
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: UpdateGlossaryDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
    delete:
      tags:
        - glossaries
      summary: glossaries root
      x-auth: public
      parameters:
        - name: id
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/image/translate:
    post:
      tags:
        - image
      summary: translate
      security:
        - bearerAuth: []
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: TranslateArtifactDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/my-jobs:
    get:
      tags:
        - jobs
      summary: my jobs
      x-auth: optional — works without token; Firebase ID token honoured if sent
      x-query-dto: JobListRequestDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/{jobId}:
    get:
      tags:
        - jobs
      summary: jobs root
      security:
        - bearerAuth: []
      parameters:
        - name: jobId
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/{jobId}/notified:
    patch:
      tags:
        - jobs
      summary: notified
      security:
        - bearerAuth: []
      parameters:
        - name: jobId
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/{jobId}/result:
    get:
      tags:
        - jobs
      summary: result
      security:
        - bearerAuth: []
      parameters:
        - name: jobId
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/{jobId}/viewed:
    patch:
      tags:
        - jobs
      summary: viewed
      security:
        - bearerAuth: []
      parameters:
        - name: jobId
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/{trackingId}:
    delete:
      tags:
        - jobs
      summary: jobs root
      security:
        - bearerAuth: []
      parameters:
        - name: trackingId
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/{trackingId}/status:
    get:
      tags:
        - jobs
      summary: status
      security:
        - bearerAuth: []
      parameters:
        - name: trackingId
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/jobs/{trackingId}/stream:
    get:
      tags:
        - jobs
      summary: stream
      security:
        - bearerAuth: []
      x-stream: text/event-stream
      parameters:
        - name: trackingId
          in: path
          required: True
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            text/event-stream:
              schema:
                type: object
  /api/v1/ocr/extract:
    post:
      tags:
        - ocr
      summary: extract
      security:
        - bearerAuth: []
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: ExtractTextDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/ocr/quota:
    get:
      tags:
        - ocr
      summary: quota
      x-auth: optional — works without token; Firebase ID token honoured if sent
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/payments/checkout:
    post:
      tags:
        - checkout
      summary: checkout root
      x-auth: public
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: CreateCheckoutDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/payments/plans:
    get:
      tags:
        - plans
      summary: plans root
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/payments/plans/credit-packages:
    get:
      tags:
        - plans
      summary: credit packages
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/payments/subscription:
    get:
      tags:
        - subscription
      summary: subscription root
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/payments/subscription/cancel:
    post:
      tags:
        - subscription
      summary: cancel
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/payments/subscription/reactivate:
    patch:
      tags:
        - subscription
      summary: reactivate
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/payments/unlock-artifact/download-artifact-url:
    get:
      tags:
        - checkout
      summary: download artifact url
      description: |
        Returns a fresh signed download URL for the watermark-free artifact of
        an unlocked document job (owner only; job identified by the jobId query
        parameter). x-enabled: false — requires unlock rollout (UNLOCK_ENABLED
        kill switch; endpoint answers 503 while disabled).
      x-enabled: false
      security:
        - bearerAuth: []
      parameters:
        - name: jobId
          in: query
          required: true
          schema:
            type: string
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  artifactUrl:
                    type: string
  /api/v1/payments/webhooks/lemon-squeezy:
    post:
      tags:
        - webhooks
      summary: lemon squeezy
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/speech/transcribe:
    post:
      tags:
        - speech
      summary: transcribe
      security:
        - bearerAuth: []
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: SpeechToTextDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/speech/tts:
    post:
      tags:
        - speech
      summary: tts
      security:
        - bearerAuth: []
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: TextToSpeechDto
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /api/v1/translations:
    post:
      tags:
        - translations
      summary: translations root
      security:
        - bearerAuth: []
      x-stream: text/event-stream
      requestBody:
        required: True
        content:
          application/json:
            schema:
              type: object
              x-dto: TranslateTextDto
      responses:
        200:
          description: OK
          content:
            text/event-stream:
              schema:
                type: object
  /health:
    get:
      tags:
        - health
      summary: health root
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /health/ready:
    get:
      tags:
        - health
      summary: ready
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /healthz:
    get:
      tags:
        - root
      summary: healthz
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
  /readyz:
    get:
      tags:
        - root
      summary: readyz
      x-auth: public
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
