ZakFin developers
A read-only API and signed webhooks, for the plan that includes API access. These pages are in English.
Start
The workspace owner or an admin signs in to ZakFin, opens Developers, and makes a key: a name, the scopes it may use, the companies it may see, an optional expiry and a rate limit. The key is shown once. Zakaria keeps only a hash, so a lost key cannot be shown again; make a new one and revoke the old.
curl -H "Authorization: Bearer zka_YOUR_KEY" \
https://YOUR-ZAKARIA-ADDRESS/api/v1/receivables
A key is read-only. It cannot create, change, send, pay or approve anything, cannot see people, billing or settings, and only reaches the endpoints below. Every call is recorded in the workspace activity log under the key's name.
To test without real customer figures, make a key limited to the demo company (Control Center, demo company). There is no separate sandbox server.
Endpoints (version 1)
Base address: /api/v1. The machine-readable description is /api/v1/openapi.json (OpenAPI 3).
| Call | Scope | What it returns |
|---|---|---|
| Loading… | ||
Scopes
| Scope | Meaning |
|---|---|
| Loading… | |
A key limited to some companies only sees those. Amounts are numbers in the currency shown with them. Totals are never added across currencies.
Limits and errors
- Each key has its own limit, 1 to 600 calls a minute (60 by default). Every answer has
RateLimit-LimitandRateLimit-Remaining. Over the limit you get429andRetry-Afterin seconds. 401the key is missing, wrong, expired or revoked (all look the same).403the key lacks the scope, or the plan has no API access.404unknown endpoint or company.400a bad parameter.- Errors are JSON:
{"error": "…"}. Every answer carriesX-Zakaria-API-Version. - Usage shown in Developers is approximate: calls are counted in memory and saved about every 30 seconds.
Webhooks
ZakFin can tell your system when something happens. Add an https address under Developers and choose the events. The address must be public: private networks and redirects are refused.
| Event | When |
|---|---|
| Loading… | |
A message is JSON: {"id", "type", "created", "workspace", "data"}. data holds names, ids and amounts only (for example the invoice number), never a bank detail, key or document. Ask the API for the rest. Use id to ignore a message you already handled.
Check the signature
Each message has Zakaria-Signature: t=UNIX_SECONDS,v1=HEX. The value is HMAC-SHA256 of t + "." + raw body with the endpoint's secret (shown once, starts with whsec_). Compare in constant time and reject a t older than 5 minutes.
// Node
const crypto = require('crypto');
function valid(secret, header, rawBody) {
const p = Object.fromEntries(header.split(',').map((x) => x.split('=')));
if (Math.abs(Date.now() / 1000 - Number(p.t)) > 300) return false;
const mac = crypto.createHmac('sha256', secret).update(p.t + '.' + rawBody).digest('hex');
return mac.length === p.v1.length && crypto.timingSafeEqual(Buffer.from(mac), Buffer.from(p.v1));
}
# Python
import hmac, hashlib, time
def valid(secret, header, raw_body):
p = dict(x.split('=', 1) for x in header.split(','))
if abs(time.time() - int(p['t'])) > 300: return False
mac = hmac.new(secret.encode(), (p['t'] + '.').encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(mac, p['v1'])
Delivery
- Answer with any
2xxwithin a few seconds. Anything else is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then given up. - After 15 messages in a row are given up, the address is switched off and you are told in Developers. Switch it on again once the receiver works.
- Delivery is at least once and not strictly ordered. Handle a repeat of the same
id. - Headers:
Zakaria-Event,Zakaria-Delivery,Zakaria-Signature. Use Send a test in Developers to see your receiver work. - Rotating a secret stops the old one at once.
Versions and changes
The address carries the version (/api/v1). Within a version we add fields and endpoints but do not remove or rename them or change their meaning. A new version is a new address. When a version is replaced it stays available for at least 12 months, answers carry Deprecation and Sunset headers, and the change is written in the release notes first. Only version 1 exists today.
Not built yet
OAuth sign-in for other apps, write endpoints (creating invoices, recording payments), an official SDK, a separate sandbox server with test credentials, and an extension framework. Today: scoped read-only keys, signed webhooks, this page and the OpenAPI file.