> ## 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.

# Definir contexto da consulta

> Define o contexto da consulta para uma sessão do paciente.



## OpenAPI

````yaml /pt-BR/scribe-api/openapi.json post /v1/set-consultation-context
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/set-consultation-context:
    post:
      tags:
        - Consultation
      summary: Definir contexto da consulta
      description: Define o contexto da consulta para uma sessão do paciente.
      operationId: api_consultation_context_set_post_v1_set_consultation_context_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetConsultationContextRequest'
            example:
              consultationInternalId: CONSULT-12345
              idCountry: COLOMBIA
              idType: PASSPORT
              idValue: A12345678
              medicalRecordConfigurationId: mrc_a1b2c3d4e5f6g7h8
              name: John Doe
              notes: Patient prefers morning appointments. Allergic to penicillin.
              pastMedicalHistory: >-
                Hypertension diagnosed 2020. Diabetes Type 2 controlled with
                metformin.
              scribeSessionModality: IN_PERSON
        required: true
      responses:
        '200':
          description: Resposta bem-sucedida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetConsultationContextResponse'
              example:
                consultationInternalId: CONSULT-12345
                success: true
        '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
                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
                account_invalid:
                  summary: Invalid account
                  value:
                    error:
                      type: invalid_request_error
                      code: account_invalid
                      message: Account has no valid authId.
              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.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Não encontrado — o recurso solicitado não existe.
          content:
            application/json:
              examples:
                resource_not_found:
                  summary: Medical record configuration not found
                  value:
                    error:
                      type: invalid_request_error
                      code: resource_not_found
                      message: Medical record configuration not found.
                      param: medicalRecordConfigurationId
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflito — o recurso já existe ou está em estado conflitante.
          content:
            application/json:
              examples:
                resource_conflict:
                  summary: consultationInternalId already in use
                  value:
                    error:
                      type: invalid_request_error
                      code: resource_conflict
                      message: >-
                        consultationInternalId is already in use by a different
                        consultation.
                      param: consultationInternalId
                resource_not_active:
                  summary: Medical record configuration exists but is not active
                  value:
                    error:
                      type: invalid_request_error
                      code: resource_not_active
                      message: >-
                        Medical record configuration 'mrc_a1b2c3d4e5f6g7h8' is
                        not active yet.
                      param: medicalRecordConfigurationId
              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: Failed to set consultation context
                  value:
                    error:
                      type: api_error
                      code: service_unavailable
                      message: >-
                        Failed to set consultation context. Please try again
                        later.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    SetConsultationContextRequest:
      properties:
        name:
          anyOf:
            - type: string
              maxLength: 500
              minLength: 1
            - type: 'null'
          title: Name
          examples:
            - John Doe
        idCountry:
          anyOf:
            - $ref: '#/components/schemas/IdCountry'
            - type: 'null'
          examples:
            - CO
        idType:
          anyOf:
            - $ref: '#/components/schemas/IdType'
            - type: 'null'
          examples:
            - CC
        idValue:
          anyOf:
            - type: string
              maxLength: 50
              minLength: 1
            - type: 'null'
          title: Idvalue
          examples:
            - '123456789'
        patientId:
          anyOf:
            - type: string
              pattern: ^sp_[a-z0-9]{16}$
            - type: 'null'
          title: Patientid
          description: >-
            Public id of an existing patient (sp_...). When provided, the
            patient's stored identity is used and the inline identity fields
            (name, idCountry, idType, idValue) must be omitted. Mutually
            exclusive with the inline identity.
          examples:
            - sp_a1b2c3d4e5f6g7h8
        notes:
          anyOf:
            - type: string
              maxLength: 10000
            - type: 'null'
          title: Notes
          examples:
            - Patient reports headache
        pastMedicalHistory:
          anyOf:
            - type: string
              maxLength: 10000
            - type: 'null'
          title: Pastmedicalhistory
          examples:
            - Hypertension, Diabetes Type 2
        consultationInternalId:
          anyOf:
            - type: string
              maxLength: 128
              pattern: ^[a-zA-Z0-9_-]{1,128}$
            - type: 'null'
          title: Consultationinternalid
          examples:
            - CONSULT-12345
        scribeSessionModality:
          anyOf:
            - $ref: '#/components/schemas/ScribeSessionModality'
            - type: 'null'
          examples:
            - IN_PERSON
        scribeSessionConfigurationId:
          anyOf:
            - type: string
              maxLength: 128
            - type: 'null'
          title: Scribesessionconfigurationid
          examples:
            - ssc_a1b2c3d4e5f6g7h8
        medicalRecordConfigurationId:
          anyOf:
            - type: string
              maxLength: 128
            - type: 'null'
          title: Medicalrecordconfigurationid
          examples:
            - mrc_a1b2c3d4e5f6g7h8
        medicalRecordConfiguration:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Medicalrecordconfiguration
          description: >-
            Inline medical record configuration JSON keyed by section name (e.g.
            'chiefComplaint'). Auto-persisted and deduplicated by content hash;
            the resolved configuration id is attached to the doctor context
            buffer. Mutually exclusive with `medicalRecordConfigurationId` and
            `scribeSessionConfigurationId`.
      type: object
      title: SetConsultationContextRequest
      description: Corpo da requisição para definir o contexto da consulta.
      examples:
        - consultationInternalId: CONSULT-12345
          idCountry: COLOMBIA
          idType: PASSPORT
          idValue: A12345678
          medicalRecordConfigurationId: mrc_a1b2c3d4e5f6g7h8
          name: John Doe
          notes: Patient prefers morning appointments. Allergic to penicillin.
          pastMedicalHistory: >-
            Hypertension diagnosed 2020. Diabetes Type 2 controlled with
            metformin.
          scribeSessionModality: IN_PERSON
        - consultationInternalId: CONSULT-12345
          idCountry: COLOMBIA
          idType: PASSPORT
          idValue: A12345678
          medicalRecordConfiguration:
            chiefComplaint:
              instructionSet:
                telepatiaPromptId: CHIEF_COMPLAINT
              schema:
                instructions: Chief complaint
                properties:
                  chiefComplaint:
                    instructions: Patient's own words
                    type: string
                type: object
          name: John Doe
          scribeSessionModality: IN_PERSON
        - consultationInternalId: CONSULT-12345
          idCountry: COLOMBIA
          idType: PASSPORT
          idValue: A12345678
          name: John Doe
          scribeSessionConfigurationId: ssc_a1b2c3d4e5f6g7h8
          scribeSessionModality: IN_PERSON
        - consultationInternalId: CONSULT-12345
          patientId: sp_a1b2c3d4e5f6g7h8
          scribeSessionConfigurationId: ssc_a1b2c3d4e5f6g7h8
          scribeSessionModality: IN_PERSON
    SetConsultationContextResponse:
      properties:
        success:
          type: boolean
          title: Success
          examples:
            - true
        consultationInternalId:
          type: string
          title: Consultationinternalid
          examples:
            - CONSULT-12345
      type: object
      required:
        - success
        - consultationInternalId
      title: SetConsultationContextResponse
      description: Corpo da resposta para definição do contexto da consulta.
      examples:
        - consultationInternalId: CONSULT-12345
          success: true
    ErrorResponse:
      description: Envelope padronizado de resposta de erro.
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      title: ErrorResponse
      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.
    ScribeSessionModality:
      type: string
      enum:
        - IN_PERSON
        - TELEMEDICINE
      title: ScribeSessionModality
      description: Modalidades de sessão de scribe suportadas.
    ErrorDetail:
      description: >-
        Detalhe do erro com códigos legíveis por máquina e mensagem legível por
        humanos.
      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
      required:
        - type
        - code
        - message
      title: ErrorDetail
      type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Chave de API enviada como token Bearer

````