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

> Copie para o Cursor/Claude/Copilot para gerar uma integração POST /v1/set-consultation-context.

Cole este prompt no seu assistente de programação com IA. Ele já inclui o contrato, a autenticação e o envelope de erros, para que o código gerado corresponda à API de produção.

<CodeGroup>
  ```text Prompt theme={null}
  Você está integrando a API pública da Telepatia Synapse.

  Endpoint: POST /v1/set-consultation-context
  Base URL: https://scribe-api.telepatia.ai
  Auth: Authorization: Bearer ${SYNAPSE_API_KEY}

  Requisição:
  - name [body]: string (opcional, minLength=1, maxLength=500)
  - idCountry [body]: string (opcional, enum: 250 values) — ISO 3166-1 alpha-2 country codes. Mirrors tanjiro's CountryCodes enum.
  - idType [body]: string (opcional, enum: 8 values) — Tipos de documento de identificação do paciente suportados.
  - idValue [body]: string (opcional, minLength=1, maxLength=50)
  - patientId [body]: string (opcional, pattern=^sp_[a-z0-9]{16}$) — 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.
  - internalCode [body]: string (opcional, minLength=1, maxLength=128) — Your own patient code, unique per institution. Looks up an existing patient by this code; when none matches, the inline identity (name, idCountry, idType, idValue) creates and tags the patient at session start. Mutually exclusive with patientId.
  - notes [body]: string (opcional, maxLength=10000)
  - pastMedicalHistory [body]: string (opcional, maxLength=10000)
  - consultationInternalId [body]: string (opcional, pattern=^[a-zA-Z0-9_-]{1,128}$, maxLength=128)
  - scribeSessionModality [body]: string (opcional, enum: IN_PERSON, TELEMEDICINE, DICTATION) — Modalidades de sessão de scribe suportadas.
  - institutionalBranchId [body]: string (opcional, maxLength=128) — Id of the institution branch for this consultation, returned by the create-branch endpoint. Stamped onto the scribe session at creation. Provide the id or the name.
  - institutionalBranch [body]: string (opcional, maxLength=256) — Name of the institution branch for this consultation. Resolved when institutionalBranchId is not provided. Provide the id or the name.
  - scribeSessionConfigurationId [body]: string (opcional, maxLength=128) — Public id of a scribe session configuration (`ssc_` + 16 chars `[a-z0-9]`). Mutually exclusive with `medicalRecordConfigurationId` and `medicalRecordConfiguration`.
  - medicalRecordConfigurationId [body]: string (opcional, maxLength=128) — Public id of a medical record configuration (`mrc_` + 16 chars `[a-z0-9]`). Mutually exclusive with `scribeSessionConfigurationId` and `medicalRecordConfiguration`.
  - medicalRecordConfiguration [body]: object (opcional) — 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`.

  Sucesso 200:
  - success: boolean
  - consultationInternalId: string

  Erros (envelope: { error: { type, code, message, param? } }):
  - 400: parameter_missing, parameter_invalid, account_invalid
  - 401: authentication_required
  - 404: resource_not_found
  - 409: resource_conflict, resource_not_active
  - 503: service_unavailable

  Gere código na linguagem do arquivo atual que:
  1. Leia SYNAPSE_API_KEY do ambiente (não fixe o valor no código).
  2. Chame o endpoint com requisição e resposta tipadas.
  3. Mapeie o envelope de erros para exceções tipadas por código de status.
  4. Adicione um teste de caminho feliz usando o token Bearer.
  ```

  ```bash curl theme={null}
  curl -X POST https://scribe-api.telepatia.ai/v1/set-consultation-context \
    -H "Authorization: Bearer $SYNAPSE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "consultationInternalId": "CONSULT-12345",
    "idCountry": "COLOMBIA",
    "idType": "PASSPORT",
    "idValue": "A12345678",
    "institutionalBranchId": "b1f2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
    "internalCode": "MRN-000123",
    "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"
  }'
  ```
</CodeGroup>
