{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/quillhub-ai/json-schema/quillhub-ai-transcription-schema.json",
  "title": "Transcription",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/quillhub-ai-openapi.json#/components/schemas/Transcription",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Stable identifier with `trs_` prefix."
    },
    "internal_id": {
      "type": "integer",
      "description": "Numeric `request.id` used by first-party web/desktop URLs (e.g. https://quillhub.ai/{locale}/transcript/{internal_id}). Public API consumers should keep using `id`; this field exists so first-party clients can deep-link to the existing web transcript page without an extra round-trip."
    },
    "kind": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "meeting",
        "dictation"
      ],
      "description": "Categorisation of the request: 'dictation' for short voice notes captured via the desktop widget, 'meeting' for recorded calls/uploads. Null on legacy rows; clients should treat null as 'meeting'."
    },
    "title": {
      "type": [
        "string",
        "null"
      ],
      "description": "Human-readable title. Generated by the structurer once the transcript is ready (e.g. \"Митинг с командой о Q3\"); falls back to the original filename for sources that don't go through structuring."
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "processing",
        "completed",
        "failed",
        "cancelled"
      ],
      "description": "Lifecycle stage. `queued` → `processing` → one of `completed` / `failed` / `cancelled` (terminal)."
    },
    "stage": {
      "type": "string",
      "enum": [
        "queued",
        "downloading",
        "transcribing",
        "structuring",
        "completed",
        "failed",
        "insufficient_funds",
        "cancelled"
      ],
      "description": "Precise processing stage. `status` keeps its existing, back-compatible meaning; `stage` refines it — notably separating `insufficient_funds` from a generic failure, and the download / transcribe / structure phases from a generic `processing`."
    },
    "progress": {
      "type": [
        "number",
        "null"
      ],
      "description": "Fraction between 0 and 1 while `processing`. `null` otherwise."
    },
    "source": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "youtube",
            "instagram",
            "direct",
            "upload"
          ],
          "description": "Detected source category. `youtube` / `instagram` for those platforms, `direct` for any other reachable URL, `upload` when the client sent an inline base64 file."
        },
        "url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Normalized source URL. `null` for inline uploads unless `include_source_url: true`."
        },
        "channel": {
          "type": [
            "string",
            "null"
          ],
          "description": "Which surface created the recording: `web`, `api`, `desktop`, `bot`, `tg_webapp`. `null` for rows created before the column existed (those are web uploads). Deliberately a free-form string, not an enum: the column carries no CHECK constraint, and a new surface must not break response validation for existing clients."
        }
      },
      "required": [
        "type"
      ],
      "description": "What was submitted."
    },
    "options": {
      "type": "object",
      "properties": {
        "language": {
          "type": [
            "string",
            "null"
          ],
          "description": "Language forced by the caller. `null` if auto-detect was used."
        },
        "speaker_recognition": {
          "type": "boolean"
        },
        "structure": {
          "type": "boolean"
        }
      },
      "required": [
        "speaker_recognition",
        "structure"
      ],
      "description": "Echoes the create-request options so clients can branch on effective config."
    },
    "duration_seconds": {
      "type": [
        "number",
        "null"
      ],
      "description": "Source duration, detected after download/probe."
    },
    "language": {
      "type": [
        "string",
        "null"
      ],
      "description": "Detected or forced ISO-639-1 language code. `null` until probed."
    },
    "share_enabled": {
      "type": "boolean",
      "description": "Whether the public share link is active."
    },
    "share_enabled_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "ISO 8601 timestamp when sharing was enabled. `null` if never enabled."
    },
    "share_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Public share URL. `null` when `share_enabled` is false."
    },
    "points_spent": {
      "type": [
        "number",
        "null"
      ],
      "description": "Points charged on completion. `null` until the job is terminal."
    },
    "result": {
      "$ref": "#/$defs/TranscriptionResult"
    },
    "source_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Short-lived presigned URL to the stored source file. Only present for inline uploads when `include_source_url: true` was set on create."
    },
    "webhook_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Callback URL recorded on create. We POST the finished Transcription object here."
    },
    "error": {
      "type": [
        "string",
        "null"
      ],
      "description": "Human-readable failure reason. Present only when `status` is `failed`. Machine-readable classification lives in `error_code`, never inside this text."
    },
    "error_code": {
      "type": [
        "string",
        "null"
      ],
      "description": "Stable machine-readable failure code (e.g. `GOT_ARCHIVE`, `CONTENT_PRIVATE`, `NO_SPEECH`). `null` when the failure wasn't classified. Branch on this instead of matching `error` text."
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      },
      "description": "Arbitrary string→string map passed on create, echoed back unchanged."
    },
    "workspace_id": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Workspace the transcription belongs to. `null` on legacy rows created before workspaces."
    },
    "project_id": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Project inside the workspace. `null` means the transcription sits in the workspace Inbox (no project)."
    },
    "created_at": {
      "type": "string",
      "description": "ISO 8601 timestamp."
    },
    "completed_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO 8601 timestamp of the terminal transition. `null` otherwise."
    }
  },
  "required": [
    "id",
    "internal_id",
    "status",
    "stage",
    "source",
    "options",
    "share_enabled",
    "share_enabled_at",
    "share_url",
    "created_at"
  ],
  "$defs": {
    "Segment": {
      "type": "object",
      "properties": {
        "start": {
          "type": "number",
          "description": "Seconds from the beginning of the source audio."
        },
        "end": {
          "type": "number",
          "description": "Seconds from the beginning of the source audio."
        },
        "text": {
          "type": "string"
        },
        "speaker": {
          "type": [
            "string",
            "null"
          ],
          "description": "Generic speaker label (`Speaker 1`, `Speaker 2`, …). Present only when the request set `speaker_recognition: true`."
        }
      },
      "required": [
        "start",
        "end",
        "text"
      ]
    },
    "TranscriptionResult": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "text": {
          "type": [
            "string",
            "null"
          ],
          "description": "Full transcript as a single plain-text string."
        },
        "segments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Segment"
          },
          "description": "Phrase-level chunks with timestamps and optional speaker labels."
        },
        "structured": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "title": {
              "type": [
                "string",
                "null"
              ],
              "description": "Suggested title inferred by the structurer."
            },
            "summary": {
              "type": [
                "string",
                "null"
              ],
              "description": "Short summary of the content."
            },
            "language": {
              "type": [
                "string",
                "null"
              ],
              "description": "Detected language code, echoed from the structurer."
            },
            "toc": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              },
              "description": "Table of contents — array of entries with a `title` and a `start_paragraph_number` anchor (plus any auxiliary fields the structurer emits)."
            },
            "chapters": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              },
              "description": "Chapter-level segmentation with `title`, `start_time`, `end_time`, and the paragraphs that belong to each chapter."
            },
            "paragraphs": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              },
              "description": "Paragraph-level readable view with `start_time`, `paragraph_text`, and the index matching back to `result.segments`."
            },
            "highlights": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Key quotes pulled from the transcript."
            },
            "key_theses": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Main thesis statements — slightly longer than highlights."
            },
            "terms": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Glossary of proper nouns, product names, and domain terms the model extracted."
            },
            "action_items": {
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "text": {
                        "type": "string"
                      },
                      "who": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "due": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "text"
                    ]
                  }
                ]
              },
              "description": "Tasks found in the recording, exactly as the structurer emitted them: either a bare string, or an object with `text` plus an optional assignee and deadline. Use `format=summary` for the normalized `ActionItem` shape."
            },
            "decisions": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Decisions reached during the recording."
            },
            "topics": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Topics covered in the recording."
            }
          },
          "description": "Title, summary, TOC, paragraphs, highlights, and terms. Populated when `structure: true`."
        },
        "subtitles": {
          "type": "object",
          "properties": {
            "vtt": {
              "type": [
                "string",
                "null"
              ],
              "description": "Presigned URL to the WebVTT file. Suitable to pass directly into a `<track>` element or a player. Expires after the storage TTL."
            },
            "srt": {
              "type": [
                "string",
                "null"
              ],
              "description": "Presigned URL to the SRT file. Expires after the storage TTL."
            }
          },
          "description": "Ready-to-use VTT and SRT caption strings."
        }
      },
      "description": "Populated when `status` is `completed`. `null` for `queued` / `processing` / `failed` / `cancelled`."
    }
  }
}