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

# Start a live consultation audio session

> Create a consultation and receive a WebSocket URL to stream the audio to. Body is `application/json` with the same metadata as the batch endpoint (`consultation`, `template`, `patient`, `context`); the `audio` block is not accepted. Stream to `live.url` as described on that field, then finish through the webhook + document GET contract shared with the batch endpoint. Retrying with the same consultation id while recording returns the same session with a fresh URL; finished consultations return 409.



## OpenAPI

````yaml /pt-BR/scribe-api/openapi.json post /v1/scribe-sessions/live
openapi: 3.1.0
info:
  title: Scribe Public API
  description: >-
    API REST externa para integração com a plataforma Telepatia. Autentique-se
    com chaves de API, defina o contexto da consulta e busque sessões de scribe.
  version: 0.1.0
servers:
  - url: https://scribe-api.telepatia.ai
    description: Production
security:
  - BearerAuth: []
paths:
  /v1/scribe-sessions/live:
    post:
      tags:
        - Scribe Sessions
      summary: Start a live consultation audio session
      description: >-
        Create a consultation and receive a WebSocket URL to stream the audio
        to. Body is `application/json` with the same metadata as the batch
        endpoint (`consultation`, `template`, `patient`, `context`); the `audio`
        block is not accepted. Stream to `live.url` as described on that field,
        then finish through the webhook + document GET contract shared with the
        batch endpoint. Retrying with the same consultation id while recording
        returns the same session with a fresh URL; finished consultations return
        409.
      operationId: api_scribe_session_live_init_v1_scribe_sessions_live_post
      requestBody:
        content:
          application/json:
            schema:
              properties:
                consultation:
                  $ref: '#/components/schemas/ConsultationInput'
                template:
                  $ref: '#/components/schemas/TemplateInput'
                patient:
                  $ref: '#/components/schemas/PatientInput'
                context:
                  anyOf:
                    - $ref: '#/components/schemas/ContextInput'
                    - type: 'null'
              type: object
              required:
                - consultation
                - template
                - patient
              title: IngestScribeSessionMetadata
              description: >-
                The consultation metadata: the multipart ``metadata`` part, or
                the JSON body.
              example:
                consultation:
                  id: CONSULT-12345
                  modality: IN_PERSON
                template:
                  id: mrc_a1b2c3d4e5f6g7h8
                patient:
                  id: sp_a1b2c3d4e5f6g7h8
                context:
                  notes: Patient reports headache since Monday.
                  pastMedicalHistory: Hypertension diagnosed 2020.
            example:
              consultation:
                id: CONSULT-12345
                modality: IN_PERSON
              template:
                id: mrc_a1b2c3d4e5f6g7h8
              patient:
                id: sp_a1b2c3d4e5f6g7h8
              context:
                notes: Patient reports headache since Monday.
                pastMedicalHistory: Hypertension diagnosed 2020.
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LiveScribeSessionResponse'
        '400':
          description: >-
            Requisição inválida — parâmetros inválidos, falhas de validação ou
            campos ausentes.
          content:
            application/json:
              examples:
                parameter_missing:
                  summary: Missing required field
                  value:
                    error:
                      type: invalid_request_error
                      code: parameter_missing
                      message: name is required.
                      param: name
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
                parameter_invalid:
                  summary: Invalid field value
                  value:
                    error:
                      type: invalid_request_error
                      code: parameter_invalid
                      message: >-
                        idCountry must be a valid country name, ISO alpha-2, or
                        ISO alpha-3 code.
                      param: idCountry
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
                account_invalid:
                  summary: Invalid account
                  value:
                    error:
                      type: invalid_request_error
                      code: account_invalid
                      message: Account has no valid authId.
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Não autorizado — chave de API ausente ou inválida.
          content:
            application/json:
              examples:
                authentication_required:
                  summary: Invalid or missing API key
                  value:
                    error:
                      type: authentication_error
                      code: authentication_required
                      message: Invalid API key.
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Proibido — a chave de API não pode executar esta operação.
          content:
            application/json:
              examples:
                permission_denied:
                  summary: Caller lacks permission for this resource
                  value:
                    error:
                      type: permission_error
                      code: permission_denied
                      message: You do not have permission to access this resource.
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
                permission_denied_role:
                  summary: API key's account role is not allowed this operation
                  value:
                    error:
                      type: permission_error
                      code: permission_denied
                      message: >-
                        Your API key is not allowed to create accounts. Account
                        creation requires an institutional API key; this key is
                        scoped to a doctor account.
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Não encontrado — o recurso solicitado não existe.
          content:
            application/json:
              examples:
                resource_not_found:
                  summary: Resource not found
                  value:
                    error:
                      type: invalid_request_error
                      code: resource_not_found
                      message: No session scribe found for the given consultation ID.
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflito — o recurso já existe ou está em estado conflitante.
          content:
            application/json:
              examples:
                resource_conflict:
                  summary: Resource conflict
                  value:
                    error:
                      type: invalid_request_error
                      code: resource_conflict
                      message: >-
                        consultationInternalId is already in use by a different
                        consultation.
                      param: consultationInternalId
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: Content Too Large
          content:
            application/json:
              examples:
                request_too_large:
                  summary: Uploaded file exceeds the maximum size
                  value:
                    error:
                      type: invalid_request_error
                      code: request_too_large
                      message: The audio file exceeds the maximum supported size.
                      param: audio_file
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Serviço indisponível — uma dependência externa está indisponível.
          content:
            application/json:
              examples:
                service_unavailable:
                  summary: External service unavailable
                  value:
                    error:
                      type: api_error
                      code: service_unavailable
                      message: >-
                        The service is temporarily unavailable. Please try again
                        later.
                      requestId: 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    ConsultationInput:
      properties:
        id:
          type: string
          maxLength: 128
          pattern: ^[a-zA-Z0-9_-]{1,128}$
          title: Id
          description: Your consultation id, the key for every follow-up GET and webhook.
          examples:
            - CONSULT-12345
        modality:
          anyOf:
            - type: string
              enum:
                - IN_PERSON
                - TELEMEDICINE
            - type: 'null'
          title: Modality
          examples:
            - IN_PERSON
      type: object
      required:
        - id
      title: ConsultationInput
      description: The caller's consultation reference.
    TemplateInput:
      properties:
        id:
          anyOf:
            - type: string
              maxLength: 128
            - type: 'null'
          title: Id
          description: >-
            Public id of an existing template, self-describing by prefix: `mrc_`
            (medicalRecordConfiguration) or `ssc_` (scribeSessionConfiguration).
          examples:
            - mrc_a1b2c3d4e5f6g7h8
        sections:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Sections
          description: >-
            Inline structured template keyed by section name (e.g.
            'chiefComplaint'). Auto-persisted and deduplicated by content hash.
            Mutually exclusive with `id`.
      type: object
      title: TemplateInput
      description: >-
        Template selection: an existing public id xor an inline structured
        template.
    PatientInput:
      properties:
        id:
          anyOf:
            - type: string
              pattern: ^sp_[a-z0-9]{16}$
            - type: 'null'
          title: Id
          description: >-
            Public id of an existing patient (sp_...). Mutually exclusive with
            the inline identity.
          examples:
            - sp_a1b2c3d4e5f6g7h8
        name:
          anyOf:
            - type: string
              maxLength: 500
              minLength: 1
            - type: 'null'
          title: Name
          examples:
            - John Doe
        document:
          anyOf:
            - $ref: '#/components/schemas/PatientDocument'
            - type: 'null'
      type: object
      title: PatientInput
      description: An existing patient by public id xor the inline identity.
    ContextInput:
      properties:
        notes:
          anyOf:
            - type: string
              maxLength: 10000
            - type: 'null'
          title: Notes
          examples:
            - Patient reports headache since Monday.
        pastMedicalHistory:
          anyOf:
            - type: string
              maxLength: 10000
            - type: 'null'
          title: Pastmedicalhistory
          examples:
            - Hypertension diagnosed 2020.
      type: object
      title: ContextInput
      description: Free-text context that feeds record generation.
    LiveScribeSessionResponse:
      properties:
        consultation:
          $ref: '#/components/schemas/ConsultationRef'
        status:
          type: string
          const: created
          title: Status
          description: >-
            Always `created` on success. Stream the audio to `live.url`;
            completion then follows the batch contract described on `status`
            above.
          default: created
        live:
          $ref: '#/components/schemas/LiveSessionInfo'
      type: object
      required:
        - consultation
        - live
      title: LiveScribeSessionResponse
      description: '201 response: the batch envelope plus the streaming URL.'
      examples:
        - consultation:
            id: CONSULT-12345
          live:
            expiresAt: '2026-08-12T14:00:00+00:00'
            url: wss://example.telepatia.ai/v1/ws/audio/abc?token=...
          status: created
    ErrorResponse:
      description: Envelope padronizado de resposta de erro.
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetailWithRequestId'
      required:
        - error
      title: ErrorResponse
      type: object
    PatientDocument:
      properties:
        country:
          $ref: '#/components/schemas/IdCountry'
          examples:
            - BR
        type:
          $ref: '#/components/schemas/IdType'
          examples:
            - CPF
        value:
          type: string
          maxLength: 50
          minLength: 1
          title: Value
          examples:
            - 123.456.789-00
      type: object
      required:
        - country
        - type
        - value
      title: PatientDocument
      description: >-
        The patient's identity document (same enums and rules as the rest of the
        API).
    ConsultationRef:
      properties:
        id:
          type: string
          title: Id
          examples:
            - CONSULT-12345
      type: object
      required:
        - id
      title: ConsultationRef
      description: Echo of the caller's consultation reference.
    LiveSessionInfo:
      properties:
        url:
          type: string
          title: Url
          description: >-
            Opaque wss URL to stream the audio to. Connect, send binary audio
            frames (PCM 16 kHz mono s16le, or Ogg/WebM Opus), then send
            `{"type": "stop_recording", "data": {}}`. Reconnecting to the same
            URL resumes the session.
          examples:
            - wss://example.telepatia.ai/v1/ws/audio/abc?token=...
        expiresAt:
          type: string
          title: Expiresat
          description: >-
            ISO 8601 instant after which the URL's credential is no longer
            valid.
          examples:
            - '2026-08-12T14:00:00+00:00'
      type: object
      required:
        - url
        - expiresAt
      title: LiveSessionInfo
      description: Where and until when the caller can stream the consultation audio.
    ErrorDetailWithRequestId:
      description: >-
        Top-level error object: :class:`ErrorDetail` plus the request
        correlation id.


        Kept as a subclass rather than a field on ``ErrorDetail`` because
        ``ErrorDetail`` is

        also the per-item error shape inside the batch account-creation response

        (``BatchAccountResult.error``), which is serialized with nulls included.
        Adding the

        field there would publish ``"requestId": null`` on an HTTP 200, and
        there is only

        ever one request id per batch anyway -- batch callers read the
        ``X-Request-ID``

        response header.
      properties:
        type:
          description: Broad error category for high-level handling.
          examples:
            - invalid_request_error
          title: Type
          type: string
        code:
          description: Machine-readable error code. Clients should switch on this value.
          examples:
            - parameter_invalid
          title: Code
          type: string
        message:
          description: Human-readable error message ending with a period.
          examples:
            - >-
              idCountry must be a valid country name, ISO alpha-2, or ISO
              alpha-3 code.
          title: Message
          type: string
        param:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: The request field that caused the error, if applicable.
          examples:
            - idCountry
          title: Param
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          description: Optional structured, machine-readable context for the error.
          examples:
            - pendingConsultations:
                - sessionId: abc123
                  url: https://...
          title: Details
        requestId:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Unique id for this request, identical to the X-Request-ID response
            header. Quote it when contacting support.
          examples:
            - 3f9a1c2e-5b7d-4a21-9f0c-8e6d4b2a1c30
          title: Requestid
      required:
        - type
        - code
        - message
      title: ErrorDetailWithRequestId
      type: object
    IdCountry:
      type: string
      enum:
        - AF
        - AX
        - AL
        - DZ
        - AS
        - AD
        - AO
        - AI
        - AQ
        - AG
        - AR
        - AM
        - AW
        - AU
        - AT
        - AZ
        - BS
        - BH
        - BD
        - BB
        - BY
        - BE
        - BZ
        - BJ
        - BM
        - BT
        - BO
        - BQ
        - BA
        - BW
        - BV
        - BR
        - IO
        - BN
        - BG
        - BF
        - BI
        - KH
        - CM
        - CA
        - CV
        - KY
        - CF
        - TD
        - CL
        - CX
        - CC
        - CO
        - KM
        - CK
        - CR
        - CI
        - HR
        - CU
        - CW
        - CY
        - CZ
        - CD
        - DK
        - DJ
        - DM
        - DO
        - EC
        - EG
        - SV
        - GQ
        - ER
        - EE
        - SZ
        - ET
        - FK
        - FO
        - FJ
        - FI
        - FR
        - GF
        - PF
        - TF
        - GA
        - GE
        - DE
        - GH
        - GI
        - GR
        - GL
        - GD
        - GP
        - GU
        - GT
        - GG
        - GN
        - GW
        - GY
        - HT
        - HM
        - VA
        - HN
        - HK
        - HU
        - IS
        - IN
        - ID
        - IQ
        - IE
        - IR
        - IM
        - IL
        - IT
        - JM
        - JP
        - JE
        - JO
        - KZ
        - KE
        - KI
        - XK
        - KW
        - KG
        - LA
        - LV
        - LB
        - LS
        - LR
        - LY
        - LI
        - LT
        - LU
        - MO
        - MG
        - MW
        - MY
        - MV
        - ML
        - MT
        - MH
        - MQ
        - MR
        - MU
        - YT
        - MX
        - FM
        - MD
        - MC
        - MN
        - ME
        - MS
        - MA
        - MZ
        - MM
        - NA
        - NR
        - NP
        - NL
        - NC
        - NZ
        - NI
        - NE
        - NG
        - NU
        - NF
        - KP
        - MP
        - 'NO'
        - OM
        - PK
        - PW
        - PA
        - PG
        - PY
        - CN
        - PE
        - PH
        - PN
        - PL
        - PT
        - PR
        - QA
        - CG
        - GM
        - RE
        - RO
        - RU
        - RW
        - BL
        - SH
        - KN
        - LC
        - MF
        - PM
        - VC
        - WS
        - SM
        - ST
        - SA
        - SN
        - RS
        - SC
        - SL
        - SG
        - SX
        - SK
        - SI
        - SB
        - SO
        - ZA
        - GS
        - KR
        - SS
        - ES
        - LK
        - PS
        - SD
        - SR
        - SJ
        - SE
        - CH
        - SY
        - TW
        - TJ
        - TH
        - MK
        - TL
        - TG
        - TK
        - TO
        - TT
        - TN
        - TR
        - TM
        - TC
        - TV
        - UG
        - UA
        - AE
        - GB
        - TZ
        - UM
        - US
        - UY
        - UZ
        - VU
        - VE
        - VN
        - VG
        - VI
        - WF
        - EH
        - YE
        - ZM
        - ZW
      title: IdCountry
      description: ISO 3166-1 alpha-2 country codes. Mirrors tanjiro's CountryCodes enum.
    IdType:
      type: string
      enum:
        - CC
        - TI
        - CE
        - RC
        - PASSPORT
        - RG
        - CPF
        - OTHER_DOC
      title: IdType
      description: Tipos de documento de identificação do paciente suportados.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Chave de API enviada como token Bearer

````