# Create and Manage Patients

URL: https://docs.clinia.com/docs/patients/create-and-manage-patients

> Create, get, list and delete the patients of a Context Engine workspace.

Every submission, session and read in the Context Engine targets a patient, so you need to create the patient first. Each patient is identified by a patient ID that you choose, as described in [Patient Records and Identifiers](https://docs.clinia.com/docs/patients/patient-records-and-identifiers).

## Before you start [#before-you-start]

You need a workspace access token with the `write` scope to create or delete patients and the `read` scope to get or list them, as described in [Authentication and Credentials](https://docs.clinia.com/docs/platform/authentication-and-credentials).

## Create a patient [#create-a-patient]

```bash
curl -X PUT "https://<workspace-id>.w.clinia.cloud/v1/patients/{patientId}" \
  -H "Authorization: Bearer <access-token>"
```

The [create call](https://docs.clinia.com/api/rest/put-patients-patientId) is idempotent, which means calling it for an existing patient returns that patient unchanged.

A new patient ID that uses characters outside the [allowed set](https://docs.clinia.com/api/identifiers#identifiers-you-assign) returns a `400`.

## Get a patient [#get-a-patient]

```bash
curl "https://<workspace-id>.w.clinia.cloud/v1/patients/{patientId}" \
  -H "Authorization: Bearer <access-token>"
```

The [response](https://docs.clinia.com/api/rest/get-patients-patientId) holds the patient's demographic information, read from its records, and counts of its facts, clinical events and relationships. A `404` means no patient exists with that patient ID.

## List patients [#list-patients]

```bash
curl "https://<workspace-id>.w.clinia.cloud/v1/patients?page=0&perPage=100" \
  -H "Authorization: Bearer <access-token>"
```

Patients come back 100 per page by default, sorted by patient ID. The response's `meta.total` gives the number of patients in the workspace. Page sizes and the other parameters are documented in [List patients](https://docs.clinia.com/api/rest/get-patients).

## Delete a patient [#delete-a-patient]

<Callout type="warn">
  Deleting a patient removes everything the Context Engine holds about that patient and cannot be
  undone.
</Callout>

```bash
curl -X DELETE "https://<workspace-id>.w.clinia.cloud/v1/patients/{patientId}" \
  -H "Authorization: Bearer <access-token>"
```

The [delete call](https://docs.clinia.com/api/rest/delete-patients-patientId) returns `204` once the data is removed, or `404` if no patient exists with that patient ID. You can delete a patient while a submission is still in progress.

## Next steps [#next-steps]

- [Ingest a FHIR Bundle](https://docs.clinia.com/docs/recorded-memory/ingest-fhir) to submit a FHIR R4 or R5 bundle for the patient.
- [Ingest a CDA Document](https://docs.clinia.com/docs/recorded-memory/ingest-cda) to submit a C-CDA R2 document for the patient.
- [Track an Ingestion](https://docs.clinia.com/docs/recorded-memory/track-an-ingestion) to follow a submission until it settles.
