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

> Update or reschedule one or more appointments via the PATCH Appointments endpoints.

Updating is done via our PATCH Appointments endpoints.

### Update Single Appointment

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

```text
curl --location --request PATCH 'https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments/{appointment_id}' 
--header 'x-leyr-client-id: {x-leyr-client-id}'
--header 'x-leyr-client-secret: {x-leyr-client-secret}'
--header 'x-leyr-standard: {x-leyr-standard}'
--data-raw '{
    "start": {start},
    "end": {end},
    "resource_id": {resource_id},
    "comment": {comment}
}'
```

#### Parameters validation

- please do not provide `status` in the payload when you are updating appointments, as it is reserved for [cancelling appointments](https://docs.leyr.io/api/guides/appointments/cancel-appointments)
- all the fields (`start`, `end`, `resource_id` and `comment`) are optional by default, so you can only provide those you actually want to update; but `start` and `end` have to be provided together

#### What Leyr does for you?

- If you provide `resource_id`, we will check that there are time slots available for selected Resource:

  - if you provide `start` and `end` - we will check that range
  - if you don't provide `start` and `end` - we assume you want to change the resource at the same time slot, and will use current `start` and `end` times of the `appointment_id` you are updating
- If you provide `start` and `end`, we will check that there are time slots available for selected time range:

  - if you provide `resource_id` - we will check for that Resource
  - if you don't provide `resource_id` - we assume you want to reschedule an appointment with the same Resource, and will use current `resource_id` of the `appointment_id` you are updating

### Update Multiple Appointments

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

That one may be tricky - we encourage you to familiarize with the logic described below well 😉

</template>
</u-alert>

If you want to update multiple appointments at once, doing bulk cancel, use our [PATCH Appointments](https://api.leyr.io/docs#tag/Appointments/operation/appointments-bulk_patch_appointments). In that case you no longer pass appointment_id in path parameters. Instead, you pass `ids` in array in JSON body payload, together with the fields you would like to update:

```text
curl --location --request PATCH 'https://api.leyr.io/api/emrs/{emr}/care-units/{care_unit_id}/appointments' 
--header 'x-leyr-client-id: {x-leyr-client-id}'
--header 'x-leyr-client-secret: {x-leyr-client-secret}'
--header 'x-leyr-standard: {x-leyr-standard}'
--data-raw '{
    "ids": ["appointment_id_1", "appointment_id_2", "appointment_id_3"],
    "start": {start},
    "end": {end},
    "resource_id": {resource_id},
    "comment": {comment}
}'
```

#### Parameters validation

- please do not provide `status` in the payload when you are updating appointments, as it is reserved for [cancelling appointments](https://docs.leyr.io/cancel-appointments)
- all the fields (`start`, `end`, `resource_id` and `comment`) are optional by default, so you can only provide those you actually want to update; but `start` and `end` have to be provided together

#### What Leyr does for you?

We treat bulk update endpoint in two different "scenarios", based on if you provide `start` and `end` parameters or not

- if you do not provide `start` and `end` - we will treat it as pure bulk update:

  - if you provide `resource_id` - we will validate if there is a time slot available with provided `resource_id` for each of the provided `ids` and move all of them to that Resource. If one of the appointments cannot be moved (there is no time slots available) - we will return a BAD_REQUEST response.
- if you do provide `start` and `end` - we will treat it as a continuous reschedule. <br />


In this case we expect and validate that the `ids` you provided have the same Patient, Resource, Healthcare Service and Care Unit.<br />


If all of them do - we will check available time slots at provided `start` to `end` time range and will fit provided `ids` to those time slots. <br />

<br />


That means we will re-use as many appointments as possible, rescheduling them in the new time slots. We will create new appointments with the same Patient, Resource, Healthcare Service and Care Unit, if provided `start` to `end` range is longer than that covered by `ids`. We will cancel extra appointments from provided `ids`, if provided `start` to `end` range is shorter that that covered by `ids`.\

## Next steps

<card-group>
<card icon="i-heroicons-x-circle" title="Cancel Appointments" to="https://docs.leyr.io/api/guides/appointments/cancel-appointments">

Cancel one or more 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.
