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

# Set Consultation Context

> Copy into Cursor/Claude/Copilot to scaffold a POST /v1/set-consultation-context integration.

Drop this prompt into your AI coding assistant. It already includes the contract, auth, and error envelope so the generated code matches the production API.

<CodeGroup>
  ```text Prompt theme={null}
  You are integrating Telepatia Synapse Public API.

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

  Request:
  - name [body]: string (optional, minLength=1, maxLength=500)
  - idCountry [body]: string (optional, enum: 250 values) — ISO 3166-1 alpha-2 country codes. Mirrors tanjiro's CountryCodes enum.
  - idType [body]: string (optional, enum: 8 values) — Supported patient identification document types.
  - idValue [body]: string (optional, minLength=1, maxLength=50)
  - patientId [body]: string (optional, 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.
  - notes [body]: string (optional, maxLength=10000)
  - pastMedicalHistory [body]: string (optional, maxLength=10000)
  - consultationInternalId [body]: string (optional, pattern=^[a-zA-Z0-9_-]{1,128}$, maxLength=128)
  - scribeSessionModality [body]: string (optional, enum: IN_PERSON, TELEMEDICINE) — Supported scribe session modalities.
  - scribeSessionConfigurationId [body]: string (optional, maxLength=128)
  - medicalRecordConfigurationId [body]: string (optional, maxLength=128)
  - medicalRecordConfiguration [body]: object (optional) — 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`.

  Success 200:
  - success: boolean
  - consultationInternalId: string

  Errors (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

  Generate code in the language of the current file that:
  1. Reads SYNAPSE_API_KEY from env (do not hardcode it).
  2. Calls the endpoint with typed request and response.
  3. Maps the error envelope to typed exceptions per status code.
  4. Adds one happy-path test using the Bearer token.
  ```

  ```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",
    "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>
