Skip to content

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

EventDescription
booking.createdA new booking was made
booking.confirmedA booking was confirmed
booking.cancelledA booking was cancelled
booking.completedA booking was completed
payment.receivedA payment was received
payment.refundedA refund was issued
customer.createdA new customer was created
review.createdA new review was created
staff.createdA new staff member was added

Endpoints

List Webhooks

Get a list of Webhooks

http
GET /api/rpc/user/webhooks/list

Create Webhook

Create a new Webhook

http
POST /api/rpc/user/webhooks/create

Body

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/update

Delete Webhook

Delete a Webhook

http
DELETE /api/rpc/user/webhooks/delete

Test Webhook

Test a Webhook

http
POST /api/rpc/user/webhooks/test

Webhook 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',
  }),
});

Released under the MIT License.