# Delete a grant

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

Source: https://developer.nylas.com/docs/reference/api/manage-grants/delete_grant_by_id/

Delete an existing grant by ID. You cannot re-authenticate the deleted grant. If you try to re-authenticate it, Nylas creates a new grant instead.

**Before deleting a grant, consider whether re-authentication is the better option.** Deleting a grant is permanent: object IDs may change (especially for IMAP providers), sync state resets, and tracking links break. See [Handling expired grants](https://developer.nylas.com/docs/dev-guide/best-practices/grant-lifecycle/) for details.

**Authentication:** NYLAS_API_KEY

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `grantId` | string | Yes |  |

## Responses

### 200 - Delete Succeeded

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

### 401 - Not Authenticated

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

### 404 - Not Found

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

## Code samples

### cURL

```bash
curl --request DELETE \
  --url 'https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
```

### Node.js SDK

```javascript
import Nylas from "nylas";

// Instantiate Nylas SDK
const NylasConfig = {
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
};

const nylas = new Nylas(NylasConfig);

// Define the identifier for the grant
const identifier = "<NYLAS_GRANT_ID>";

// Function to delete the grant
async function destroyGrant() {
  try {
    const response = await nylas.grants.destroy({
      grantId: identifier,
    });

    console.log("Grant deleted:", response);
  } catch (error) {
    console.error("Error finding grant:", error);
  }
}

destroyGrant();

```

### Python SDK

```python
import sys
from nylas import Client

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

grant_id = "<NYLAS_GRANT_ID>"

response = nylas.grants.destroy(
  grant_id
)

print(response)
```

### Ruby SDK

```ruby
# frozen_string_literal: true

# Load gems
require 'nylas'

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

status, _ = nylas.grants.destroy(grant_id: "<NYLAS_GRANT_ID>")

puts status
```

### Java SDK

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

public class read_grants {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();
    DeleteResponse grant = nylas.grants().destroy("<NYLAS_GRANT_ID>");
    
    System.out.println(grant);
  }
}
```

### Kotlin SDK

```kotlin
import com.nylas.NylasClient

fun main(args: Array<String>) {
  val nylas: NylasClient = NylasClient(
      apiKey = "<NYLAS_API_KEY>"
  )

  val grant = nylas.grants().destroy("<NYLAS_GRANT_ID>")
  
  print(grant)
}
```
