> ## Documentation Index
> Fetch the complete documentation index at: /developers/llms.txt
> Use this file to discover all available pages before exploring further.

# How an integration works

> Connect a clinician, prepare a consultation, and return a reviewed note to your EHR.

A typical integration connects the clinician once, then creates a session for
each consultation.

## Connect a clinician

```mermaid theme={null}
sequenceDiagram
    participant C as Clinician
    participant E as Your application
    participant A as Cortexa app
    participant S as Cortexa API
    C->>E: Connect Cortexa
    E->>A: Open authorization link with clinician ID
    C->>A: Sign in and choose a workspace
    A-->>E: Callback with code and state
    E->>S: API key + authorization code
    S-->>E: Partner JWT + grant ID
```

Save the returned `grant_id` for the clinician and workspace. Your backend uses it
with the API key to renew access tokens. The clinician only needs to reconnect
when authorization is no longer valid. See [Authentication](/developers/authentication.md).

## Run a consultation

**1. Open the patient and session**

Send your patient and encounter IDs to the [session workflow](/developers/session-workflow.md).
It creates or resumes the consultation and returns Cortexa IDs for later requests.

**2. Add clinical input**

Submit transcript text or audio and add relevant [history and reports](/developers/context.md).
Wait for transcription and any required attachments to finish processing.

**3. Generate the note**

Choose a [template](/developers/templates.md) and request a [consult note](/developers/notes.md).
Process incoming `output.delta` text. The final `output.ready` event contains
the saved document.

**4. Review and save**

Let the clinician review the draft. [Save edits](/developers/documents.md#save-an-edit) in
Cortexa, then write the reviewed result through your EHR API or an
[approved connector call](/developers/connectors.md).

## Choose an input path

| Input | Use | Ready when |
| - | - | - |
| Transcript text | [Transcript segments](/developers/transcripts.md) | The final batch is submitted |
| Complete recording | [Recording uploads](/developers/recordings.md) | The transcription job succeeds |
| Audio recorded during the consultation | [Segmented transcription](/developers/segmented-transcription.md) | All chunks are uploaded and finish succeeds |

## Keep the IDs you will need

| ID | Source | Use |
| - | - | - |
| `grant_id` | Token response | Renew the clinician's token |
| Patient `id` | Patient or workflow response | Link consultations to the patient |
| Session `id` | Session or workflow response | Add inputs and retrieve outputs |
| `document_ids` | Generation stream or receipt | Retrieve and edit outputs |
| `job_id` / `job_ids` | Processing receipt or stream | Check background work |
| `current_version` | Saved document | Submit edits as `base_version` |

Use the same grant throughout the consultation. A different grant cannot access
its patients or sessions, even under the same application.

> [card] [Generate your first note](/developers/quickstart.md)
>
> Try the complete flow with a synthetic transcript and cURL.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.