Skip to main content
Webhooks let ByDoctor notify your application the moment something important happens in a clinic — a new appointment is booked, a patient is created, or a payment is confirmed. Instead of repeatedly asking the API whether anything has changed, your server receives an HTTP POST request the instant the event occurs.

What Are Webhooks?

Traditional API integrations rely on polling: your code calls the API on a schedule and checks for changes. Polling is simple but wasteful — most requests return nothing new, and you still miss events that fall between checks. Webhooks flip this model. ByDoctor acts as the caller and sends a payload directly to a URL you control. Your server processes the data in real time and responds. This approach is faster, cheaper on request volume, and far more reliable for event-driven workflows like sending confirmation messages, updating a local database, or triggering downstream automation.

How ByDoctor Webhooks Work

Every webhook delivery is a standard HTTP POST request to your registered URL. The request body is a JSON object describing the event — what happened, when, and which clinic it belongs to. Every request also carries a X-ByDoctor-Signature header so you can verify the payload came from ByDoctor and was not tampered with in transit. Here is what a typical delivery looks like:
Your server must respond with any 2xx status code within 30 seconds. If it does not, ByDoctor retries the delivery automatically — see Retries for the full schedule.

Webhooks vs. Polling the API

Use the right tool for the job:
Webhook events are scoped to the clinic associated with the API key you use to register the endpoint. An API key issued for Clinic A will never receive events from Clinic B.

Register a Webhook Endpoint

1

Create a publicly reachable HTTPS endpoint on your server

Your URL must use HTTPS. ByDoctor will not deliver events to plain HTTP endpoints. The endpoint should be dedicated to receiving webhook payloads — a route like /webhooks/bydoctor works well.For local development, use a tunneling tool like ngrok to expose your local server:
Use the https:// ngrok URL as your endpoint during testing.
2

Register the endpoint with POST /webhooks

Send a POST request to /webhooks with the URL you want to receive events and the list of event types you want to subscribe to:
cURL
ByDoctor responds with a 201 Created and the full webhook object, including a one-time secret:
3

Store the returned secret securely

Copy the secret value from the response and store it in your application’s environment variables or secrets manager.
The secret is shown only once at registration time. ByDoctor never returns it again. If you lose it, you must delete the webhook and create a new one to obtain a fresh secret.
4

Verify incoming signatures

Every delivery includes a X-ByDoctor-Signature header. Always verify this signature before trusting or processing the payload. See Webhook Security for step-by-step instructions and code examples in Node.js, Python, and PHP.
5

Respond with 2xx within 30 seconds

Your handler must return a 2xx status code (typically 200 OK) within 30 seconds of receiving the request. If ByDoctor does not receive a 2xx response in time, it treats the delivery as failed and will retry.
To stay well within the time limit, acknowledge the request immediately by returning 200 OK and then process the event asynchronously — push the payload onto a queue or background job and handle the business logic separately.

Subscribing to All Events

To receive every event type, pass "*" in the events array:
You can update your event subscriptions at any time with PATCH /webhooks/{id} without needing to re-register.