Developer docs

Webhooks

A webhook tells your system when something happens to an order, so you do not have to keep asking. You add the address in the portal and HomelyRx sends a signed POST to it for each event.

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 ping event 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 on https://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.

Verify a webhook
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);
}

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.

Order events
EventWhen it is sent
order.createdAn order was placed.
order.cancelledAn order was cancelled before it shipped.
order.messageA note was added to an order. data has the order number and the message.
pingSent 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.