---
title: "Cancel Appointment(s)"
description: "Cancel one or more booked appointments via the PATCH Appointments endpoints."
canonical_url: "https://docs.leyr.io/api/guides/appointments/cancel-appointments"
---
# Cancel Appointment(s)

> Cancel one or more booked appointments via the PATCH Appointments endpoints.

Cancelling is done via our PATCH Appointments endpoints.

## Cancel Single Appointment

If you want to cancel a single appointment, use the [PATCH Appointment](https://api.leyr.io/docs#tag/Appointments/operation/appointments-patch_appointment) endpoint, passing `appointment_id` as the path parameter, and including `"status": "cancelled"` in the JSON body payload:

```text
PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments/{appointment_id}
```

```json
{
    "status": "cancelled",
    "comment": "{comment}"
}
```

You don't have to provide other optional fields (like `start`, `end` or `resource_id`), but you can provide `comment` that will be added to the appointment in the EHR.

## Cancel Multiple Appointments

If you want to cancel multiple appointments at once, use the [PATCH Appointments](https://api.leyr.io/docs#tag/Appointments/operation/appointments-bulk_patch_appointments) bulk endpoint. In that case you no longer pass `appointment_id` in the path. Instead, pass `ids` as an array in the JSON body, together with `"status": "cancelled"`:

```text
PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments
```

```json
{
    "ids": ["appointment_id_1", "appointment_id_2", "appointment_id_3"],
    "status": "cancelled",
    "comment": "{comment}"
}
```

## Two-Step Cancellation

Some EHRs require the patient to confirm their cancellation via an SMS code before the appointment is actually removed. This is called **two-step cancellation**.

### When does it apply?

Whenever you send a cancellation request and receive `"status": "awaiting_confirmation"` back in the response, it means two-step cancellation is required:

```text
PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments/{appointment_id}
```

```json
{
    "status": "cancelled"
}
```

Response:

```json
{
    "id": "<new_appointment_id>",
    "status": "awaiting_confirmation",
    ...
}
```

Leyr has already triggered an SMS with a cancellation code to the patient at this point. Your only job is to present an input field where they can enter that code.

<u-alert color="primary" variant="subtle">
<template v-slot:description="">

**Important:** The `id` returned in this response is a **new appointment ID**. You must use this new `id` - not the original one - when submitting the confirmation code in step 2.

</template>
</u-alert>

### Step 2 - Confirm the cancellation

Once the patient has received and entered the SMS code, submit it using the new `id` from the step 1 response:

```text
PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments/{new_appointment_id}
```

```json
{
    "confirmation": {
        "code": "{sms_code}"
    }
}
```

If the code is correct, you will receive the appointment back with `"status": "cancelled"`:

```json
{
    "id": "...",
    "status": "cancelled",
    ...
}
```

That's when you know the appointment has been successfully cancelled in the EHR.

<u-alert color="success" variant="subtle">
<template v-slot:description="">

If you receive `"status": "cancelled"` when sending a cancellation request (no `awaiting_confirmation`), two-step cancellation is not required for this EHR - the appointment is cancelled directly.

</template>
</u-alert>

## Next steps

<card-group>
<card icon="i-heroicons-pencil-square" title="Update Appointments" to="https://docs.leyr.io/api/guides/appointments/update-appointments">

Reschedule or modify booked appointments.

</card>

<card icon="i-heroicons-check-badge" title="Confirm Appointments" to="https://docs.leyr.io/api/guides/appointments/confirm-appointments">

Confirm requested appointments with a confirmation code.

</card>
</card-group>


## Sitemap

See the full [sitemap](https://docs.leyr.io/sitemap.md) for all pages.
