# Webhook endpoints

Manage the URLs that receive your webhooks from code.

## The webhook endpoint object

| Field | Type | Description |
|---|---|---|
| `id` | string | Starts with `we_`. |
| `object` | string | Always `webhook_endpoint`. |
| `livemode` | boolean \| null | `true` live only, `false` test only, `null` both modes. |
| `url` | string | HTTPS URL we POST events to. |
| `enabled_events` | string[] | Event types to send. Empty means all. |
| `status` | enum | `enabled` or `disabled`. |
| `description` | string \| null | Your note. |
| `created_at` | timestamp | When it was created. |
| `secret` | string | Signing secret. **Only in the create response**; store it then. |

```json title="A webhook endpoint"
{
  "id": "we_9Ab1Cd3Ef5Gh7Ij9Kl1Mn3",
  "object": "webhook_endpoint",
  "livemode": null,
  "url": "https://shop.example.com/webhooks/klink-pay",
  "enabled_events": [
    "payment.succeeded",
    "payment.failed",
    "refund.succeeded"
  ],
  "status": "enabled",
  "description": "Order fulfilment",
  "created_at": "2026-11-27T09:00:00Z"
}
```

## Create a webhook endpoint

```http
POST /v1/webhook_endpoints
```

**Body**

| Field | Type | Required | Description |
|---|---|---|---|
| `url` | string | yes | HTTPS URL. |
| `enabled_events` | string[] | no | Default: all events. |
| `livemode` | boolean \| null | no | Which mode to listen to; `null` for both. |
| `description` | string | no | Your note. |

```bash title="Request"
curl https://api.klinkpay.net/v1/webhook_endpoints \
  -X POST \
  -H "Authorization: Bearer kp_test_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://shop.example.com/webhooks/klink-pay",
    "enabled_events": [
      "payment.succeeded",
      "payment.failed",
      "refund.succeeded"
    ],
    "description": "Order fulfilment"
  }'
```

```json title="Response (secret shown once)"
{
  "id": "we_9Ab1Cd3Ef5Gh7Ij9Kl1Mn3",
  "object": "webhook_endpoint",
  "livemode": null,
  "url": "https://shop.example.com/webhooks/klink-pay",
  "enabled_events": [
    "payment.succeeded",
    "payment.failed",
    "refund.succeeded"
  ],
  "status": "enabled",
  "description": "Order fulfilment",
  "created_at": "2026-11-27T09:00:00Z",
  "secret": "whsec_…"
}
```

> [!NOTE]
> Requires `webhook_endpoints:write` on restricted keys. Rotating a secret, editing and the delivery log are in the dashboard.

## List webhook endpoints

```http
GET /v1/webhook_endpoints
```

Requires `webhook_endpoints:read`. Secrets are never included.

```bash title="Request"
curl https://api.klinkpay.net/v1/webhook_endpoints \
  -H "Authorization: Bearer kp_test_…"
```

```json title="Response"
{
  "object": "list",
  "data": [
    {
      "id": "we_9Ab1Cd3Ef5Gh7Ij9Kl1Mn3",
      "object": "webhook_endpoint",
      "livemode": null,
      "url": "https://shop.example.com/webhooks/klink-pay",
      "enabled_events": [
        "payment.succeeded",
        "payment.failed",
        "refund.succeeded"
      ],
      "status": "enabled",
      "description": "Order fulfilment",
      "created_at": "2026-11-27T09:00:00Z"
    }
  ],
  "has_more": false
}
```

## Delete a webhook endpoint

```http
DELETE /v1/webhook_endpoints/:id
```

Stops all deliveries to the endpoint.

```bash title="Request"
curl https://api.klinkpay.net/v1/webhook_endpoints/we_9Ab1Cd3Ef5Gh7Ij9Kl1Mn3 \
  -X DELETE \
  -H "Authorization: Bearer kp_test_…"
```
