Set up a webhook
- Choose the organization at the top of the portal, then open Developers and add a webhook. The address must be public and start with
https://. - Pick the events you want. The signing secret is shown once; keep it where your server can read it.
- Use Send test to see a
pingevent arrive. The portal shows the status of the last delivery for each webhook. - Events are sent from HomelyRx for orders placed on
https://app-api.homelyrx.com(production) and onhttps://stage-api.homelyrx.com(test).
Check the signature
Every request carries X-HomelyRx-Event with the event name and X-HomelyRx-Signature with sha256= followed by the HMAC-SHA256 of the raw body, made with your signing secret. Compute it on your side and compare before you trust the request.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function isFromHomelyRx(rawBody, signatureHeader, secret) {
const expected = 'sha256=' + createHmac('sha256', secret).update(rawBody).digest('hex');
const a = Buffer.from(expected);
const b = Buffer.from(signatureHeader ?? '');
return a.length === b.length && timingSafeEqual(a, b);
}import hmac, hashlib
def is_from_homelyrx(raw_body: bytes, signature: str, secret: str) -> bool:
expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature or "")The body is JSON: { "id": "evt_…", "event": "order.created", "createdAt": "…", "data": { … } }, where data is the order as GET /v1/orders/:number returns it.
Order events
These are the events sent today. More steps of the Order lifecycle, such as shipped and delivered, will be added as events; until then read the current state with the API.
| Event | When it is sent |
|---|---|
order.created | An order was placed. |
order.cancelled | An order was cancelled before it shipped. |
order.message | A note was added to an order. data has the order number and the message. |
ping | Sent by Send test, to check that your address works. |
Your endpoint
Each event is sent to your endpoint as a POST. Your endpoint should answer with a 2xx status. The Order lifecycle page shows how an endpoint that answers 404 shows up and what to fix.
Reading state through the API
You can always read the current state of an order with GET /v1/orders/:number, which returns the order and every line with its status and tracking. See Orders. That is useful to reconcile your records after downtime.
What is not in the API yet
- There are no endpoints to create, list or test webhook endpoints, or to manage API keys. These are arranged with the HomelyRx team.
- The API in this reference does not list past webhook deliveries.
