# Update Webhook

> PATCH /webhooks/:id — update a webhook’s endpoint, events, or status.

`PATCH /webhooks/:id`

Updates an existing webhook. Send any of `endpoint`, `events`, or `status`; omitted fields are left unchanged. Use `status` to pause delivery without deleting the webhook.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The webhook id as returned by [Create Webhook](https://www.sendping.co/docs/api/webhooks-create) or [List Webhooks](https://www.sendping.co/docs/api/webhooks-list) — a numeric string (e.g. `17`), not a UUID. A non-numeric id returns `not_found` (404). |

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `endpoint` | string | No | The HTTPS URL where webhook events will be sent. |
| `events` | string[] | No | Array of event types to subscribe to. Replaces the existing set. See [Create Webhook](https://www.sendping.co/docs/api/webhooks-create) for the available values. |
| `status` | string | No | The webhook status. Either `enabled` or `disabled`. |

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.webhooks.update('17', {
  "endpoint": "https://new-webhook.example.com/handler",
  "events": ["email.sent", "email.delivered"],
  "status": "enabled"
});
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Webhooks.update("17", {
  "endpoint": "https://new-webhook.example.com/handler",
  "events": [
    "email.sent",
    "email.delivered"
  ],
  "status": "enabled"
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->webhooks->update('17', [
  'endpoint' => "https://new-webhook.example.com/handler",
  'events' => [
    "email.sent",
    "email.delivered"
  ],
  'status' => "enabled"
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Webhooks.update("17", {
  "endpoint": "https://new-webhook.example.com/handler",
  "events": [
    "email.sent",
    "email.delivered"
  ],
  "status": "enabled"
})
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

updated, err := client.Webhooks.Update("17", &sendping.UpdateWebhookRequest{
    Endpoint: "https://new-webhook.example.com/handler",
    Events:   []string{"email.sent", "email.delivered"},
    Status:   "enabled",
})
```

**Rust**

```rust
use sendping::{SendPing, UpdateWebhookOptions, WebhookStatus};

let mb = SendPing::new("mb_xxxxxxxxx");

let params = UpdateWebhookOptions::new()
    .with_endpoint("https://new-webhook.example.com/handler")
    .with_events(["email.sent", "email.delivered"])
    .with_status(WebhookStatus::Enabled);
let _updated = mb.webhooks.update("17", params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.UpdateWebhookRequest;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

UpdateWebhookRequest request = UpdateWebhookRequest.builder()
        .endpoint("https://new-webhook.example.com/handler")
        .events("email.sent", "email.delivered")
        .status("enabled")
        .build();

SendPingResponse response = sendping.webhooks().update("17", request);
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.WebhookUpdateAsync("17", new WebhookUpdateOptions
{
    Endpoint = "https://new-webhook.example.com/handler",
    Events = new List<string> { "email.sent", "email.delivered" },
    Status = "enabled",
});
```

**cURL**

```bash
curl -X PATCH 'https://www.sendping.co/api/webhooks/17' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "endpoint": "https://new-webhook.example.com/handler",
  "events": ["email.sent", "email.delivered"],
  "status": "enabled"
}'
```

**CLI**

```bash
sendping webhooks update 17 \
  --endpoint 'https://new-webhook.example.com/handler' \
  --events 'email.sent,email.delivered' \
  --status 'enabled'
```

### Response

```json
{
  "object": "webhook",
  "id": "17"
}
```

Errors: `not_found` if the webhook does not exist or is not yours. See [Errors](https://www.sendping.co/docs/api/errors).
