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

# Update Webhook Endpoint

> Update an existing webhook endpoint's configuration

# Update Webhook Endpoint

Updates the configuration of an existing webhook endpoint.

## Request

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key
</ParamField>

<ParamField path="id" type="string" required>
  The unique identifier of the webhook endpoint
</ParamField>

<ParamField body="url" type="string">
  Updated HTTPS URL for webhook delivery
</ParamField>

<ParamField body="events" type="array">
  Updated array of event types to subscribe to
</ParamField>

<ParamField body="isActive" type="boolean">
  Enable or disable the endpoint
</ParamField>

<ParamField body="description" type="string">
  Updated description
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  Updated webhook endpoint object
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  # Update URL and events
  curl -X PUT https://api.swiftpay.cx/api/webhooks/wh_abc123 \
    -H "Authorization: Bearer mp_live_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://new-url.yoursite.com/webhooks",
      "events": ["checkout.completed", "refund.completed"]
    }'

  # Disable endpoint

  curl -X PUT https://api.swiftpay.cx/api/webhooks/wh_abc123 \
   -H "Authorization: Bearer mp_live_your_api_key" \
   -H "Content-Type: application/json" \
   -d '{"isActive": false}'

  ```

  ```javascript JavaScript theme={null}
  const endpointId = 'wh_abc123';

  // Add new events
  const response = await fetch(
    `https://api.swiftpay.cx/api/webhooks/${endpointId}`,
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer mp_live_your_api_key',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        events: [
          'checkout.completed',
          'checkout.failed',
          'refund.completed',
          'refund.failed',
          'withdrawal.completed'
        ]
      })
    }
  );

  const updated = await response.json();
  console.log('Updated events:', updated.data.events);
  ```

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

  endpoint_id = 'wh_abc123'

  # Disable endpoint
  response = requests.put(
      f'https://api.swiftpay.cx/api/webhooks/{endpoint_id}',
      headers={
          'Authorization': 'Bearer mp_live_your_api_key',
          'Content-Type': 'application/json'
      },
      json={'isActive': False}
  )

  updated = response.json()
  print(f"Endpoint active: {updated['data']['isActive']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "data": {
      "id": "wh_abc123",
      "url": "https://new-url.yoursite.com/webhooks",
      "events": [
        "checkout.completed",
        "refund.completed"
      ],
      "isActive": true,
      "description": "Production webhook handler",
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-20T14:00:00Z"
    }
  }
  ```

  ```json 400 theme={null}
  {
     "success": false,
     "error": {
        "type": "validation_error",
        "message": "URL must be HTTPS",
        "requestId": "req_abc123"
     }
  }
  ```

  ```json 404 theme={null}
  {
     "success": false,
     "error": {
        "type": "not_found",
        "message": "Webhook endpoint not found",
        "requestId": "req_abc123"
     }
  }
  ```
</ResponseExample>

## Common Updates

### Disable an Endpoint

```json theme={null}
{ "isActive": false }
```

### Add Events

```json theme={null}
{
   "events": [
      "checkout.completed",
      "checkout.failed",
      "refund.completed",
      "refund.failed"
   ]
}
```

### Subscribe to All Events

```json theme={null}
{
   "events": ["*"]
}
```

<Note>
  Updating an endpoint does not change the signing secret. The original secret
  remains valid.
</Note>
