Web Hooks¶
Web Hooks let AbraFlexi notify your application about changes in near real
time (usually within a few seconds) instead of you polling the
Changes API. For every registered hook the server sends
an HTTP POST to the hook’s URL; the body lists the changes since the
previous call, in the same format as the Changes API.
Notifications sent to hooks do not count towards the daily API request limit.
Prerequisites¶
The Changes API must be enabled for the company.
Hooks must be enabled on the server. On self-hosted installations set
enableHookstotrueinflexibee-server.xml(cloud customers have this configured already).
Without enabled hooks every /hooks endpoint returns 400 with the
message “Hooks are not enabled in flexibee-server.xml”.
Registering a hook¶
PUT or POST /c/{company}/hooks
Parameter |
Required |
Description |
|---|---|---|
|
yes |
URL the server will call. |
|
yes |
|
|
no |
Start sending from the version following this one. Defaults to the
current |
|
no |
Secret sent with every notification in the |
|
no |
|
curl -k -L -u user:password -X PUT \
"https://server:5434/c/company/hooks.xml?url=https://example.com/hook&format=JSON&secKey=s3cret" \
-H Content-Length:0
At registration the server sends an empty test notification to the URL.
If the response is not 2xx, the hook is not registered. Success returns
200; failure returns 400 with a description. HTTPS virtual hosts are
supported (SNI) since version 2017.1.1.
A hook cannot be filtered by record or evidence — it receives every change, and your application has to pick the relevant ones itself.
Listing and unregistering¶
GET /c/{company}/hooks — list registered hooks
DELETE /c/{company}/hooks/{id} — unregister a hook
Notification body¶
The body is the same change listing as returned by /c/{company}/changes
(see Changes API): globalVersion, the changed records with
in-version / operation (create / update / delete) and ids,
and next. The notification only identifies what changed — fetch the
current data of the record through the regular API.
Failures, retries and redirects¶
A failed call is retried; while failures continue the delay between attempts grows (a “penalty”).
Hooks are stored in the database and survive a server restart. No change is lost — all changes are delivered once the endpoint recovers.
Current penalty:
GET /c/{company}/hooks/{id}.Reset the penalty and call immediately:
PUT /c/{company}/hooks/{id}/retry.
Response codes of your endpoint with special meaning:
Code |
Effect |
|---|---|
|
Notification accepted. |
|
The hook’s URL is updated to the redirect target; notifications resume there after a short penalty. |
|
The hook is considered permanently cancelled and is unregistered automatically. |
other |
Failure — retried with penalty. |
Receiver recommendations¶
Delivery is best effort: expect delays and duplicates; use
globalVersionto deduplicate.Answer quickly — aim for under 15 seconds, the hard limit is 30 seconds. Violating it penalizes the hook and may eventually disable it.
Return
200(or another2xx) with an empty body.Persist the received changes immediately and process them asynchronously.
Verify the
X-FB-Hook-SecKeyheader if you registered asecKey.After downtime, or if you suspect a gap, resynchronize through the Changes API (
?start=the last processed version).
Company restore¶
When restoring a company, the disableWebHooks option deregisters all
hooks (see Company management).