Leyr
Appointments

Cancel Appointment(s)

Cancelling is done via our PATCH Appointments endpoints.

Cancel Appointment(s)

Cancelling is done via our PATCH Appointments endpoints.

Cancel Single Appointment

If you want to cancel a single appointment, use the PATCH Appointment endpoint, passing appointment_id as the path parameter, and including "status": "cancelled" in the JSON body payload:

PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments/{appointment_id}
{
    "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 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":

PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments
{
    "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:

PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments/{appointment_id}
{
    "status": "cancelled"
}

Response:

{
    "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.

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.

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:

PATCH https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments/{new_appointment_id}
{
    "confirmation": {
        "code": "{sms_code}"
    }
}

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

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

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

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.
Leyr © 2026