Skip to main content

Webhooks Guide

Webhooks are the most efficient way to react to events in WioClinic — no polling required.

Quick Setup

# 1. Register your endpoint
curl -X POST https://wioclinic.services/api/developer/v1/webhooks \
-H "Authorization: Developer wc_live_…:wcs_live_…" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourapp.com/webhooks/wioclinic",
"events": ["appointment.created", "appointment.cancelled"],
"secret": "your-signing-secret"
}'

Handling Events

Your endpoint must:

  1. Respond with 2xx within 10 seconds
  2. Verify the signature before processing
  3. Return 2xx even for event types you don't handle (to prevent retries)
// Minimal PHP handler
$payload = json_decode(file_get_contents('php://input'), true);

// Verify signature first (see Signature Verification)

match ($payload['event']) {
'appointment.created' => handleAppointmentCreated($payload['data']),
'appointment.cancelled' => handleAppointmentCancelled($payload['data']),
default => null, // ignore unknown events
};

http_response_code(200);

Testing Webhooks Locally

Use a tunneling tool like ngrok to expose your local server:

ngrok http 3000
# Exposes: https://abc123.ngrok.io → localhost:3000

Register https://abc123.ngrok.io/webhooks/wioclinic as your webhook URL during development.