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

# Reference

> init() options, methods, callbacks, and errors

## init() options

Grouped by topic; everything is optional. `window.TelepatiaRecorderConfig` (set
before the script loads) accepts the same fields, and `init()` wins when both
set one.

| Field                                   | Value                                                                 |
| --------------------------------------- | --------------------------------------------------------------------- |
| `settings.locale` · `settings.branding` | `"en"·"es"·"pt"` · name shown in the panel                            |
| `patient.name`                          | display name                                                          |
| `patient.idCountry · idType · idValue`  | identity — registers the patient on start (e.g. `CO · CC · 55544433`) |
| `template.medicalRecordConfigurationId` | smart template (`mrc_…`)                                              |
| `template.configurationDocumentId`      | selected template (SSC)                                               |
| `consultation.scribeSessionModality`    | `"in-person"` · `"telemedicine"`                                      |
| `consultation.externalConsultationId`   | your encounter id — always pass it                                    |
| `open` · `callbacks`                    | open the panel now · lifecycle callbacks                              |

Endpoint overrides (`baseUrl`, `data-*`) exist for white-label setups only; you
normally set nothing here.

## TelepatiaRecorder methods

| Method              | Does                                                                                                     |
| ------------------- | -------------------------------------------------------------------------------------------------------- |
| `init(config?)`     | mounts and opens (overlay); collapsed in launcher mode unless `open: true`. Safe to call on every click. |
| `show()` / `hide()` | expand / collapse a panel that's already mounted                                                         |
| `destroy()`         | tears down the Shadow DOM                                                                                |
| `version`           | loaded bundle version (e.g. `"0.2.0"`)                                                                   |

After the panel mounts, a new `init()` applies only `open` and `callbacks`;
other fields take effect after `destroy()` then `init()`.

## Callbacks and errors

Register them in `init({ callbacks })`: `onSessionStart(id)`,
`onSessionComplete(event)`, `onError(message)`, `onStateChange(state)`. The
browser `onSessionComplete` is optional — the webhook is the reliable trigger.
Health signals fire on `window`:

```js theme={null}
window.addEventListener("telepatia-recorder-health", (e) => {
  // e.detail.type: "page-hidden" | "pagehide" | "microphone-denied"
});
```

Backend fetch errors use Telepatia's standard format — switch on `code`:
`authentication_required` (401, key invalid or expired), `resource_not_found`
(404, wrong id or fetched too early), `resource_conflict` (409, id reused),
`rate_limit_exceeded` (429). The full table is on the Scribe API errors page.
