# Delete an event

> **DELETE** `https://api.us.nylas.com/v3/grants/{grant_id}/events/{event_id}`

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

Delete the specified event.

Google sends deleted events to the "Trash" folder, and you can read them for a period of time using
the `show_cancelled` query parameter.

Microsoft deletes events immediately.

**Authentication:** NYLAS_API_KEY, ACCESS_TOKEN

## Parameters

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `calendar_id` | string | Yes | The calendar ID of the event.  For Microsoft, we do not validate whether the given calendar ID matches the real calendar ID of the event. This is due to a limitation of the Microsoft Graph API.  (Not supported for iCloud) You can use `primary` to query the user's primary calendar. |
| `notify_participants` | boolean | No | Filter for events matching the specified `notify_participants` setting.  Microsoft and iCloud do _not_ support `notify_participants=false`. |

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `grant_id` | string | Yes | ID of the grant to access. You can also use the email address associated with the grant, or use `/me/` to refer to the grant associated with an access token. |
| `event_id` | string | Yes | ID of the event to access. Nylas recommends you URL-encode this field, or you might receive a [`404` error](/docs/api/errors/400-response/) if the ID contains special characters (for example, `#`). |

## 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

```bash
curl --compressed --request DELETE \
  --url 'https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/events/<EVENT_ID>?calendar_id=<CALENDAR_ID>' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json'
```

### Node.js SDK

```javascript
import Nylas from "nylas";

const nylas = new Nylas({
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
});

async function deleteEvent() {
  try {
    const event = await nylas.events.destroy({
      identifier: "<NYLAS_GRANT_ID>",
      eventId: "<EVENT_ID>",
      queryParams: {
        calendarId: "<CALENDAR_ID>",
      },
    });

    console.log("Event deleted:", event);
  } catch (error) {
    console.error("Error to delete event:", error);
  }
}

deleteEvent();

```

### Python SDK

```python
from nylas import Client

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

grant_id = "<NYLAS_GRANT_ID>"
event_id = "<EVENT_ID>"

event = nylas.events.destroy(
    grant_id,
    event_id,
    query_params={
      "calendar_id": "<CALENDAR_ID>"
    }
)

print(event)
```

### Ruby SDK

```ruby
require 'nylas'	

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

query_params = {
  calendar_id: "<CALENDAR_ID>"
}

result, _request_ids = nylas.events.destroy(
    identifier: "<NYLAS_GRANT_ID>", 
    event_id: "<EVENT_ID>",
    query_params: query_params)

puts result

```

### Java SDK

```java
import com.nylas.NylasClient;
import com.nylas.models.*;

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

    DeleteResponse event = nylas.events().destroy(
        "<NYLAS_GRANT_ID>",
        "<EVENT_ID>",
        queryParams);
  }
}
```

### Kotlin SDK

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

fun main(args: Array<String>) {
  val nylas: NylasClient = NylasClient(apiKey = "<NYLAS_API_KEY>")
  val queryParams = DestroyEventQueryParams("<CALENDAR_ID>", false)

  val event = nylas.events().destroy(
      "<NYLAS_GRANT_ID>",
      "<EVENT_ID>", 
      queryParams)
}
```
