Authentication & scopes
Every request carries an API key. Each key has an explicit list of scopes. A developer key is also confined to one facility: a test key to the sandbox, a live key to a facility your account was approved for.
API keys
Send the key as a bearer token:
curl https://admin.heka.care/api/platform/v1/facilities -H "Authorization: Bearer hsl_live_9f3a1c2b…"| Part | Meaning |
|---|---|
hsl_live_ | Live key. Acts on one real facility, within the scopes approved for your account on that facility. |
hsl_test_ | Test key. Same API, but it always acts on the sandbox facility HSL-SANDBOX, which holds synthetic data only. |
9f3a1c2b | The visible prefix — shown in the console and logs so you can tell keys apart. |
| the rest | Secret. 32 random bytes. The hub stores only its SHA-256 hash, so a lost key cannot be recovered — only replaced. |
A missing, malformed, unknown, revoked or expired key returns 401 with an authentication_error and a specific code: missing_api_key, invalid_api_key, api_key_revoked or api_key_expired.
Your developer account
Keys belong to a developer account. Create one at /developers/signup; the hub e-mails you a set-up link, where you choose your password, and you are then signed in to the console. If the hub cannot send e-mail, a Heka SoftLink administrator sends you the set-up link instead.
- Test keys are self-serve: create them in the console whenever you need them.
- Live access is requested in the console and approved by a Heka SoftLink administrator, per facility, with the scopes allowed on each.
- Live access needs two-step verification (an authenticator app) on your account. It cannot be approved while two-step verification is off, and you cannot turn it off while live access is approved.
- Every live change in the console asks for a current code from your authenticator app: creating or rotating a live key, and creating, changing, enabling or rotating the secret of a live webhook.
Test and live keys
| Test key | Live key | |
|---|---|---|
| Facility | Always HSL-SANDBOX, whatever else the key says | The facility it was created for, while your grant for it is active |
| Data | Synthetic: no real people, facilities or money | Real facility data, within your grant |
| Who creates it | You, in the console | You, in the console, after live access is approved, with a code from your authenticator app |
| Scopes | Any developer scope | Only scopes on your grant for that facility, never a sandbox-only scope |
The hub checks a key’s account, live access and grant on every request, with no cache, so a change takes effect on the next request. When a key cannot be used, the error says why:
| Status | Code | Meaning |
|---|---|---|
| 401 | api_key_disabled | The developer account that owns the key is not active (for example, suspended). |
| 403 | live_access_required | Live access is not approved for the account, or two-step verification is off. |
| 403 | facility_access_revoked | The account no longer has a grant for the live key’s facility. |
| 503 | sandbox_unavailable | The sandbox facility is not set up on this hub yet, so test keys cannot be used. |
Scopes
There is no wildcard. A request needs every scope its endpoint lists (shown on each operation in the reference); otherwise it gets 403 insufficient_scope with the missing scopes in error.details.missing.
| Scope | Grants |
|---|---|
plans:read | Read plans and add-ons (the public price book). |
facilities:read | Read facility profiles and balances. |
subscriptions:read | Read subscriptions, their add-ons and status. |
subscriptions:write | Create subscriptions, change plans, set add-ons and cancel. |
invoices:read | Read invoices, line items and payments applied to them. |
invoices:write | Create manual invoices, finalize and void them. |
payments:read | Read payments. |
payments:write | Record manual payments and create Paystack checkout links. |
usage:write | Report metered usage (NHIA claims, SMS, AI requests…). |
entitlements:read | Read the features, limits and commercial state of a facility. |
events:read | Read the platform event log. |
webhooks:manage | Create, list and delete webhook endpoints. Not available to facility-scoped admin keys; a developer key reaches only its own endpoints. |
analytics:read | Read network revenue analytics (MRR, ARR, retention, receivables). Not available to facility-scoped keys. |
A developer key can hold only some of these:
- Developer scopes:
plans:read,facilities:read,subscriptions:read,invoices:read,payments:read,entitlements:read,events:read,usage:write,webhooks:manage. - Live grants can carry:
plans:read,facilities:read,subscriptions:read,invoices:read,payments:read,entitlements:read,events:read,webhooks:manage. - Sandbox only:
usage:write. Reporting usage changes a facility’s bill, so it is never part of a live grant. - Never on a developer key:
subscriptions:write,invoices:write,payments:write,analytics:read.
- Finance / ERP sync:
invoices:read,payments:read,events:read, andwebhooks:managefor your own endpoints. - Showing a facility’s plan and standing:
facilities:read,subscriptions:read,entitlements:read. - Trying out usage reporting:
usage:writeon a test key, in the sandbox.
Facility-scoped keys
Every developer key is confined to one facility. Every query it makes is filtered to that facility:
- Lists return only that facility’s records.
- Fetching or changing another facility’s resource returns
404, not403— the key cannot even learn that the resource exists. - Request bodies may omit
facility_id; if present it must match. webhooks:manageon a developer key reaches only your own account’s endpoints, in the key’s environment: a test key sees test endpoints, a live key sees live endpoints.- Keys issued by Heka SoftLink administrators can be confined to one facility too. Such a key cannot hold the network-wide scopes
webhooks:manage,analytics:read.
Rotation & revocation
- Create one key per integration so each can be revoked on its own. An account can hold up to 10 active keys.
- Rotate in the console issues a new key and keeps the old one working for 24 hours, then it expires. Deploy the new key, confirm traffic in the request log, and revoke the old key early if you like. Rotating a live key asks for a code.
- Revoke takes effect on the next request.
- Keys may carry an expiry date; expired keys fail with
api_key_expired. - The console shows when each key was last used, and the request log lists every call. Investigate any traffic you do not recognise.