# Update a webhook

`PUT /client_api/v2/webhooks/{id}`

Changes a webhook's URL or events. Send only what changes. PATCH works the same way.

## Parameters

- `id` (integer, required): The webhook's id.

## Body

- `webhook` (object, required): The webhook's settings.
  - `events` (array of string): The events to send. `shipment.updated.status` fires when a shipment's status changes.
`shipment.updated.waybill` fires when a shipment gets its waybill.
 Possible enum values: `shipment.updated.status`, `shipment.updated.waybill`.

## Returns

Returns the webhook.

- `webhook` (object, required): The webhook.
  - `events` (array of string, required): The events to send. `shipment.updated.status` fires when a shipment's status changes.
`shipment.updated.waybill` fires when a shipment gets its waybill.
 Possible enum values: `shipment.updated.status`, `shipment.updated.waybill`.
  - `id` (integer, required): The webhook's id.
  - `status` (enum, required): `failing` when deliveries to the URL keep failing. Possible enum values: `active`, `failing`.
  - `target_url` (string, required): The http or https URL we send events to.
  - `token` (string, required): A secret we send with every event, so your system can tell the event came from us.

## Errors

- `400 Bad Request`: The request body isn't valid JSON, or something failed on our side.
- `401 Unauthorized`: The token is missing, expired or invalid. Sign in again.
- `422 Unprocessable Content`: The request was refused. `error` says why in one sentence, and `errors` lists each reason.

## Example request (curl)

```bash
curl -X PUT "https://sandbox-api.vatit-stream.com/client_api/v2/webhooks/5" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "webhook": {
      "events": [
        "shipment.updated.status"
      ]
    }
  }'
```

## Example response (200)

```json
{
  "webhook": {
    "events": [
      "shipment.updated.status"
    ],
    "id": 4,
    "status": "active",
    "target_url": "https://hooks.globaltradecorp.example/stream",
    "token": "q7Vt2mX9pL4sKe8RzW1nYg"
  }
}
```
