Webhooks and Notifications
Webhooks let RxScale notify your system in real time when something happens — such as an order status change, a prescription being signed, or a pharmacy shipping an order. This page explains how to set up and use webhooks effectively.Setting Up Webhooks
To start receiving webhook notifications:Prepare your endpoint
Create an HTTP endpoint on your server that can receive POST requests. This endpoint should be publicly accessible and able to handle incoming webhook payloads.
Register your webhook
Use the Management API to register your webhook endpoint URL. You will specify which event types you want to receive.
Verify your setup
RxScale will send a test event to your endpoint. Make sure your server responds with a 200 status code to confirm it is working.
Available Event Types
RxScale sends webhook notifications for a variety of events. Here are the most common ones:| Event Type | When It Fires |
|---|---|
| Order created | A new order has been placed. |
| Order updated | An order’s status has changed (for example, moved to “waiting for pharmacy”). |
| Prescription approved | A doctor has approved a prescription. |
| Prescription signed | A prescription has been electronically signed. |
| Prescription declined | A doctor has declined a prescription. |
| Prescription doctor changed | The doctor assigned to a prescription has changed. |
| Pharmacy order updated | A pharmacy has updated an order’s status (for example, shipped). |
Prescription doctor assignment changes
If you subscribe to Pub/Sub notifications, RxScale can publish a dedicated event whenever the doctor assigned to a prescription changes. Subscribe to the notification typePRESCRIPTION_DOCTOR_CHANGED to receive these updates.
The payload uses the prescription notification envelope with category set to prescription and event set to doctor_changed:
data object contains the public prescription payload plus the fields external_provider_identifier, doctor_assignment_reason, old_doctor_uid, and new_doctor_uid. old_doctor_uid is null when a prescription was not assigned to a doctor before the change. new_doctor_uid is null when the assignment was removed.
doctor_assignment_reason describes why RxScale changed the assignment. Stable reason examples include ADMIN_ASSIGNED, ORDER_ATTRIBUTE_ASSIGNED, QUEUE_ASSIGNED, PRESCRIPTION_REQUEUED, DOCTOR_REQUEUED_PRESCRIPTIONS, STALE_ASSIGNMENT_CLEARED, and ON_HOLD_DOCTOR_REMOVED.
Monitoring Order Status Changes
Webhooks are the best way to stay informed about what is happening with your orders. Instead of polling the API repeatedly, you receive a notification the moment something changes. A typical monitoring workflow:- A patient places an order on your shop.
- You receive a webhook when the order is created.
- You receive a webhook when the doctor approves the prescription.
- You receive a webhook when the prescription is signed.
- You receive a webhook when the order is sent to a pharmacy.
- You receive a webhook when the pharmacy ships the order.
- You receive a webhook when the order is completed.
Best Practices for Webhook Handling
Respond quickly
Respond quickly
Your endpoint should respond with a 200 status code as quickly as possible. Process the webhook payload asynchronously if needed — do not block the response while performing lengthy operations.
Handle duplicates
Handle duplicates
In rare cases, you may receive the same webhook event more than once. Design your handler to be idempotent, meaning processing the same event twice should not cause issues.
Verify the payload
Verify the payload
RxScale signs webhook payloads so you can verify they are authentic. Always verify the signature before processing the payload. See Webhook Security for details.
Monitor for failures
Monitor for failures
If your endpoint is down or returning errors, webhook deliveries will be retried. Set up monitoring to detect when your endpoint is failing so you can fix issues quickly.
Log webhook events
Log webhook events
Keep a log of all received webhook events. This is invaluable for debugging and understanding the sequence of events for any given order.
Related Topics
- Webhooks Overview — Technical details about how webhooks work.
- Webhook Events — Complete list of event types and payload formats.
- Webhook Security — How to verify webhook signatures.