# Update a webhook destination

> **PUT** `https://api.us.nylas.com/v3/webhooks/{id}`

Source: https://developer.nylas.com/docs/reference/api/webhook-notifications/put-webhook-by-id/

Update the values in a specific webhook destination.

### Limitations

- You only need to specify fields that need to change when you make a request to this endpoint.
Empty fields in the request do not overwrite existing fields.
- You should limit how many webhook destinations you have for each trigger type. When Nylas retries
a webhook, the retry goes to _all destinations for the specific trigger type_. This can result in
a lot of notifications.
- Some webhook testing tools rate-limit or block you if your webhook destination endpoint generates
too much traffic. Nylas blocks Ngrok connections for this reason.

**Authentication:** NYLAS_API_KEY

## Parameters

### Path parameters

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

## Request body

Destination definition

Content-Type: application/json



## Responses

### 200 - Destination Updated

- `data` (object)
  - `id` (string) - A unique identifier for the webhook destination.
  - `description` (string) - A human-readable description of the webhook destination.
  - `trigger_types` (array) - The event that triggers the notification. See the
[notification schemas](/docs/reference/notifications/) for details about each trigger
type.

See the [Grants](/docs/reference/api/manage-grants/), [Calendar](/docs/reference/api/calendar/),
[Events](/docs/reference/api/events/), and [Messages](/docs/reference/api/messages/) references
for information on how to trigger each event type.
  - `webhook_url` (string) - The URL to send webhooks to.
  - `status` (string) - The status of the new destination.
  - `notification_email_addresses` (array) - The email addresses that Nylas notifies when a webhook is down for a while. See
[Failing and failed webhooks](/docs/v3/notifications/#failing-and-failed-webhooks) for
details.
  - `compressed_delivery` (boolean) - If `true`, Nylas compresses notification payloads using gzip before delivering them.
  - `status_updated_at` (integer) - The time the `status` field was last updated, represented as a Unix timestamp in seconds.
  - `created_at` (integer) - The time the webhook destination was created, represented as a Unix timestamp in seconds.
  - `updated_at` (integer) - The time the webhook destination was last updated, represented as a Unix timestamp in seconds.
- `request_id` (string) - The ID for each request.

### 400 - Unable to update Pub/Sub channel

- `error` (object)
  - `type` (string) - An alphanumeric code that represents the error type.
  - `message` (string) - A human readable message with details about the error.
- `request_id` (string) - The unique ID of the request that generated this response.

## Code samples

### cURL

```bash
curl --request PUT \
  --url 'https://api.us.nylas.com/v3/webhooks/<WEBHOOK_ID>' \  
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --data '{
    "notification_email_addresses": ["leyah@example.com"]
  }'
```

### Node.js SDK

```javascript
import Nylas from "nylas";

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

async function updateWebhook() {
  try {
    const webhook = await nylas.webhooks.update({
      webhookId: "<WEBHOOK_ID>",
      requestBody: {
        notificationEmailAddresses: ["<EMAIL_ADDRESS>"],
      },
    });

    console.log("Updated Webhook:", webhook);
  } catch (error) {
    console.error("Error updating webhook:", error);
  }
}

updateWebhook();

```

### Python SDK

```python
from nylas import Client

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

webhook = nylas.webhooks.update(
    "<WEBHOOK_ID>",
    request_body={
        "notification_email_addresses": ["<EMAIL_ADDRESS>"],
    }
)

print(webhook)

```

### Ruby SDK

```ruby
require 'nylas'

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

request_body = {
    description: 'My updated webhook'
}

webhooks = nylas.webhooks.update(webhook_id: "<WEBHOOK_ID>", 
request_body: request_body)
puts webhooks

```

### Java SDK

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

public class webhooks {
    public static void main(String[] args) throws 
    NylasSdkTimeoutError, NylasApiError {

        NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();

        UpdateWebhookRequest webhookRequest = new
                UpdateWebhookRequest.Builder().
                description("My updated webhook").
                build();

        Response<Webhook> webhook = nylas.webhooks().update("<WEBHOOK_ID>", 
        webhookRequest);
        System.out.println(webhook.getData());
    }
}

```

### Kotlin SDK

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

fun main(args: Array<String>){

    val nylas: NylasClient = NylasClient(
        apiKey = "<NYLAS_API_KEY>"
    )

    val webhookRequest : UpdateWebhookRequest =
        UpdateWebhookRequest.Builder().
        description("My updated webhook").
        build()

    val webhooks = nylas.webhooks().update("<WEBHOOK_ID>", 
    webhookRequest)
    println(webhooks.data)
}

```
