# Create a Webhook Subscription

To set up an active webhook subscription, you'll need to call the CreateWebhookSubscription endpoint and specify the events you want to monitor and the URL where you'll receive notifications. This guide walks you through configuring your webhook endpoint.

### Request Body

The request body should be in JSON format and include the following key parameters:


```json
{
  "webhookType": "direct",
  "eventTypes": [
    "loan.created",
    "payment.succeeded"
  ],
  "webhookDirectDetails": {
    "webhookUrl": "https://your-endpoint.com/webhook"
  },
  "enabled": true
}
```

* `webhookType`: Specify "direct" for standard webhook delivery.
* `eventTypes`: An array of event types you want to subscribe to. Refer to our Webhook Events documentation for a complete list.
* `webhookDirectDetails.webhookUrl`: Your HTTPS endpoint that will receive the webhook payloads.
* `enabled`: Set to `true` to activate the subscription immediately.


The following request creates a subscription to the `loan.created` and `payment.succeeded` events.

### Request


```bash
curl --request POST \
  --url https://sandboxapi.peach.finance/api/webhooks \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "webhookType": "direct",
    "eventTypes": ["loan.created", "payment.succeeded"],
    "webhookDirectDetails": {
      "webhookUrl": "https://your-endpoint.com/webhook"
    },
    "enabled": true
  }'
```

### Response

Upon success, you'll receive a response containing the details of your new webhook subscription, including a unique identifier:


```json
{
  "status": 0,
  "message": "Webhook subscription created successfully",
  "data": {
    "id": "whk_1234567890abcdef",
    "webhookType": "direct",
    "eventTypes": ["loan.created", "payment.succeeded"],
    "webhookDirectDetails": {
      "webhookUrl": "https://your-endpoint.com/webhook",
      "hmacSecretKey": "whsec_abcdefghijklmnopqrstuvwxyz123456"
    },
    "enabled": true,
    "createdAt": "2023-10-18T14:15:22Z",
    "updatedAt": "2023-10-18T14:15:22Z"
  }
}
```

## Next steps

- **[Webhook Events](/developer-tools/webhooks/webhook-events)** — Reference for the event types you can subscribe to.
- **[Testing Webhooks](/developer-tools/webhooks/testing-webhooks)** — Verify your handler with static payloads before going live.