Webhooks
Webhooks allow you to receive real-time notifications when specific events occur in the Flabs system. Instead of repeatedly polling our API to check for updates, webhooks will automatically send HTTP POST requests to your specified endpoint whenever subscribed events happen.Overview
Webhooks are HTTP callbacks that Flabs sends to your application when certain events occur. This enables you to:- Get instant notifications when bills or reports are completed
- Automate workflows based on bill lifecycle events
- Reduce API polling and improve system efficiency
- Build real-time integrations with the Flabs platform
Supported Events
Flabs supports the following webhook events:Bill Events
bill.created- Triggered when a new bill is created in the systembill.completed- Triggered when all reports in a bill are completed and the entire bill is finalizedbill.deleted- Triggered when a bill is deleted from the system
Report Events
report.completed- Triggered when an individual report within a bill is completed
CRM Events
lead.created- Triggered when a lead is created in the CRMbooking.created- Triggered when a booking is created (directly, or when a lead is converted to a booking)booking.phlebotomist_assigned- Triggered when a phlebotomist is assigned to the bookingbooking.phlebotomist_arrived- Triggered when the phlebotomist reaches the patient’s locationbooking.phlebotomist_sample_collected- Triggered when the phlebotomist collects the sample from the patientbooking.phlebotomist_sample_submitted- Triggered when the phlebotomist submits the collected sample back to the lab (this also auto-creates the bill, which triggers yourbill.createdevent)booking.rescheduled- Triggered when the booking’s scheduled date or time is changedbooking.cancelled- Triggered when the booking is cancelled
Each bill consists of multiple reports. The
bill.completed event is only
triggered when all reports within that bill are finished, while
report.completed is triggered for each individual report as it gets
completed.data object instead of bill data:
The six
booking.* lifecycle events (assigned through cancelled) fire only for bookings created through the integration — bookings that carry the integratorID you sent to Create Lead or Booking. A booking created inside the Flabs CRM (with no integratorID) does not emit them.Catch-all vs party-scoped
How webhooks are registered depends on your account mode (see CRM integration modes):- Catch-all (default): register one webhook with no party. It receives every event for the lab.
- Party-scoped (B2B): for a doctor’s CRM, a hospital portal, a wellness app, or a corporate health dashboard — register one webhook per party by attaching a
corporateUserororganizationwhen subscribing. Each webhook receives only that party’s events. A party can have one active webhook per event. See Party-scoped flow.
Security Requirements
- HTTPS Only: All webhook endpoints must use HTTPS protocol for security
- Authentication: Bearer token authentication is required to register webhooks
- Endpoint Validation: Your webhook endpoint must be publicly accessible and return appropriate HTTP status codes
Webhook Payload Structure
When an event occurs, Flabs will send a POST request to your registered endpoint with the following structure:Payload Fields
The
integratorID field contains your unique identifier that you provide when
creating a bill through the Create Bill API. This helps you correlate webhook
events with your internal records.Getting Started
- Get an Auth Token: Use the authentication endpoints to obtain a Bearer token
- Register Your Webhook: Use the webhook registration endpoint to subscribe to events
- Handle Webhook Requests: Implement an endpoint on your server to receive and process webhook notifications
- Verify Webhooks: Validate incoming webhook requests using the optional auth token
Best Practices
- Always respond with a
2xxstatus code to acknowledge receipt - Implement proper error handling and retry logic
- Use HTTPS endpoints for security
- Validate webhook authenticity using the auth token
- Process webhooks asynchronously to avoid timeouts
- Implement idempotency to handle duplicate deliveries
Retry Policy
Webhook deliveries are subject to the following retry mechanism:- Maximum of 3 retry attempts for failed deliveries
- 2-minute interval between each retry attempt
- After 3 failed retries, you must contact Flabs support to get that webhook event