> ## Documentation Index
> Fetch the complete documentation index at: https://developers.mageloyalty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a webhook subscription

> Update the URL, events, active status, or description of a webhook subscription.

Update a webhook subscription. Send only the fields you want to change. The signing secret is not returned by this endpoint and is never changed here. To issue a new secret, use [rotate secret](/api-reference/webhooks/subscriptions/rotate-secret).

## Path parameters

| Parameter | Type   | Description                 |
| --------- | ------ | --------------------------- |
| `id`      | string | The webhook subscription ID |

## Request body

All fields are optional. Include any subset you want to change.

| Field         | Type           | Description                                                                                                                       |
| ------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `url`         | string         | A new HTTPS endpoint. Must be a valid URL                                                                                         |
| `events`      | string\[]      | A non-empty array of events. Valid events: `points.earned`, `points.redeemed`, `customer.tier_upgrade`, `customer.tier_downgrade` |
| `is_active`   | boolean        | Set to `false` to pause deliveries, `true` to resume                                                                              |
| `description` | string \| null | A new label, or `null` to clear it                                                                                                |

## Errors

| Status | Scenario                                                                                               |
| ------ | ------------------------------------------------------------------------------------------------------ |
| `400`  | `url` not a string, `url` not a valid URL, `events` empty, one or more events invalid, or invalid JSON |
| `401`  | Missing or invalid API key                                                                             |
| `403`  | The API key is read-only and cannot perform write operations                                           |
| `404`  | No subscription with this ID exists for the shop                                                       |
| `429`  | [Rate limit](/api-reference/rate-limits) exceeded (6 requests/second)                                  |

<RequestExample>
  ```bash cURL theme={null}
  curl --request PUT \
    --url https://api.mageloyalty.com/v1/webhook-subscriptions/whsub_abc123 \
    --header 'Authorization: <api-key>' \
    --header 'Content-Type: application/json' \
    --data '{
    "events": ["points.earned", "points.redeemed"],
    "is_active": false
  }'
  ```

  ```javascript Node theme={null}
  const response = await fetch(
    "https://api.mageloyalty.com/v1/webhook-subscriptions/whsub_abc123",
    {
      method: "PUT",
      headers: {
        Authorization: "<api-key>",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        events: ["points.earned", "points.redeemed"],
        is_active: false,
      }),
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.put(
      "https://api.mageloyalty.com/v1/webhook-subscriptions/whsub_abc123",
      headers={"Authorization": "<api-key>"},
      json={
          "events": ["points.earned", "points.redeemed"],
          "is_active": False,
      },
  )

  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init("https://api.mageloyalty.com/v1/webhook-subscriptions/whsub_abc123");
  curl_setopt_array($ch, [
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HTTPHEADER => [
          "Authorization: <api-key>",
          "Content-Type: application/json",
      ],
      CURLOPT_POSTFIELDS => json_encode([
          "events" => ["points.earned", "points.redeemed"],
          "is_active" => false,
      ]),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "type": "webhook_subscription",
      "id": "whsub_abc123",
      "attributes": {
        "url": "https://example.com/webhooks/mage",
        "events": ["points.earned", "points.redeemed"],
        "is_active": false,
        "description": "Production points + tier sync",
        "created_at": "2024-01-01T00:00:00.000Z",
        "updated_at": "2024-01-02T00:00:00.000Z"
      }
    }
  }
  ```

  ```json 400 Invalid events theme={null}
  {
    "errors": [
      {
        "status": "400",
        "title": "Bad Request",
        "detail": "Invalid event(s): points.created. Valid events: points.earned, points.redeemed, customer.tier_upgrade, customer.tier_downgrade"
      }
    ]
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "errors": [
      {
        "status": "404",
        "title": "Not Found",
        "detail": "Webhook subscription 'whsub_abc123' not found"
      }
    ]
  }
  ```
</ResponseExample>
