# Update a webhook configuration

`PUT https://api.mothership.com/beta/webhookConfigs/{webhookConfigId}`

Sandbox: `https://sandbox.api.mothership.com/beta/webhookConfigs/{webhookConfigId}`

Updates the webhook configuration with the given `webhookConfigId`.

> [!WARNING]
> The only fields on a webhook config that can be updated are `webhookUrl` and `subscribedEvents`.

A change applies to events from then on. Deliveries already queued, and their retries, still go to the URL they were queued for.

## Authorization

Send your API token as a Bearer token: `Authorization: Bearer <token>`.

## Path parameters

- `webhookConfigId` (string, required): ID of the webhook config to update.

## Request body

- `subscribedEvents` (array of strings, optional): Events that trigger a webhook. One of: `billOfLading.created`, `billOfLading.updated`, `proofOfDelivery.created`, `proofOfDelivery.updated`, `deliveryReceipt.created`, `deliveryReceipt.updated`, `certificateOfInsurance.created`, `shipment.purchased`, `shipment.status.updated`.
- `webhookUrl` (string, optional): URL that Mothership POSTs webhook events to.

## Responses

### 200

The updated webhook configuration, inside `data`.

- `data` (object, optional)
  - `id` (string, required): ID of the webhook configuration.
  - `createdAt` (string<date-time>, required): When this webhook configuration was created, as an ISO 8601 date-time.
  - `status` (string, required): Current status of the webhook config. One of: `active`, `inactive`.
  - `subscribedEvents` (array of strings, required): Events that trigger a webhook. One of: `billOfLading.created`, `billOfLading.updated`, `proofOfDelivery.created`, `proofOfDelivery.updated`, `deliveryReceipt.created`, `deliveryReceipt.updated`, `certificateOfInsurance.created`, `shipment.purchased`, `shipment.status.updated`.
  - `webhookUrl` (string, required): URL that Mothership POSTs webhook events to.

### 404

No webhook config with the given id exists for the caller organization

- `code` (number, required) One of: `100`, `101`, `200`, `201`, `202`, `203`, `204`, `205`, `206`, `300`, `301`, `302`, `303`, `304`, `305`, `307`, `400`, `401`, `402`, `403`, `404`, `405`, `406`, `407`, `408`, `409`, `410`, `411`, `412`, `413`, `414`, `415`, `416`, `417`, `422`, `429`, `500`, `501`, `502`, `503`, `504`, `505`.
- `type` (string, required) One of: `UNKNOWN`, `NOT_FOUND`, `SERVER_ERROR`, `UNAUTHENTICATED`, `MISSING_PERMISSION`, `INVALID_REQUEST`, `RATE_LIMIT_EXCEEDED`, `CARGO_TOO_LARGE`, `NO_RATES_FOUND`, `QUOTE_NOT_PURCHASABLE`, `PAYMENT_REQUIRED`, `PAYMENT_FAILED`.
- `message` (string, required)
- `metadata` (object, optional)

## Example request

```bash
curl --request PUT \
  --url 'https://sandbox.api.mothership.com/beta/webhookConfigs/48asjgaoi33nkl4t3lae' \
  --header "Authorization: Bearer $MOTHERSHIP_API_TOKEN" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "webhookUrl": "https://www.yourserver.io/newWebhook/mothership",
  "subscribedEvents": [
    "shipment.status.updated"
  ]
}'
```

## Example response (200)

```json
{
  "data": {
    "id": "48asjgaoi33nkl4t3lae",
    "createdAt": "2019-03-20T16:17:13.424Z",
    "status": "active",
    "subscribedEvents": ["shipment.status.updated"],
    "webhookUrl": "https://www.yourserver.io/newWebhook/mothership"
  }
}
```