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 aX-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:
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 Use the
/webhooks/bydoctor works well.For local development, use a tunneling tool like ngrok to expose your local server:https:// ngrok URL as your endpoint during testing.2
Register the endpoint with POST /webhooks
Send a ByDoctor responds with 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
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.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.Subscribing to All Events
To receive every event type, pass"*" in the events array:
PATCH /webhooks/{id} without needing to re-register.