Skip to content

Webhooks

Webhooks push platform events to your HTTPS endpoint as they happen, signed so you can prove they came from the hub.

Setting up an endpoint

Add an endpoint in the developer console under Webhooks, or with POST /webhook-endpoints (scope webhooks:manage). Pick the event types to receive, or * for all — including types added in future. The signing secret (whsec_…) is shown once.

  • The URL must be public https on port 443. The hub resolves the host name each time it delivers and refuses private, loopback, link-local, carrier-grade NAT and cloud-metadata addresses, for IPv4 and IPv6.
  • Redirects are not followed: respond from the URL you registered.
  • Use Send test in the console to fire a signed webhook.test event at any time.

Test and live endpoints

  • A testendpoint receives only events for the sandbox facility that your own keys caused. Other developers’ sandbox activity never reaches it.
  • A liveendpoint receives events only for facilities your account holds an active grant for, and only the event types that grant’s scopes allow (for example invoices:read for invoice.*). It needs live access approved and two-step verification on.
  • Live endpoints are created and changed only in the console, with a code from your authenticator app. A live key that calls POST /webhook-endpoints gets 403 with code console_required. A test key can create test endpoints through the API.
  • A key lists and deletes only your own account’s endpoints, in its own environment.

Payload

POST https://erp.example.com/hooks/hekasoftlink
Content-Type: application/json
User-Agent: Hekasoftlink-Webhooks/1.0
HSL-Event-Id: 6c1f2a9e-3b7d-4a51-9a0c-1d2e3f4a5b6c
HSL-Event-Type: invoice.paid
HSL-Delivery-Id: 0f8e…
HSL-Delivery-Attempt: 1
HSL-Signature: t=1795660000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd

{
  "id": "6c1f2a9e-3b7d-4a51-9a0c-1d2e3f4a5b6c",
  "type": "invoice.paid",
  "created_at": "2026-11-25T09:12:44.118Z",
  "data": {
    "id": "9b1f…",
    "number": "HSL-2026-00412",
    "facility_id": "GH-VRH-001",
    "status": "paid",
    "currency": "GHS",
    "total": 473200,
    "amount_paid": 473200,
    "amount_due": 0,
    "due_date": "2026-11-15T00:00:00.000Z"
  }
}

id is the event id and is identical across retries — use it to de-duplicate. The same events are available by polling GET /events.

Event types

TypeWhen
subscription.createdA facility subscribed (trial or paid).
subscription.updatedPlan, terms or add-ons changed, or a cancellation was scheduled/undone.
subscription.cancelledThe subscription ended (immediately or at period end).
subscription.status_changedCommercial standing moved, e.g. active → past_due → grace → restricted, or trial → active.
invoice.createdAn invoice exists (draft or issued).
invoice.finalizedAn invoice was issued and is payable.
invoice.paidAn invoice is fully paid.
invoice.voidedAn invoice was voided.
invoice.uncollectibleAn invoice was written off.
payment.succeededMoney was received and applied (manual or Paystack).
payment.failedA Paystack payment attempt failed or was abandoned.
usage.recordedA usage batch was stored (summary: counts per metric).
implementation.updatedA setup / implementation project changed status or milestones.
server_rental.createdA rent-a-server contract started.
server_rental.updatedA rental changed — e.g. lease-to-own completed and ownership transferred.
facility.restrictedOverdue past the restriction threshold: premium add-ons paused. Clinical access remains full.
facility.restoredThe facility left restricted standing (usually after payment).

Verifying signatures

HSL-Signature is t=<unix seconds>,v1=<hex> where v1 is the HMAC-SHA256 of "<t>.<raw body>" keyed by your endpoint secret. Verify against the raw request bytes before parsing JSON, compare in constant time, and reject timestamps more than 5 minutes from your clock to stop replays.

import { createHmac, timingSafeEqual } from 'node:crypto'

export function verifyHslSignature(secret: string, header: string | null, rawBody: string, toleranceSec = 300) {
  if (!header) return false
  const parts = Object.fromEntries(header.split(',').map((p) => p.trim().split('=', 2)))
  const t = Number(parts.t)
  if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false
  const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest()
  // during secret rotation several v1 values may be present
  return header
    .split(',')
    .filter((p) => p.trim().startsWith('v1='))
    .some((p) => {
      const given = Buffer.from(p.trim().slice(3), 'hex')
      return given.length === expected.length && timingSafeEqual(given, expected)
    })
}

// Next.js route handler
export async function POST(req: Request) {
  const raw = await req.text()
  if (!verifyHslSignature(process.env.HSL_WEBHOOK_SECRET!, req.headers.get('hsl-signature'), raw)) {
    return new Response('invalid signature', { status: 400 })
  }
  const event = JSON.parse(raw)
  await queue.enqueue(event) // do the work asynchronously
  return new Response('ok')
}

Retries & failures

Any 2xx within 10 seconds is success. Anything else — a non-2xx status, a redirect, a timeout, a TLS or connection error — is a failure and is retried:

AttemptSent
1Immediately
21 min after attempt 1
35 min after attempt 2
430 min after attempt 3
52 h after attempt 4
66 h after attempt 5
712 h after attempt 6
824 h after attempt 7
  • After 8 failed attempts (about two days) the delivery is dead. It stays visible in the console and can be redelivered by hand.
  • After 25 failures in a row the endpoint is disabled. Re-enable it in the console once your receiver is fixed, then redeliver what you missed — or backfill from GET /events.
  • Delivery order is not guaranteed. Use created_at and the resource’s own state, not arrival order.

Best practices

  • Respond 200 quickly and do the work in a background job. Slow receivers time out and get retried.
  • De-duplicate on the event id: at-least-once delivery means you may see an event more than once.
  • Re-fetch the resource (GET /invoices/{id}) when you need its full, current state — events carry a summary.
  • Rotate the secret from the console if it may have leaked; the old secret stops working immediately.

No patient data

Events describe subscriptions, invoices, payments, usage counts and facility standing. They never contain patient information.