# Delete a booking

> **DELETE** `https://api.us.nylas.com/v3/scheduling/bookings/{booking_id}`

Source: https://developer.nylas.com/docs/reference/api/bookings/delete-bookings-id/

Deletes the specified booking. Nylas also cancels the associated event on the provider.

Nylas validates the provided session ID and uses it to retrieve the related
[Configuration object](/docs/reference/api/configurations/). If you created a public
Configuration, you don't need to include the `Authorization` request header with a session ID, but
you do need to pass the Configuration object ID as a query parameter.

**Authentication:** SCHEDULER_SESSION_TOKEN

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `booking_id` | string | Yes | The ID of the booking object to access. |

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `configuration_id` | string | No | The ID of the Configuration object used for calculating availability. If you're using session authentication (`requires_session_auth: true`), the `configuration_id` isn't required. |
| `slug` | string | No | The Configuration object slug. You can use this with the `client_id` instead of using the `configuration_id`. If you're using session authentication (`requires_session_auth: true`) or using the `configuration_id`, `slug` isn't required. |
| `client_id` | string | No | The client ID that was used to create the Configuration object. Required only if you're using `slug`. |

## Request body

Content-Type: application/json

- `cancellation_reason` (string) - The reason that the booking is being cancelled.

## Responses

### 200 - Delete Succeeded

- `request_id` (string) **(required)** - ID of the request.

### 400 - Bad Request

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 401 - Unauthorized

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 404 - Not Found

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The raw error from the provider, if available
    - `code` (string)
    - `message` (string)

### 429 - Rate Limit

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

### 504 - Provider Failure

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

## Code samples

### cURL (Public)

```bash
curl --compressed --request DELETE \
  --url 'https://api.us.nylas.com/v3/scheduling/bookings/<BOOKING_ID>?configuration_id=<SCHEDULER_CONFIG_ID>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json'
```

### cURL (Private)

```bash
curl --compressed --request DELETE \
  --url 'https://api.us.nylas.com/v3/scheduling/bookings/<BOOKING_ID>' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <SCHEDULER_SESSION_ID>' \
  --header 'Content-Type: application/json'
```

### Python SDK (Private)

```python
from nylas import Client

nylas = Client(
    "<NYLAS_API_KEY>",
    "<NYLAS_API_URI>",
)

response = nylas.scheduler.bookings.destroy(
    booking_id="<BOOKING_ID>",
    request_body={
        "cancellation_reason": "Plans changed.",
    },
    query_params={
        "configuration_id": "<SCHEDULER_CONFIG_ID>",
    },
)

print("Booking cancelled:", response)

```

### Ruby SDK (Public)

```ruby
# Load gems
require 'nylas'

# Initialize Nylas client
nylas = Nylas::Client.new(
  api_key: "<NYLAS_API_KEY>"
)

booking, _request_ids = nylas.scheduler.bookings.destroy(booking_id: "<BOOKING_ID>", query_params: {"configuration_id": "<CONFIGURATION_ID>"})

puts booking
```

### Ruby SDK (Private)

```ruby
# Load gems
require 'nylas'

# Initialize Nylas client
nylas = Nylas::Client.new(
  api_key: "<SCHEDULER_SESSION_ID>"
)

booking, _request_ids = nylas.scheduler.bookings.destroy(booking_id: "<BOOKING_ID>")

puts booking
```

### Java SDK (Public)

```java
import com.nylas.NylasClient;
import com.nylas.models.DeleteResponse;
import com.nylas.models.DestroyBookingQueryParams;
import com.nylas.models.NylasApiError;
import com.nylas.models.NylasSdkTimeoutError;

public class DeleteBookingPublic {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();

    DestroyBookingQueryParams queryParams = new DestroyBookingQueryParams.Builder()
        .configurationId("<SCHEDULER_CONFIG_ID>")
        .build();

    DeleteResponse result = nylas.scheduler().bookings().destroy("<BOOKING_ID>", queryParams, null);

    System.out.println("Deleted booking: " + result);
  }
}

```

### Java SDK (Private)

```java
import com.nylas.NylasClient;
import com.nylas.models.DeleteResponse;
import com.nylas.models.NylasApiError;
import com.nylas.models.NylasSdkTimeoutError;

public class DeleteBooking {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<SCHEDULER_SESSION_ID>").build();

    DeleteResponse result = nylas.scheduler().bookings().destroy("<BOOKING_ID>", null, null);

    System.out.println("Deleted booking: " + result);
  }
}

```

### Kotlin SDK (Public)

```kotlin
import com.nylas.NylasClient
import com.nylas.models.DestroyBookingQueryParams

fun main() {
  val nylas = NylasClient.Builder("<NYLAS_API_KEY>").build()

  val queryParams = DestroyBookingQueryParams.Builder()
      .configurationId("<SCHEDULER_CONFIG_ID>")
      .build()

  val result = nylas.scheduler().bookings().destroy("<BOOKING_ID>", queryParams)

  println("Deleted booking: $result")
}

```

### Kotlin SDK (Private)

```kotlin
import com.nylas.NylasClient

fun main() {
  val nylas = NylasClient.Builder("<SCHEDULER_SESSION_ID>").build()

  val result = nylas.scheduler().bookings().destroy("<BOOKING_ID>")

  println("Deleted booking: $result")
}

```
