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.
- clinicalContext [body]: object (opcional) — Dados clínicos estruturados do paciente e do atendimento: alergias, medicamentos, condições, o atendimento atual e os atendimentos anteriores. Veja /pt-BR/scribe-api/consultations#contexto-clínico.
- 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
- 403: permission_denied, permission_denied_role
- 404: resource_not_found
- 409: resource_conflict, resource_not_active
- 413: request_too_large
- 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.
curl -X POST https://scribe-api.telepatia.ai/v1/set-consultation-context \
-H "Authorization: Bearer $SYNAPSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"clinicalContext": {
"allergies": [
{
"code": {
"system": "ATC",
"value": "J01CE01"
},
"id": "ALG-881",
"name": "Penicillin",
"note": "Hives and facial swelling"
}
],
"conditions": [
{
"code": {
"system": "ICD10",
"value": "I10"
},
"id": "CD-120",
"name": "Essential hypertension"
},
{
"code": {
"system": "ICD10",
"value": "E11"
},
"id": "CD-121",
"name": "Type 2 diabetes mellitus"
}
],
"currentEncounter": {
"chiefComplaint": "Severe headache for 2 days, worse in the morning",
"class": "EMERGENCY",
"diagnoses": [
{
"code": {
"system": "ICD10",
"value": "R51"
},
"id": "DG-9001-1",
"name": "Headache"
}
],
"id": "ATD-9001",
"note": "08:50 triage: alert and oriented, no focal deficit. 09:20 ER physician: head CT ordered.",
"procedures": [
{
"id": "PX-9001-1",
"name": "Head CT without contrast"
}
],
"startedAt": "2026-10-15T08:40:00-05:00",
"triagePriority": "Yellow - urgent",
"vitals": {
"diastolicBloodPressure": 102,
"heartRate": 92,
"measuredAt": "2026-10-15T08:55:00-05:00",
"oxygenSaturation": 97,
"painScore": 8,
"respiratoryRate": 18,
"systolicBloodPressure": 168,
"temperature": 36.8
}
},
"medications": [
{
"code": {
"system": "ATC",
"value": "C09CA01"
},
"id": "RX-4410",
"name": "Losartan 50 mg, 1 tablet daily"
},
{
"code": {
"system": "ATC",
"value": "A10BA02"
},
"id": "RX-4411",
"name": "Metformin 850 mg, 1 tablet every 12 hours"
},
{
"code": {
"system": "ATC",
"value": "C07AA05"
},
"id": "RX-4412",
"name": "Propranolol 40 mg, 1 tablet every 12 hours"
},
{
"id": "RX-3982",
"name": "Captopril 25 mg",
"status": "INACTIVE"
}
],
"previousEncounters": [
{
"diagnoses": [
{
"code": {
"system": "ICD10",
"value": "G43.0"
},
"id": "DG-7120-1",
"name": "Migraine without aura"
}
],
"id": "ATD-7120",
"note": "Neurology visit. Started propranolol 40 mg every 12 hours. Follow-up in 3 months.",
"startedAt": "2025-05-02"
},
{
"class": "EMERGENCY",
"diagnoses": [
{
"code": {
"system": "ICD10",
"value": "N39.0"
},
"id": "DG-6044-1",
"name": "Urinary tract infection"
}
],
"id": "ATD-6044",
"note": "Emergency room. Dysuria for 3 days, no fever. Nitrofurantoin for 7 days.",
"startedAt": "2024-11-18"
}
]
},
"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"
}'