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

# Create or resume a consultation

> Set up the patient and session in one idempotent request.

Create or resume a patient and consultation in one request, using your EHR's
external IDs. Requires `scribe:write`.

## Open the encounter

`POST /workflows/session`

```bash theme={null}
curl --request POST "$CORTEXA_API_BASE/workflows/session" \
  --header "Authorization: Bearer $CORTEXA_JWT" \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: synthetic-visit-001-open' \
  --data '{
    "patient": {"external_patient_id":"synthetic-patient-001","name":"Synthetic Patient"},
    "session": {"external_session_id":"synthetic-visit-001","title":"Follow-up"}
  }'
```

The `200` response contains `patient`, `session`, and `resumed`. Store the returned
`patient.id` and `session.id`. `resumed: false` means this request created the
session; `true` means it found an existing one.

| Field | Description |
| - | - |
| `patient` | The same body as [patient creation](/developers/patients.md). The external ID and name are required. Omitted optional fields keep their existing values. |
| `session` | The same body as [session creation](/developers/sessions.md). `external_session_id` is required. |
| `session_id` | Optional explicit Cortexa session to resume. Its external ID and patient must match. |
| `Idempotency-Key` | A stable key for this opening action. Reuse it when retrying the identical request. |

## Resume an existing session

On resume, supplied patient fields are updated and session settings are preserved.
Use `PATCH /sessions/{session_id}` to change the title, background, or language.
A conflicting patient or external session ID returns `409` without saving changes.

Reusing an idempotency key returns the original response, including `resumed`.
Use a new key for a new opening action and the same grant for the encounter.

## Continue the consultation

Add [history](/developers/context.md), [transcript text](/developers/transcripts.md), or [audio](/developers/segmented-transcription.md),
then [stream a note](/developers/streaming.md).


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