{
  "openapi": "3.0.0",
  "paths": {
    "/templates": {
      "post": {
        "operationId": "TemplatesController_create",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTemplateDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Template created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Invalid template data"
          },
          "401": {
            "description": "Not authenticated"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Create a new template",
        "tags": [
          "Templates"
        ]
      },
      "get": {
        "operationId": "TemplatesController_findAll",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (1-based)",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "pageSize",
            "required": false,
            "in": "query",
            "description": "Number of items per page",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort order",
            "schema": {
              "default": "desc",
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "name",
            "required": false,
            "in": "query",
            "description": "Filter by template name (partial match)",
            "schema": {
              "example": "SOAP",
              "type": "string"
            }
          },
          {
            "name": "documentType",
            "required": false,
            "in": "query",
            "description": "Filter by document type",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categories",
            "required": false,
            "in": "query",
            "description": "Filter by categories (comma-separated)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "createdBy",
            "required": false,
            "in": "query",
            "description": "Filter by created by user ID",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Search in content (full-text search)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Sort field",
            "schema": {
              "default": "useCount",
              "type": "string",
              "enum": [
                "created",
                "name",
                "updated",
                "likes",
                "useCount"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Templates retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Get all templates (paginated)",
        "tags": [
          "Templates"
        ]
      }
    },
    "/templates/{id}": {
      "get": {
        "operationId": "TemplatesController_findOne",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Template ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Template retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateResponseDto"
                }
              }
            }
          },
          "404": {
            "description": "Template not found"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Get template by ID",
        "tags": [
          "Templates"
        ]
      },
      "patch": {
        "operationId": "TemplatesController_update",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Template ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTemplateDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Template updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateResponseDto"
                }
              }
            }
          },
          "403": {
            "description": "Not authorized to update this template"
          },
          "404": {
            "description": "Template not found"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Update template by ID",
        "tags": [
          "Templates"
        ]
      },
      "delete": {
        "operationId": "TemplatesController_remove",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Template ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Template deleted successfully"
          },
          "403": {
            "description": "Not authorized to delete this template"
          },
          "404": {
            "description": "Template not found"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Delete a template",
        "tags": [
          "Templates"
        ]
      }
    },
    "/notes": {
      "post": {
        "description": "Generate a structured medical note from conversation text or audio using a specified template. Returns immediately with the generated content.",
        "operationId": "NotesController_generateNote",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNoteRequestDto"
              },
              "examples": {
                "text_input": {
                  "summary": "Text-based Note Generation",
                  "description": "Generate a note from conversation text",
                  "value": {
                    "template_id": "a8d09b68-85f2-49c5-ba88-77517d196263",
                    "conversation_text": "Patient reports chest pain that started 2 hours ago. Pain is sharp, 7/10 intensity, radiating to left arm. No shortness of breath or nausea. Patient appears anxious."
                  }
                },
                "audio_input": {
                  "summary": "Audio-based Note Generation",
                  "description": "Generate a note from audio file or URL",
                  "value": {
                    "template_id": "a8d09b68-85f2-49c5-ba88-77517d196263",
                    "audioUrl": "https://example.com/consultation-recording.wav",
                    "sourceLanguage": "en-US",
                    "transcriptionQuality": "high",
                    "context": {
                      "patient_id": "pat_123",
                      "encounter_id": "enc_456"
                    }
                  }
                },
                "combined_input": {
                  "summary": "Combined Text and Audio Generation",
                  "description": "Generate a note from both conversation text and audio URL",
                  "value": {
                    "template_id": "a8d09b68-85f2-49c5-ba88-77517d196263",
                    "conversation_text": "Initial assessment: Patient reports chest pain that started 2 hours ago. Pain is sharp, 7/10 intensity, radiating to left arm.",
                    "audioUrl": "https://example.com/detailed-consultation.wav",
                    "sourceLanguage": "en-US",
                    "transcriptionQuality": "high",
                    "context": {
                      "patient_id": "pat_123",
                      "encounter_id": "enc_456"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Note generated successfully",
            "schema": {
              "example": {
                "note": {
                  "title": "SOAP Note",
                  "sections": {
                    "Subjective": "Patient presents with chief complaint of chest pain that started 2 hours ago. Pain is described as sharp, 7/10 intensity, radiating to left arm. No associated shortness of breath or nausea.",
                    "Objective": "Vital signs: BP 140/90, HR 88, RR 16, Temp 98.6°F. Patient appears in mild distress. Cardiovascular exam reveals regular rhythm, no murmurs.",
                    "Assessment": "Based on the presentation and examination findings, this appears to be atypical chest pain, likely non-cardiac etiology.",
                    "Plan": "Continue current medications as prescribed. Schedule follow-up appointment in 2 weeks. Return to ED if symptoms worsen."
                  }
                },
                "template": {
                  "id": "a8d09b68-85f2-49c5-ba88-77517d196263",
                  "name": "Emergency Department SOAP Note",
                  "type": "soap"
                },
                "generation_metadata": {
                  "generated_at": "2024-01-15T10:30:00Z",
                  "model_used": "scribe-balanced",
                  "model_version": "1.0"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "application/json": {
                "schema": {
                  "example": {
                    "statusCode": 400,
                    "message": [
                      "conversation_text should not be empty"
                    ],
                    "error": "Bad Request"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "example": {
                    "statusCode": 401,
                    "message": "Invalid API key",
                    "error": "Unauthorized"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Template not found",
            "content": {
              "application/json": {
                "schema": {
                  "example": {
                    "statusCode": 404,
                    "message": "Template with ID template_invalid not found",
                    "error": "Not Found"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Generate medical note",
        "tags": [
          "Notes"
        ]
      }
    },
    "/notes/regenerate-section": {
      "post": {
        "description": "Re-run generation for one template heading without repeating the full note request.",
        "operationId": "NotesController_regenerateSection",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegenerateSectionDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Regenerate a single note section",
        "tags": [
          "Notes"
        ]
      }
    },
    "/notes/ask": {
      "post": {
        "description": "Answers clinician questions strictly using the provided note and/or encounter transcript on Canadian infrastructure (zero retention), returning grounded citations.",
        "operationId": "NotesController_askNote",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "question"
                ],
                "properties": {
                  "question": {
                    "type": "string",
                    "example": "Did the patient report any penicillin allergy?"
                  },
                  "note": {
                    "type": "string"
                  },
                  "transcript": {
                    "type": "string"
                  },
                  "history": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "required": [
                        "role",
                        "content"
                      ],
                      "properties": {
                        "role": {
                          "type": "string",
                          "enum": [
                            "user",
                            "assistant"
                          ]
                        },
                        "content": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "scribe-balanced",
                      "scribe-swift",
                      "scribe-precise",
                      "scribe-classic"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Grounded clinical Q&A answer with verbatim citations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "answer": {
                      "type": "string"
                    },
                    "citations": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "grounded": {
                      "type": "boolean"
                    },
                    "engine": {
                      "type": "string"
                    },
                    "region": {
                      "type": "string",
                      "example": "ca-montreal"
                    },
                    "latency_ms": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Ask AI a clinical question grounded in a note or transcript",
        "tags": [
          "Notes"
        ]
      }
    },
    "/notes/refine": {
      "post": {
        "description": "Applies natural-language editing instructions (conciseness, formatting, bullet points, tone) to a full note or focused section on Canadian infrastructure without inventing clinical facts.",
        "operationId": "NotesController_refineNote",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "instruction",
                  "note"
                ],
                "properties": {
                  "instruction": {
                    "type": "string",
                    "example": "Convert Assessment & Plan into concise numbered bullets."
                  },
                  "note": {
                    "type": "string"
                  },
                  "transcript": {
                    "type": "string"
                  },
                  "section_title": {
                    "type": "string",
                    "example": "Assessment & Plan"
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "scribe-balanced",
                      "scribe-swift",
                      "scribe-precise",
                      "scribe-classic"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Refined clinical note and summary of changes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "refined_note": {
                      "type": "string"
                    },
                    "summary_of_changes": {
                      "type": "string"
                    },
                    "engine": {
                      "type": "string"
                    },
                    "region": {
                      "type": "string",
                      "example": "ca-montreal"
                    },
                    "latency_ms": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Refine a clinical note or section with plain-English instructions",
        "tags": [
          "Notes"
        ]
      }
    },
    "/transcription/jobs": {
      "post": {
        "description": "Submit audio via file upload or URL for transcription. Results will be sent to your configured webhook.",
        "operationId": "TranscriptionController_createTranscriptionJob",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/CreateTranscriptionDto"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Transcription job accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranscriptionJobResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - missing audio or invalid parameters"
          },
          "403": {
            "description": "Transcription feature not enabled for this project"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Create transcription job",
        "tags": [
          "Transcription"
        ]
      },
      "get": {
        "description": "List all transcription jobs for the project with optional filtering and pagination.",
        "operationId": "TranscriptionController_listTranscriptionJobs",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (1-based)",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "pageSize",
            "required": false,
            "in": "query",
            "description": "Number of items per page",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort order",
            "schema": {
              "default": "desc",
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Filter by job status",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "processing",
                "completed",
                "failed"
              ]
            }
          },
          {
            "name": "sourceType",
            "required": false,
            "in": "query",
            "description": "Filter by source type",
            "schema": {
              "type": "string",
              "enum": [
                "upload",
                "url"
              ]
            }
          },
          {
            "name": "language",
            "required": false,
            "in": "query",
            "description": "Filter by source language",
            "schema": {
              "example": "en-US",
              "type": "string"
            }
          },
          {
            "name": "webhookStatus",
            "required": false,
            "in": "query",
            "description": "Filter by webhook delivery status",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "delivered",
                "failed",
                "not_configured"
              ]
            }
          },
          {
            "name": "createdAfter",
            "required": false,
            "in": "query",
            "description": "Filter jobs created after this date (ISO 8601)",
            "schema": {
              "example": "2024-01-01T00:00:00.000Z",
              "type": "string"
            }
          },
          {
            "name": "createdBefore",
            "required": false,
            "in": "query",
            "description": "Filter jobs created before this date (ISO 8601)",
            "schema": {
              "example": "2024-01-31T23:59:59.999Z",
              "type": "string"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Sort by field",
            "schema": {
              "default": "createdAt",
              "type": "string",
              "enum": [
                "createdAt",
                "completedAt",
                "status"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of transcription jobs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "List transcription jobs",
        "tags": [
          "Transcription"
        ]
      }
    },
    "/transcription/jobs/{jobId}": {
      "get": {
        "description": "Retrieve the status and metadata of a specific transcription job. Does not include transcription content.",
        "operationId": "TranscriptionController_getTranscriptionJob",
        "parameters": [
          {
            "name": "jobId",
            "required": true,
            "in": "path",
            "description": "Session ID of the transcription job",
            "schema": {
              "example": "sess_550e8400-e29b-41d4-a716-446655440000",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transcription job status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranscriptionJobStatusDto"
                }
              }
            }
          },
          "404": {
            "description": "Transcription job not found"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Get transcription job status",
        "tags": [
          "Transcription"
        ]
      }
    },
    "/clinical/billing-codes/suggest": {
      "post": {
        "description": "Analyzes a clinical note and/or encounter transcript on Canadian infrastructure (zero retention) and returns ranked billing and diagnostic code suggestions with verbatim supporting evidence.",
        "operationId": "ClinicalController_suggestBillingCodes",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "note": {
                    "type": "string",
                    "example": "34yo F with 2 days of dysuria and urinary frequency. No fever or flank pain. Uncomplicated UTI; prescribed nitrofurantoin 100 mg BID x 5 days."
                  },
                  "transcript": {
                    "type": "string"
                  },
                  "jurisdiction": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "ON-OHIP",
                      "BC-MSP",
                      "AB-AHCIP",
                      "QC-RAMQ",
                      "ICD-10-CA",
                      "US-CPT",
                      "ICD-10-CM"
                    ],
                    "default": "auto",
                    "example": "ON-OHIP"
                  },
                  "specialty": {
                    "type": "string",
                    "example": "Family Medicine"
                  },
                  "max_codes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 20,
                    "default": 8
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "scribe-balanced",
                      "scribe-swift",
                      "scribe-precise",
                      "scribe-classic"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked billing and diagnostic code suggestions with evidence",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jurisdiction": {
                      "type": "string"
                    },
                    "codes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string",
                            "example": "A007"
                          },
                          "system": {
                            "type": "string",
                            "example": "ON-OHIP"
                          },
                          "category": {
                            "type": "string",
                            "enum": [
                              "billing",
                              "diagnostic"
                            ]
                          },
                          "description": {
                            "type": "string"
                          },
                          "confidence": {
                            "type": "number",
                            "example": 0.92
                          },
                          "evidence": {
                            "type": "string"
                          },
                          "rationale": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "notes": {
                      "type": "string",
                      "nullable": true
                    },
                    "engine": {
                      "type": "string",
                      "enum": [
                        "scribe-balanced",
                        "scribe-swift",
                        "scribe-precise",
                        "scribe-classic"
                      ]
                    },
                    "region": {
                      "type": "string",
                      "example": "ca-montreal"
                    },
                    "latency_ms": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Suggest grounded billing and diagnostic codes",
        "tags": [
          "Clinical"
        ]
      }
    },
    "/clinical/prechart/summarize": {
      "post": {
        "description": "Synthesizes prior notes, labs, intake forms, and daysheets into a structured pre-visit summary including patient contact/DOB, active problems, medications, allergies, care gaps, and visit agenda. Zero retention.",
        "operationId": "ClinicalController_summarizePrechart",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "documents"
                ],
                "properties": {
                  "visit_reason": {
                    "type": "string",
                    "example": "Diabetes & hypertension follow-up"
                  },
                  "specialty": {
                    "type": "string",
                    "example": "Internal Medicine"
                  },
                  "documents": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 25,
                    "items": {
                      "type": "object",
                      "required": [
                        "text"
                      ],
                      "properties": {
                        "title": {
                          "type": "string",
                          "example": "HbA1c Lab Report"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "prior-note",
                            "lab-result",
                            "intake",
                            "daysheet",
                            "medication-list",
                            "referral",
                            "other"
                          ],
                          "default": "other"
                        },
                        "date": {
                          "type": "string",
                          "example": "2026-10-12"
                        },
                        "text": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "scribe-balanced",
                      "scribe-swift",
                      "scribe-precise",
                      "scribe-classic"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured pre-visit clinical summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "patient_summary": {
                      "type": "string"
                    },
                    "contact_and_demographics": {
                      "type": "object",
                      "properties": {
                        "date_of_birth": {
                          "type": "string",
                          "nullable": true
                        },
                        "phone": {
                          "type": "string",
                          "nullable": true
                        },
                        "email": {
                          "type": "string",
                          "nullable": true
                        },
                        "preferred_pharmacy": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    },
                    "active_problems": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "current_medications": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "allergies": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "recent_results": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "open_care_gaps": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "suggested_agenda": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "document_count": {
                      "type": "integer"
                    },
                    "engine": {
                      "type": "string",
                      "enum": [
                        "scribe-balanced",
                        "scribe-swift",
                        "scribe-precise",
                        "scribe-classic"
                      ]
                    },
                    "region": {
                      "type": "string",
                      "example": "ca-montreal"
                    },
                    "latency_ms": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Generate a pre-visit clinical brief (pre-charting)",
        "tags": [
          "Clinical"
        ]
      }
    },
    "/clinical/documents/generate": {
      "post": {
        "description": "Creates structured clinical documents grounded strictly in the provided note or encounter transcript. Returns both Markdown and plain text. Zero retention.",
        "operationId": "ClinicalController_generateDocument",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "document_type"
                ],
                "properties": {
                  "document_type": {
                    "type": "string",
                    "enum": [
                      "referral",
                      "patient-handout",
                      "work-note",
                      "school-note",
                      "consult-letter"
                    ],
                    "example": "referral"
                  },
                  "note": {
                    "type": "string"
                  },
                  "transcript": {
                    "type": "string"
                  },
                  "recipient": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "example": "Dr. M. Tremblay"
                      },
                      "specialty": {
                        "type": "string",
                        "example": "Cardiology"
                      },
                      "clinic": {
                        "type": "string"
                      }
                    }
                  },
                  "clinician": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "example": "Dr. A. Patel"
                      },
                      "credentials": {
                        "type": "string",
                        "example": "MD, CCFP"
                      },
                      "clinic": {
                        "type": "string"
                      }
                    }
                  },
                  "instructions": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string",
                    "default": "en",
                    "example": "en"
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "scribe-balanced",
                      "scribe-swift",
                      "scribe-precise",
                      "scribe-classic"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated clinical document in Markdown, plain text, and structured sections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "document_type": {
                      "type": "string",
                      "enum": [
                        "referral",
                        "patient-handout",
                        "work-note",
                        "school-note",
                        "consult-letter"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "sections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "heading": {
                            "type": "string"
                          },
                          "body": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "content_markdown": {
                      "type": "string"
                    },
                    "content_text": {
                      "type": "string"
                    },
                    "engine": {
                      "type": "string",
                      "enum": [
                        "scribe-balanced",
                        "scribe-swift",
                        "scribe-precise",
                        "scribe-classic"
                      ]
                    },
                    "region": {
                      "type": "string",
                      "example": "ca-montreal"
                    },
                    "latency_ms": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Generate referrals, patient handouts, work/school notes, or consult letters",
        "tags": [
          "Clinical"
        ]
      }
    },
    "/clinical/forms/fill": {
      "post": {
        "description": "Extracts typed field answers (`text`, `boolean`, `date`, `number`, `choice`, `multi-choice`) with confidence scores and verbatim quotes for any non-FHIR custom form schema. Zero retention.",
        "operationId": "ClinicalController_fillCustomForm",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fields"
                ],
                "properties": {
                  "form_title": {
                    "type": "string",
                    "default": "Clinical Form",
                    "example": "Prior Authorization Intake"
                  },
                  "fields": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 150,
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "label",
                        "type"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "smoking_status"
                        },
                        "label": {
                          "type": "string",
                          "example": "Smoking status"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "text",
                            "boolean",
                            "date",
                            "number",
                            "choice",
                            "multi-choice"
                          ]
                        },
                        "options": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "instruction": {
                          "type": "string"
                        },
                        "required": {
                          "type": "boolean"
                        }
                      }
                    }
                  },
                  "transcript": {
                    "type": "string"
                  },
                  "note": {
                    "type": "string"
                  },
                  "existing_values": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "today": {
                    "type": "string",
                    "example": "2026-11-27"
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "scribe-balanced",
                      "scribe-swift",
                      "scribe-precise",
                      "scribe-classic"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Typed form answers validated against the requested field schema",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "form_title": {
                      "type": "string"
                    },
                    "filled_fields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "value": {},
                          "confidence": {
                            "type": "number",
                            "example": 0.95
                          },
                          "evidence": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "unanswered_field_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "engine": {
                      "type": "string",
                      "enum": [
                        "scribe-balanced",
                        "scribe-swift",
                        "scribe-precise",
                        "scribe-classic"
                      ]
                    },
                    "region": {
                      "type": "string",
                      "example": "ca-montreal"
                    },
                    "latency_ms": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Populate any custom structured medical form from a transcript or note",
        "tags": [
          "Clinical"
        ]
      }
    },
    "/tools": {
      "get": {
        "description": "Get a list of all registered tools with their definitions and parameters",
        "operationId": "ToolsController_getTools",
        "parameters": [],
        "responses": {
          "200": {
            "description": "List of available tools",
            "content": {
              "application/json": {
                "example": [
                  {
                    "name": "add_numbers",
                    "description": "Add two numbers together",
                    "category": "math",
                    "requiresConfirmation": true,
                    "parameters": [
                      {
                        "name": "a",
                        "type": "number",
                        "description": "First number to add",
                        "required": true
                      },
                      {
                        "name": "b",
                        "type": "number",
                        "description": "Second number to add",
                        "required": true
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "summary": "List all available tools",
        "tags": [
          "Tools"
        ]
      }
    },
    "/tools/categories": {
      "get": {
        "description": "Get a summary of tools organized by category with counts",
        "operationId": "ToolsController_getToolsByCategory",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Tools organized by category",
            "content": {
              "application/json": {
                "example": {
                  "math": 4,
                  "healthcare": 1
                }
              }
            }
          }
        },
        "summary": "Get tools organized by category",
        "tags": [
          "Tools"
        ]
      }
    },
    "/tools/category/{category}": {
      "get": {
        "description": "Get all tools in a specific category",
        "operationId": "ToolsController_getToolsInCategory",
        "parameters": [
          {
            "name": "category",
            "required": true,
            "in": "path",
            "description": "Tool category (e.g., \"math\", \"healthcare\")",
            "schema": {
              "example": "math",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tools in the specified category"
          }
        },
        "summary": "Get tools by category",
        "tags": [
          "Tools"
        ]
      }
    },
    "/tools/{name}": {
      "get": {
        "description": "Get detailed information about a specific tool",
        "operationId": "ToolsController_getTool",
        "parameters": [
          {
            "name": "name",
            "required": true,
            "in": "path",
            "description": "Tool name",
            "schema": {
              "example": "add_numbers",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tool definition"
          },
          "404": {
            "description": "Tool not found"
          }
        },
        "summary": "Get tool definition",
        "tags": [
          "Tools"
        ]
      }
    },
    "/tools/{name}/execute": {
      "post": {
        "description": "Execute a tool with provided arguments. Requires SMART authentication for FHIR tools.",
        "operationId": "ToolsController_executeTool",
        "parameters": [
          {
            "name": "name",
            "required": true,
            "in": "path",
            "description": "Tool name to execute",
            "schema": {
              "example": "add_numbers",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Tool execution request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToolExecutionRequestDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tool executed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ToolExecutionResponseDto"
                },
                "example": {
                  "success": true,
                  "data": {
                    "result": 8,
                    "operation": "5 + 3 = 8",
                    "operationType": "addition"
                  },
                  "metadata": {
                    "executedAt": "2024-01-01T12:00:00Z",
                    "userId": "user123",
                    "sessionId": "session456"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid arguments or tool not found"
          },
          "401": {
            "description": "Missing or invalid SMART JWT token"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Execute a tool",
        "tags": [
          "Tools"
        ]
      }
    },
    "/tools/{name}/validate": {
      "post": {
        "description": "Validate arguments for a tool without executing it",
        "operationId": "ToolsController_validateTool",
        "parameters": [
          {
            "name": "name",
            "required": true,
            "in": "path",
            "description": "Tool name",
            "schema": {
              "example": "add_numbers",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Arguments to validate",
          "content": {
            "application/json": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "example": {
                  "valid": true
                }
              }
            }
          }
        },
        "summary": "Validate tool arguments",
        "tags": [
          "Tools"
        ]
      }
    },
    "/realtime/tokens": {
      "post": {
        "description": "Generate a short-lived token for browser-side WebSocket streaming. Call this from your server, then pass the token to the browser client. Tokens expire after the specified duration (max 1 hour).",
        "operationId": "RealtimeTokenController_createToken",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRealtimeTokenBodyDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Token created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateRealtimeTokenResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Create a temporary realtime token",
        "tags": [
          "Realtime"
        ]
      }
    },
    "/questionnaires/{questionnaireId}/versions/{version}": {
      "put": {
        "description": "Validates and compiles any FHIR R4/R5 Questionnaire, runs one-time speech enrichment, and stores it for this project. Re-sending identical content is idempotent; different content for an existing version returns 409.",
        "operationId": "GuidedFormsController_register",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Register an immutable FHIR Questionnaire version",
        "tags": [
          "Guided forms"
        ]
      },
      "get": {
        "operationId": "GuidedFormsController_get",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Fetch a Questionnaire version (FHIR resource)",
        "tags": [
          "Guided forms"
        ]
      }
    },
    "/questionnaires": {
      "get": {
        "operationId": "GuidedFormsController_list",
        "parameters": [],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "List registered and built-in Questionnaires",
        "tags": [
          "Guided forms"
        ]
      }
    },
    "/guided-forms/extract": {
      "post": {
        "description": "Stateless Section 5.3/5.4 extraction for partners running live audio, post-visit dictation, typed notes (`mode: \"note\"`), or end-of-visit synthesis (`mode: \"batch\"`). Supports optional per-field `field_instructions`; nothing is stored.",
        "operationId": "GuidedFormsController_extract",
        "parameters": [],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Extract field answers from an utterance, typed note, or batch transcript",
        "tags": [
          "Guided forms"
        ]
      }
    },
    "/questionnaires/{questionnaireId}/versions/{version}/instructions/tweak": {
      "post": {
        "description": "Turns an admin natural-language request into a reviewable diff of per-field `scribe-instruction` values without altering linkIds, types, or options.",
        "operationId": "GuidedFormsController_tweakInstructions",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Suggest per-field extraction instruction edits from natural language",
        "tags": [
          "Guided forms"
        ]
      }
    },
    "/questionnaires/{questionnaireId}/versions/{version}/test": {
      "post": {
        "description": "Runs stateless extraction (up to 2 passes to exercise conditional enableWhen gates) with optional draft `field_instructions`, returning extracted fields and a draft FHIR QuestionnaireResponse. Nothing is persisted.",
        "operationId": "GuidedFormsController_sandboxTest",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Pre-publish admin sandbox test against a transcript or pharmacist note",
        "tags": [
          "Guided forms"
        ]
      }
    },
    "/dictation/transcribe": {
      "post": {
        "description": "Transcribes a dictated clip on Scribeberry Live (Toronto, zero retention) and optionally applies Smart clinical cleanup, medical dictionary spelling enforcement, and voice macros. Accepts multipart `audio`, JSON `audio_base64`, or JSON `audio_url`.",
        "operationId": "DictationController_transcribe",
        "parameters": [],
        "requestBody": {
          "required": true,
          "description": "Provide audio as multipart `audio`, JSON `audio_base64`, or JSON `audio_url`. Omitting `cleanup_mode`, `medical_dictionary`, or `macros` inherits saved clinician/project settings.",
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "audio": {
                    "type": "string",
                    "format": "binary",
                    "description": "Multipart audio clip (WAV, WebM, MP3, M4A, OGG, FLAC; max 100 MB / 30 min)"
                  },
                  "audio_base64": {
                    "type": "string",
                    "description": "Base64-encoded audio (or data URI) when using JSON"
                  },
                  "audio_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "HTTPS URL to an audio clip"
                  },
                  "mime_type": {
                    "type": "string",
                    "example": "audio/webm"
                  },
                  "language": {
                    "type": "string",
                    "default": "auto",
                    "example": "en"
                  },
                  "cleanup_mode": {
                    "type": "string",
                    "enum": [
                      "smart",
                      "verbatim",
                      "raw"
                    ]
                  },
                  "field_kind": {
                    "type": "string",
                    "enum": [
                      "clinical-note",
                      "email",
                      "chat",
                      "search",
                      "template"
                    ]
                  },
                  "medical_dictionary": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "Eliquis",
                      "apixaban",
                      "metoprolol"
                    ]
                  },
                  "macros": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "trigger",
                        "replacement"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "trigger": {
                          "type": "string",
                          "minLength": 2
                        },
                        "replacement": {
                          "type": "string"
                        },
                        "enabled": {
                          "type": "boolean",
                          "default": true
                        },
                        "noLeadingSpace": {
                          "type": "boolean"
                        }
                      }
                    }
                  },
                  "external_user_id": {
                    "type": "string",
                    "example": "dr_patel_42"
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "audio": {
                    "type": "string",
                    "format": "binary",
                    "description": "Multipart audio clip (WAV, WebM, MP3, M4A, OGG, FLAC; max 100 MB / 30 min)"
                  },
                  "audio_base64": {
                    "type": "string",
                    "description": "Base64-encoded audio (or data URI) when using JSON"
                  },
                  "audio_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "HTTPS URL to an audio clip"
                  },
                  "mime_type": {
                    "type": "string",
                    "example": "audio/webm"
                  },
                  "language": {
                    "type": "string",
                    "default": "auto",
                    "example": "en"
                  },
                  "cleanup_mode": {
                    "type": "string",
                    "enum": [
                      "smart",
                      "verbatim",
                      "raw"
                    ]
                  },
                  "field_kind": {
                    "type": "string",
                    "enum": [
                      "clinical-note",
                      "email",
                      "chat",
                      "search",
                      "template"
                    ]
                  },
                  "medical_dictionary": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "Eliquis",
                      "apixaban",
                      "metoprolol"
                    ]
                  },
                  "macros": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "trigger",
                        "replacement"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "trigger": {
                          "type": "string",
                          "minLength": 2
                        },
                        "replacement": {
                          "type": "string"
                        },
                        "enabled": {
                          "type": "boolean",
                          "default": true
                        },
                        "noLeadingSpace": {
                          "type": "boolean"
                        }
                      }
                    }
                  },
                  "external_user_id": {
                    "type": "string",
                    "example": "dr_patel_42"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transcribed and cleaned dictation text",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string",
                      "example": "Patient started on Eliquis 5 mg BID."
                    },
                    "raw_text": {
                      "type": "string",
                      "example": "um patient started on eliquis 5 mg bid"
                    },
                    "cleanup_mode": {
                      "type": "string",
                      "enum": [
                        "smart",
                        "verbatim",
                        "raw"
                      ]
                    },
                    "cleaned": {
                      "type": "boolean"
                    },
                    "language": {
                      "type": "string",
                      "example": "en"
                    },
                    "audio_seconds": {
                      "type": "number",
                      "example": 4.8
                    },
                    "inference_ms": {
                      "type": "number",
                      "example": 310
                    },
                    "polish_ms": {
                      "type": "number",
                      "example": 0
                    },
                    "engine": {
                      "type": "string",
                      "example": "scribe-live"
                    },
                    "region": {
                      "type": "string",
                      "example": "ca-toronto"
                    },
                    "provider": {
                      "type": "string",
                      "example": "scribeberry"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Paste-mode Canadian dictation (single audio clip up to 30 min)",
        "tags": [
          "Dictation"
        ]
      }
    },
    "/dictation/polish": {
      "post": {
        "description": "Stateless Canadian-resident clinical dictation cleaner. Fixes medical dictionary spellings, punctuation, stutters, and voice macros without inventing clinical facts. Zero retention.",
        "operationId": "DictationController_polish",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "example": "um patient takes eliquis 5 mg twice daily new paragraph normal neuro"
                  },
                  "cleanup_mode": {
                    "type": "string",
                    "enum": [
                      "smart",
                      "verbatim",
                      "raw"
                    ]
                  },
                  "field_kind": {
                    "type": "string",
                    "enum": [
                      "clinical-note",
                      "email",
                      "chat",
                      "search",
                      "template"
                    ]
                  },
                  "language": {
                    "type": "string",
                    "example": "en"
                  },
                  "medical_dictionary": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "Eliquis",
                      "apixaban"
                    ]
                  },
                  "macros": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "trigger",
                        "replacement"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "trigger": {
                          "type": "string",
                          "minLength": 2
                        },
                        "replacement": {
                          "type": "string"
                        },
                        "enabled": {
                          "type": "boolean",
                          "default": true
                        },
                        "noLeadingSpace": {
                          "type": "boolean"
                        }
                      }
                    }
                  },
                  "external_user_id": {
                    "type": "string",
                    "example": "dr_patel_42"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Polished clinical dictation text",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string"
                    },
                    "raw_text": {
                      "type": "string"
                    },
                    "changed": {
                      "type": "boolean"
                    },
                    "cleanup_mode": {
                      "type": "string",
                      "enum": [
                        "smart",
                        "verbatim",
                        "raw"
                      ]
                    },
                    "engine": {
                      "type": "string",
                      "enum": [
                        "scribe-swift",
                        "scribe-classic",
                        "passthrough"
                      ]
                    },
                    "region": {
                      "type": "string",
                      "nullable": true,
                      "example": "ca-montreal"
                    },
                    "latency_ms": {
                      "type": "number",
                      "example": 280
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Polish dictated clinical text and expand voice macros",
        "tags": [
          "Dictation"
        ]
      }
    },
    "/dictation/settings": {
      "get": {
        "description": "Returns project defaults or merged clinician-specific dictation settings when `external_user_id` is provided.",
        "operationId": "DictationController_getSettings",
        "parameters": [
          {
            "name": "external_user_id",
            "required": false,
            "in": "query",
            "description": "Optional partner clinician ID for per-clinician settings",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resolved project or clinician dictation settings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "scope": {
                      "type": "string",
                      "enum": [
                        "project",
                        "clinician"
                      ]
                    },
                    "external_user_id": {
                      "type": "string"
                    },
                    "cleanup_mode": {
                      "type": "string",
                      "enum": [
                        "smart",
                        "verbatim",
                        "raw"
                      ]
                    },
                    "delivery": {
                      "type": "string",
                      "enum": [
                        "live",
                        "paste"
                      ]
                    },
                    "medical_dictionary": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "macros": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Get saved dictation settings (medical dictionary & voice macros)",
        "tags": [
          "Dictation"
        ]
      },
      "put": {
        "description": "Persists default cleanup mode, delivery preference (`live` or `paste`), medical dictionary terms, and custom voice macros for the project or an individual clinician (`external_user_id`).",
        "operationId": "DictationController_updateSettings",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "external_user_id": {
                    "type": "string",
                    "example": "dr_patel_42"
                  },
                  "cleanup_mode": {
                    "type": "string",
                    "enum": [
                      "smart",
                      "verbatim",
                      "raw"
                    ]
                  },
                  "delivery": {
                    "type": "string",
                    "enum": [
                      "live",
                      "paste"
                    ]
                  },
                  "medical_dictionary": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "Eliquis",
                      "apixaban",
                      "Dr. Chen"
                    ]
                  },
                  "macros": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "trigger",
                        "replacement"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "macro-neuro"
                        },
                        "trigger": {
                          "type": "string",
                          "minLength": 2,
                          "example": "normal neuro"
                        },
                        "replacement": {
                          "type": "string",
                          "example": "Cranial nerves II-XII intact. Motor 5/5 throughout."
                        },
                        "enabled": {
                          "type": "boolean",
                          "default": true
                        },
                        "noLeadingSpace": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated dictation settings"
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Update saved dictation settings (medical dictionary & voice macros)",
        "tags": [
          "Dictation"
        ]
      }
    },
    "/jobs/visits": {
      "post": {
        "description": "Queues audio and/or text for note generation. Poll GET /jobs/:jobId or configure a project webhook for completion.",
        "operationId": "JobsController_createVisitJob",
        "parameters": [
          {
            "name": "idempotency-key",
            "required": true,
            "in": "header",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Safe retry key; repeats return the same job",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateVisitJobDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatusDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Create async visit job",
        "tags": [
          "Jobs"
        ]
      }
    },
    "/jobs/{jobId}": {
      "get": {
        "operationId": "JobsController_getJob",
        "parameters": [
          {
            "name": "jobId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatusDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "API-Key": []
          }
        ],
        "summary": "Get job status",
        "tags": [
          "Jobs"
        ]
      }
    }
  },
  "info": {
    "title": "Scribeberry Public API",
    "description": "# Scribeberry Public API\n\nClinical speech recognition, realtime and paste dictation, structured note generation, FHIR Guided Forms, and Canadian-resident clinical intelligence APIs.\n\n## Authentication\n\nAll REST endpoints require an API-key Bearer token (`Authorization: Bearer sk_live_...`). Browser WebSocket sessions use short-lived tokens minted via `POST /api/v1/realtime/tokens`.",
    "version": "1.0.0",
    "contact": {
      "name": "Scribeberry Support",
      "url": "https://api.scribeberry.com",
      "email": "hello@scribeberry.com"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://api.scribeberry.com/license"
    },
    "termsOfService": "https://scribeberry.com/terms",
    "x-logo": {
      "url": "https://app.scribeberry.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fscribeberry-berry.a91611d0.png&w=2048&q=75",
      "altText": "Scribeberry Logo"
    }
  },
  "tags": [],
  "servers": [
    {
      "url": "https://api.scribeberry.com/api/v1",
      "description": "Production"
    },
    {
      "url": "https://sandbox.api.scribeberry.com/api/v1",
      "description": "Sandbox"
    }
  ],
  "components": {
    "securitySchemes": {
      "API-Key": {
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "type": "http"
      }
    },
    "schemas": {
      "SmartDiscoveryResponseDto": {
        "type": "object",
        "properties": {
          "authorization_endpoint": {
            "type": "string",
            "description": "OAuth2 authorization endpoint",
            "example": "https://auth.example.com/oauth/authorize"
          },
          "token_endpoint": {
            "type": "string",
            "description": "OAuth2 token endpoint",
            "example": "https://auth.example.com/oauth/token"
          },
          "introspection_endpoint": {
            "type": "string",
            "description": "Token introspection endpoint",
            "example": "https://auth.example.com/oauth/introspect"
          },
          "revocation_endpoint": {
            "type": "string",
            "description": "Token revocation endpoint",
            "example": "https://auth.example.com/oauth/revoke"
          },
          "jwks_uri": {
            "type": "string",
            "description": "JSON Web Key Set URI",
            "example": "https://auth.example.com/.well-known/jwks.json"
          },
          "scopes_supported": {
            "description": "Supported SMART on FHIR scopes",
            "example": [
              "openid",
              "fhirUser",
              "launch",
              "launch/patient",
              "patient/*.read",
              "user/*.read",
              "offline_access"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "response_types_supported": {
            "description": "Supported OAuth2 response types",
            "example": [
              "code"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "capabilities": {
            "description": "SMART on FHIR capabilities",
            "example": [
              "launch-ehr",
              "launch-standalone",
              "client-public",
              "client-confidential-symmetric",
              "context-ehr-patient",
              "permission-patient"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "code_challenge_methods_supported": {
            "description": "Supported PKCE code challenge methods",
            "example": [
              "S256"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grant_types_supported": {
            "description": "Supported OAuth2 grant types",
            "example": [
              "authorization_code",
              "refresh_token"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "authorization_endpoint",
          "token_endpoint"
        ]
      },
      "SmartTokenRequestDto": {
        "type": "object",
        "properties": {
          "grant_type": {
            "type": "string",
            "description": "OAuth2 grant type",
            "example": "authorization_code",
            "default": "authorization_code"
          },
          "code": {
            "type": "string",
            "description": "Authorization code from OAuth2 callback",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
          },
          "redirect_uri": {
            "type": "string",
            "description": "Redirect URI used in authorization request",
            "example": "http://localhost:3000/api/v1/smart-auth/callback"
          },
          "code_verifier": {
            "type": "string",
            "description": "PKCE code verifier",
            "example": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
          },
          "client_id": {
            "type": "string",
            "description": "Client ID for public clients",
            "example": "my-smart-app-client-id"
          },
          "client_secret": {
            "type": "string",
            "description": "Client secret for confidential clients",
            "example": "my-client-secret"
          }
        },
        "required": [
          "grant_type",
          "code",
          "redirect_uri"
        ]
      },
      "SmartTokenResponseDto": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "description": "OAuth2 access token",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
          },
          "token_type": {
            "type": "string",
            "description": "Token type",
            "example": "Bearer",
            "default": "Bearer"
          },
          "expires_in": {
            "type": "number",
            "description": "Token expiration time in seconds",
            "example": 3600
          },
          "refresh_token": {
            "type": "string",
            "description": "OAuth2 refresh token",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.refresh"
          },
          "scope": {
            "type": "string",
            "description": "Granted scopes",
            "example": "openid fhirUser patient/Patient.read patient/Observation.read"
          },
          "id_token": {
            "type": "string",
            "description": "OpenID Connect ID token",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.id_token"
          },
          "patient": {
            "type": "string",
            "description": "Patient context ID",
            "example": "Patient/123"
          },
          "encounter": {
            "type": "string",
            "description": "Encounter context ID",
            "example": "Encounter/456"
          },
          "fhirUser": {
            "type": "string",
            "description": "FHIR user reference",
            "example": "Practitioner/789"
          },
          "need_patient_banner": {
            "type": "boolean",
            "description": "Whether patient banner is needed",
            "example": true
          },
          "smart_style_url": {
            "type": "string",
            "description": "SMART style URL for UI customization",
            "example": "https://ehr.example.com/styles/smart-app.css"
          }
        },
        "required": [
          "access_token",
          "token_type"
        ]
      },
      "CreateApiKeyDto": {
        "type": "object",
        "properties": {}
      },
      "CreateTemplateDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Template name",
            "example": "SOAP Note Template"
          },
          "description": {
            "type": "string",
            "description": "Template description",
            "example": "Comprehensive SOAP note template for clinical documentation"
          },
          "content": {
            "type": "string",
            "description": "Template content/prompt",
            "example": "Generate a SOAP note with..."
          },
          "documentType": {
            "type": "string",
            "description": "Document type this template generates",
            "example": "soap"
          },
          "headings": {
            "description": "Template headings structure",
            "example": [
              "Subjective",
              "Objective",
              "Assessment",
              "Plan"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "categories": {
            "description": "Template categories for organization",
            "example": [
              "emergency",
              "soap",
              "cardiology"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "additionalInfo": {
            "type": "string",
            "description": "Additional information or guidance"
          },
          "notes": {
            "type": "string",
            "description": "Optional notes about the template"
          },
          "preview": {
            "type": "object",
            "description": "Preview data for the template",
            "example": {
              "testConvo": "Patient presents with chest pain...",
              "testOutput": "S: Patient reports sudden onset chest pain..."
            }
          }
        },
        "required": [
          "name",
          "content",
          "documentType"
        ]
      },
      "TemplateResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Template ID"
          },
          "name": {
            "type": "string",
            "description": "Template name"
          },
          "description": {
            "type": "object",
            "description": "Template description",
            "nullable": true
          },
          "documentType": {
            "type": "string",
            "description": "Document type this template generates",
            "example": "soap"
          },
          "headings": {
            "description": "Template headings structure",
            "example": [
              "Subjective",
              "Objective",
              "Assessment",
              "Plan"
            ],
            "nullable": true,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "categories": {
            "description": "Template categories for organization",
            "example": [
              "emergency",
              "soap",
              "cardiology"
            ],
            "nullable": true,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "content": {
            "type": "object",
            "description": "Template content/prompt instructions",
            "nullable": true
          },
          "additionalInfo": {
            "type": "object",
            "description": "Additional template-specific instructions for note generation",
            "nullable": true
          },
          "preview": {
            "type": "object",
            "description": "Template preview data",
            "nullable": true
          },
          "isPublic": {
            "type": "boolean",
            "description": "Whether the template is public",
            "default": false
          },
          "createdAt": {
            "type": "string",
            "description": "Creation timestamp"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last update timestamp"
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "documentType",
          "headings",
          "categories",
          "content",
          "additionalInfo",
          "preview",
          "isPublic",
          "createdAt",
          "updatedAt"
        ]
      },
      "PaginatedResponseDto": {
        "type": "object",
        "properties": {
          "items": {
            "description": "Array of items for current page",
            "type": "array",
            "items": {
              "type": "array"
            }
          },
          "total": {
            "type": "number",
            "description": "Total number of items",
            "example": 150
          },
          "page": {
            "type": "number",
            "description": "Current page number",
            "example": 1
          },
          "pageSize": {
            "type": "number",
            "description": "Number of items per page",
            "example": 20
          },
          "totalPages": {
            "type": "number",
            "description": "Total number of pages",
            "example": 8
          },
          "hasNext": {
            "type": "boolean",
            "description": "Whether there is a next page",
            "example": true
          },
          "hasPrevious": {
            "type": "boolean",
            "description": "Whether there is a previous page",
            "example": false
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "pageSize",
          "totalPages",
          "hasNext",
          "hasPrevious"
        ]
      },
      "UpdateTemplateDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Template name",
            "example": "SOAP Note Template"
          },
          "description": {
            "type": "string",
            "description": "Template description",
            "example": "Comprehensive SOAP note template for clinical documentation"
          },
          "content": {
            "type": "string",
            "description": "Template content/prompt",
            "example": "Generate a SOAP note with..."
          },
          "documentType": {
            "type": "string",
            "description": "Document type this template generates",
            "example": "soap"
          },
          "headings": {
            "description": "Template headings structure",
            "example": [
              "Subjective",
              "Objective",
              "Assessment",
              "Plan"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "categories": {
            "description": "Template categories for organization",
            "example": [
              "emergency",
              "soap",
              "cardiology"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "additionalInfo": {
            "type": "string",
            "description": "Additional information or guidance"
          },
          "notes": {
            "type": "string",
            "description": "Optional notes about the template"
          },
          "preview": {
            "type": "object",
            "description": "Preview data for the template",
            "example": {
              "testConvo": "Patient presents with chest pain...",
              "testOutput": "S: Patient reports sudden onset chest pain..."
            }
          },
          "updateReason": {
            "type": "string",
            "description": "Update reason or notes"
          }
        }
      },
      "NoteContextDto": {
        "type": "object",
        "properties": {
          "patient_id": {
            "type": "string",
            "description": "Patient identifier",
            "example": "patient_123"
          },
          "encounter_id": {
            "type": "string",
            "description": "Encounter identifier",
            "example": "encounter_456"
          },
          "provider_id": {
            "type": "string",
            "description": "Provider identifier",
            "example": "provider_789"
          },
          "institution_id": {
            "type": "string",
            "description": "Institution identifier",
            "example": "institution_321"
          },
          "additional_context": {
            "type": "object",
            "description": "Additional context data",
            "example": {
              "department": "cardiology",
              "urgency": "routine"
            }
          }
        }
      },
      "CreateNoteRequestDto": {
        "type": "object",
        "properties": {
          "conversation_text": {
            "type": "string",
            "description": "The conversation text to generate medical note from. Can be provided alone or combined with audio/audioUrl.",
            "example": "Patient complains of chest pain that started 2 hours ago. Pain is described as sharp, 7/10 intensity, radiating to left arm. No shortness of breath. Vital signs stable.",
            "minLength": 10,
            "maxLength": 50000
          },
          "audio": {
            "type": "string",
            "format": "binary",
            "description": "Audio file to transcribe and generate note from. Can be provided alone or combined with conversation_text."
          },
          "audioUrl": {
            "type": "string",
            "description": "URL to audio file to transcribe and generate note from. Can be provided alone or combined with conversation_text.",
            "example": "https://example.com/audio/patient-consultation.wav"
          },
          "sourceLanguage": {
            "type": "string",
            "description": "Source language for audio transcription. Only used when audio is provided.",
            "example": "en-US",
            "default": "auto"
          },
          "transcriptionQuality": {
            "type": "string",
            "description": "Quality setting for audio transcription. Only used when audio is provided.",
            "enum": [
              "low",
              "medium",
              "high"
            ],
            "default": "high"
          },
          "template_id": {
            "type": "string",
            "description": "Template ID to use for note generation",
            "example": "a8d09b68-85f2-49c5-ba88-77517d196263"
          },
          "context": {
            "description": "Additional context about the patient, encounter, provider, etc.",
            "allOf": [
              {
                "$ref": "#/components/schemas/NoteContextDto"
              }
            ]
          },
          "status": {
            "type": "string",
            "description": "Initial status for the note generation",
            "enum": [
              "draft",
              "final"
            ],
            "default": "draft"
          }
        },
        "required": [
          "template_id"
        ]
      },
      "NoteContentDto": {
        "type": "object",
        "properties": {
          "markdown": {
            "type": "string",
            "description": "The generated medical note content in markdown format",
            "example": "# Subjective\n- Patient reports chest pain...\n# Objective\n- Vitals stable..."
          },
          "text": {
            "type": "string",
            "description": "The generated medical note content in plain text format",
            "example": "Subjective: Patient reports chest pain...\nObjective: Vitals stable..."
          },
          "structured": {
            "type": "object",
            "description": "The generated medical note content structured by headings",
            "example": {
              "Subjective": "Patient reports chest pain...",
              "Objective": "Vitals stable..."
            }
          }
        },
        "required": [
          "markdown",
          "text",
          "structured"
        ]
      },
      "NoteTemplateDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the template used",
            "example": "1977b8c6-21a7-4abf-b970-435ab85e50a2"
          },
          "name": {
            "type": "string",
            "description": "Name of the template",
            "example": "SOAP Note"
          },
          "documentType": {
            "type": "string",
            "description": "Document type of the template",
            "example": "soap"
          },
          "headings": {
            "description": "Headings defined in the template",
            "example": [
              "Subjective",
              "Objective",
              "Assessment",
              "Plan"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "name",
          "documentType",
          "headings"
        ]
      },
      "GenerationMetadataDto": {
        "type": "object",
        "properties": {
          "inputTokens": {
            "type": "number",
            "description": "Number of input tokens used for generation",
            "example": 500
          },
          "outputTokens": {
            "type": "number",
            "description": "Number of output tokens generated",
            "example": 200
          },
          "generationTimeMs": {
            "type": "number",
            "description": "Time taken for note generation in milliseconds",
            "example": 1500
          }
        },
        "required": [
          "inputTokens",
          "outputTokens",
          "generationTimeMs"
        ]
      },
      "TranscriptDto": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "Transcribed text from audio input",
            "example": "Patient reports chest pain that started 2 hours ago..."
          },
          "confidence": {
            "type": "number",
            "description": "Overall confidence score of the transcription",
            "example": 0.95
          },
          "duration": {
            "type": "number",
            "description": "Duration of the audio in seconds",
            "example": 45.5
          },
          "sourceLanguage": {
            "type": "string",
            "description": "Detected or specified source language",
            "example": "en-US"
          },
          "sessionId": {
            "type": "string",
            "description": "Transcription session ID for tracking",
            "example": "sess_550e8400-e29b-41d4-a716-446655440000"
          }
        },
        "required": [
          "text",
          "confidence",
          "duration",
          "sourceLanguage"
        ]
      },
      "NoteExternalContextDto": {
        "type": "object",
        "properties": {
          "patient_id": {
            "type": "string",
            "description": "Caller-supplied patient identifier"
          },
          "encounter_id": {
            "type": "string",
            "description": "Caller-supplied encounter identifier"
          }
        }
      },
      "NoteResponseDto": {
        "type": "object",
        "properties": {
          "note": {
            "$ref": "#/components/schemas/NoteContentDto"
          },
          "template": {
            "$ref": "#/components/schemas/NoteTemplateDto"
          },
          "generation_metadata": {
            "$ref": "#/components/schemas/GenerationMetadataDto"
          },
          "transcript": {
            "description": "Transcript information when audio input was used",
            "allOf": [
              {
                "$ref": "#/components/schemas/TranscriptDto"
              }
            ]
          },
          "context": {
            "description": "Echo of external ids supplied on the request",
            "allOf": [
              {
                "$ref": "#/components/schemas/NoteExternalContextDto"
              }
            ]
          }
        },
        "required": [
          "note",
          "template",
          "generation_metadata"
        ]
      },
      "RegenerateSectionDto": {
        "type": "object",
        "properties": {
          "template_id": {
            "type": "string",
            "description": "Template UUID"
          },
          "section_heading": {
            "type": "string",
            "description": "Section heading to regenerate"
          },
          "conversation_text": {
            "type": "string",
            "description": "Source conversation / transcript text"
          },
          "current_section_content": {
            "type": "string",
            "description": "Existing section content to revise"
          },
          "instruction": {
            "type": "string",
            "description": "Extra instruction (e.g. \"make shorter\", \"add ROS detail\")"
          }
        },
        "required": [
          "template_id",
          "section_heading",
          "conversation_text"
        ]
      },
      "CreateTranscriptionDto": {
        "type": "object",
        "properties": {
          "audio": {
            "type": "string",
            "format": "binary",
            "description": "Audio file (WAV, MP3, M4A, etc.)"
          },
          "audioUrl": {
            "type": "string",
            "description": "URL to audio file (must be publicly accessible)",
            "example": "http://localhost:3000/audio/example.mp3"
          },
          "sourceLanguage": {
            "type": "string",
            "description": "Source language code or \"auto\" for automatic detection",
            "example": "en-US",
            "default": "auto"
          },
          "targetLanguage": {
            "type": "string",
            "description": "Target language for translation",
            "example": "es-ES"
          },
          "webhookPath": {
            "type": "string",
            "description": "Webhook endpoint path relative to project webhook URL",
            "example": "/webhooks/transcription",
            "default": "/webhooks/transcription"
          },
          "quality": {
            "type": "string",
            "description": "Quality setting for transcription",
            "enum": [
              "low",
              "medium",
              "high"
            ],
            "default": "high"
          },
          "speechProvider": {
            "type": "string",
            "description": "Speech infrastructure profile. Use `scribeberry-live` for Canadian-resident Toronto processing (memory-only); omit or use `standard` for existing project default.",
            "enum": [
              "standard",
              "scribeberry-live"
            ],
            "default": "standard"
          }
        }
      },
      "TranscriptionJobResponseDto": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "Unique session ID for this transcription",
            "example": "sess_550e8400-e29b-41d4-a716-446655440000"
          },
          "message": {
            "type": "string",
            "description": "Message indicating the job status",
            "example": "Transcription job accepted. Results will be sent to your webhook."
          }
        },
        "required": [
          "sessionId",
          "message"
        ]
      },
      "TranscriptionJobStatusDto": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "Unique session ID for this transcription",
            "example": "sess_550e8400-e29b-41d4-a716-446655440000"
          },
          "status": {
            "type": "string",
            "description": "Current status of the transcription job",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed"
            ],
            "example": "completed"
          },
          "createdAt": {
            "type": "string",
            "description": "When the job was created",
            "example": "2024-01-03T10:00:00.000Z"
          },
          "startedAt": {
            "type": "string",
            "description": "When the job started processing",
            "example": "2024-01-03T10:00:01.000Z"
          },
          "completedAt": {
            "type": "string",
            "description": "When the job completed or failed",
            "example": "2024-01-03T10:00:45.000Z"
          },
          "sourceType": {
            "type": "string",
            "description": "Source type of the audio",
            "enum": [
              "upload",
              "url"
            ],
            "example": "upload"
          },
          "sourceLanguage": {
            "type": "string",
            "description": "Source language code",
            "example": "en-US"
          },
          "targetLanguage": {
            "type": "string",
            "description": "Target language for translation",
            "example": "es-ES"
          },
          "duration": {
            "type": "number",
            "description": "Duration of the audio in seconds (if processed)",
            "example": 45.5
          },
          "webhookDelivery": {
            "type": "object",
            "description": "Webhook delivery status",
            "example": {
              "status": "delivered",
              "attempts": 1,
              "lastAttemptAt": "2024-01-03T10:00:46.000Z",
              "nextRetryAt": null,
              "error": null
            }
          },
          "error": {
            "type": "object",
            "description": "Error details if the job failed",
            "example": {
              "code": "AUDIO_PROCESSING_ERROR",
              "message": "Failed to process audio file"
            }
          },
          "metadata": {
            "type": "object",
            "description": "Additional metadata",
            "example": {
              "fileName": "recording.wav",
              "fileSize": 1048576,
              "quality": "high"
            }
          }
        },
        "required": [
          "sessionId",
          "status",
          "createdAt",
          "sourceType",
          "webhookDelivery"
        ]
      },
      "ToolExecutionRequestDto": {
        "type": "object",
        "properties": {
          "args": {
            "type": "object",
            "description": "Arguments to pass to the tool",
            "example": {
              "a": 5,
              "b": 3
            }
          },
          "context": {
            "type": "object",
            "description": "Execution context",
            "example": {
              "userId": "user123",
              "sessionId": "session456"
            }
          }
        },
        "required": [
          "args"
        ]
      },
      "ToolExecutionResponseDto": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the execution was successful"
          },
          "data": {
            "type": "object",
            "description": "Tool execution result"
          },
          "error": {
            "type": "string",
            "description": "Error message if execution failed"
          },
          "metadata": {
            "type": "object",
            "description": "Additional metadata"
          }
        },
        "required": [
          "success"
        ]
      },
      "AcceptInvitationDto": {
        "type": "object",
        "properties": {}
      },
      "UpdateSecuritySettingsDto": {
        "type": "object",
        "properties": {}
      },
      "UpdateFeaturesDto": {
        "type": "object",
        "properties": {}
      },
      "UpdateRateLimitsDto": {
        "type": "object",
        "properties": {}
      },
      "UpdateMonthlyLimitsDto": {
        "type": "object",
        "properties": {}
      },
      "UpdateGeneralProjectSettingsDto": {
        "type": "object",
        "properties": {}
      },
      "UpdateTranscriptionSettingsDto": {
        "type": "object",
        "properties": {}
      },
      "CreateRealtimeTokenBodyDto": {
        "type": "object",
        "properties": {
          "expiresInSeconds": {
            "type": "number",
            "description": "Token lifetime in seconds (default: 3600, max: 3600)",
            "default": 3600,
            "maximum": 3600
          }
        }
      },
      "CreateRealtimeTokenResponseDto": {
        "type": "object",
        "properties": {}
      },
      "CreateVisitJobDto": {
        "type": "object",
        "properties": {
          "template_id": {
            "type": "string",
            "description": "Template UUID for note generation"
          },
          "conversation_text": {
            "type": "string",
            "description": "Conversation text (optional with audio)"
          },
          "audioUrl": {
            "type": "string",
            "description": "HTTPS URL to audio file"
          },
          "context": {
            "$ref": "#/components/schemas/NoteContextDto"
          },
          "webhook_path": {
            "type": "string",
            "description": "Relative path appended to project webhook URL",
            "example": "/hooks/scribeberry"
          }
        },
        "required": [
          "template_id"
        ]
      },
      "JobStatusDto": {
        "type": "object",
        "properties": {
          "jobId": {
            "type": "string"
          },
          "jobType": {
            "type": "string",
            "enum": [
              "visit",
              "note",
              "transcription"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "processing",
              "completed",
              "failed"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "completedAt": {
            "type": "string"
          },
          "externalPatientId": {
            "type": "object"
          },
          "externalEncounterId": {
            "type": "object"
          },
          "result": {
            "type": "object"
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "jobId",
          "jobType",
          "status",
          "createdAt"
        ]
      }
    }
  },
  "externalDocs": {
    "description": "Find more info here",
    "url": "https://scribeberry.com"
  }
}