Webhooks API
API for managing Webhooks to receive real-time notifications
Overview
Webhooks allow you to receive notifications when events occur in the system, such as new bookings, cancellations, payments
Events
| Event | Description |
|---|---|
booking.created | A new booking was made |
booking.confirmed | A booking was confirmed |
booking.cancelled | A booking was cancelled |
booking.completed | A booking was completed |
payment.received | A payment was received |
payment.refunded | A refund was issued |
customer.created | A new customer was created |
review.created | A new review was created |
staff.created | A new staff member was added |
Endpoints
List Webhooks
Get a list of Webhooks
http
GET /api/rpc/user/webhooks/listCreate Webhook
Create a new Webhook
http
POST /api/rpc/user/webhooks/createBody
json
{
"url": "https://your-app.com/webhook",
"events": ["booking.created", "payment.received"],
"secret": "your_webhook_secret"
}Update Webhook
Update a Webhook
http
PATCH /api/rpc/user/webhooks/updateDelete Webhook
Delete a Webhook
http
DELETE /api/rpc/user/webhooks/deleteTest Webhook
Test a Webhook
http
POST /api/rpc/user/webhooks/testWebhook Payload
When an event occurs, the system sends a POST request to the specified URL:
json
{
"event": "booking.created",
"timestamp": "2025-01-15T10:00:00Z",
"data": {
"bookingId": "booking_123",
"providerId": "provider_456",
"customerId": "cust_789",
"serviceId": "svc_abc",
"dateTime": "2025-01-20T14:00:00Z",
"status": "pending"
},
"signature": "sha256=abc123..."
}Signature Verification
typescript
import crypto from 'crypto';
function verifyWebhook(payload: string, signature: string, secret: string) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return `sha256=${expected}` === signature;
}Example Code
typescript
// Create Webhook
const webhook = await fetch('/api/rpc/user/webhooks/create', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://your-app.com/webhook',
events: ['booking.created', 'payment.received'],
secret: 'your_secret',
}),
});