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.
The request body should be in JSON format and include the following key parameters:
{
"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 totrueto activate the subscription immediately.
The following request creates a subscription to the loan.created and payment.succeeded events.
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
}'Upon success, you'll receive a response containing the details of your new webhook subscription, including a unique identifier:
{
"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"
}
}- Webhook Events — Reference for the event types you can subscribe to.
- Testing Webhooks — Verify your handler with static payloads before going live.