M6-S1 — Webhooks and data-model events: tell the payroll system
Section titled “M6-S1 — Webhooks and data-model events: tell the payroll system”| Module | M6 — Integrations and live data |
| After this session you can | Make the suite tell another system what happened, reliably and safely, and agree the contract with the system’s developers. |
| Time | Facilitated: 45 min · On your own: 45 min |
| Before you start | M5-S3. The starter application of Rami Toufic waits at Respond to job offer. The address of your sandbox’s webhook inspector (a page that shows every request sent to it), from your enrolment message. Signed in as yourself; Hala Mansour in a private window. |
| Go deeper | Webhooks & integrations · Data model & events · Call another system |
◆ Orientation (1 min) — The other direction
Section titled “◆ Orientation (1 min) — The other direction”In Module 5 another program called the suite. Payroll (R-11) works the other way: the suite must tell payroll, the day a candidate signs, who was hired, without the passport number, with the key payroll issued. In M1-S1 you wrote its integration card; here you turn the card into a reaction and agree what payroll’s developers must build on their side.
▤ Concept (4 min) — Events, the record they carry, and outbound calls
Section titled “▤ Concept (4 min) — Events, the record they carry, and outbound calls”The platform’s events
Section titled “The platform’s events”Everything that happens to a record is an event, and every integration surface is built on the same vocabulary:
| Domain | Events | In a reaction |
|---|---|---|
| Record lifecycle | created, updated (with the fields that changed), archived, restored, deleted | On Entry Created, On Entry Updated, On Entry Archived, On Entry Restored |
| Workflow | step reached, step exited, action executed, owner changed | On Workflow Step Reached, On Workflow Step Exited, On Workflow Action Executed, On Owner Changed |
| Your own | an announcement, a reaction’s success or failure | On Event Announced, Reaction Succeeded, Reaction Failed |
Moving between workflow steps is a workflow event, not an update: On Entry Updated does not run on an approval. Creating a record that has a workflow runs both On Entry Created and On Workflow Step Reached for its first step.
The record an event carries
Section titled “The record an event carries”An event about a record carries the record itself. The parts an integrator reads:
{ "id": "6660a1b2…", // the record "dataEntity": "664ade91…", // its entity "state": 1, // 0 draft, 1 active, 2 archived "value": { // the fields, by normalized name "full_name": { "en": "Rami Toufic", "ar": "رامي توفيق" }, "email": "rami.toufic@example.org", "vacancy": { "dataEntity": "…", "dataEntry": "…" } // a reference: entity + record }, "creationInfo": { "doneAt": "…", "doneBy": { "dataEntity": "…", "dataEntry": "…" } }}Identify things by normalized name, which never changes, not by the localized name. A reference is always the pair entity plus record. New optional properties appear over time: ignore what you do not use.
Ways to consume events
Section titled “Ways to consume events”- A reaction listens for the event and acts: no code. Its Call API action is the platform’s outbound webhook.
- A Function runs your code on the event (M4).
- Notify Zapier posts the record to Zapier subscriptions.
- Real-time pushes changes to a connected client (M6-S2).
- Polling the API is the last resort: it is slow and costly where an event would do.
Call API, and what the platform allows
Section titled “Call API, and what the platform allows”Call API sends an HTTP request (GET, POST, PATCH, PUT or DELETE) to an API URL,
with API Headers and a Payload you write with {{name}} placeholders mapped to the
record’s values. A 2xx answer is success; anything else is a failure, and the request and answer
are kept in the run’s history. For safety it reaches only public HTTP(S) addresses (private
and internal networks are refused unless your operator allows a destination), must finish within
30 seconds, follows at most five redirects, and carries at most 10 MiB each way. Values sent
under credential headers (Authorization, X-Api-Key, Cookie) are stored as **** in the
history, and so is any value you tick Redact in history; the real value is still sent.
The receiving endpoint’s contract
Section titled “The receiving endpoint’s contract”The platform does not sign its outbound calls. So the receiver must:
- Check a secret it issued, in a header, on every call.
- Reply with a
2xxquickly, and do slow work afterwards. - Be idempotent: the same notice may arrive twice; deduplicate on the record id and event.
- Treat a notice as “this changed” and re-read the record over the API when it needs the authoritative state.
- Reconcile now and then: in rare operations, such as a restore from backup, a notice can be lost.
⛏ Lab (32 min) — The payroll notice
Section titled “⛏ Lab (32 min) — The payroll notice”Goal. When an application reaches Add employee, the suite posts a JSON notice to payroll’s address with payroll’s key in a header; the key never appears in the history; a failed call tells HR.
Before you start. Open your webhook inspector in a browser tab. It stands in for payroll’s endpoint. Use only the course’s fictional data with it.
The notice
-
Open Job Application › Reactions › +. Name Notify payroll of a hire.
-
Event On Workflow Step Reached, step Add employee. Event Executor Type System.
-
Action Type Call API. Choose HTTP Type POST; API URL your inspector’s address.
-
API Headers:
Content-Typeapplication/json, andX-Api-Keypayroll-test-key-001(the fictional key “payroll issued”). -
Payload: turn on Enable custom payload and enter in Custom Payload:
{"event": "candidate.hired", "fullName": "{{name}}", "email": "{{email}}", "startDate": "{{start}}", "jobTitle": "{{job}}"} -
Map the placeholders: name to the field Full name, email to Email, start to Available from, job to Vacancy. Confirm. Full name arrives as plain text in the space’s default language, and Vacancy as the job’s title.
The failure branch
- Add Payroll notice failed: Event Reaction Failed of Notify payroll of a hire; Triggering Space; Send Notification to HR, title Payroll was not told about {{name}}, with name mapped to Full name.
Prove it
- As Hala Mansour, open Rami Toufic’s application and select Sign contract.
- In the inspector, a
POSThas arrived with your JSON and the headerX-Api-Key: payroll-test-key-001. - As yourself, open Reaction Logs and find the run of Notify payroll of a hire: the
header shows
****, and the answer’s status is recorded. The hire chain from M3-S1 ran too: Rami Toufic has an onboarding checklist. - Make it fail on purpose. Edit the reaction: set API URL to
http://10.0.0.15/payroll, an internal address. Sign Sara Odeh’s contract as Hala Mansour. The call is refused, the failure branch runs, and Hala Mansour is notified. - Restore the inspector’s address.
Screenshot pending The Call API settings of Notify payroll of a hire: method POST, the API URL, two API Headers, and a custom payload with four placeholders What to notice: the payload is a template; the record’s values enter only through the mapped placeholders, and the passport is not one of them.
Screenshot pending The webhook inspector showing the POST from the platform, with the JSON body and the X-Api-Key header What to notice: the receiver sees the real key, while the platform’s own history stores it masked; nothing signs the request, so the key is the receiver’s only proof of the sender.
Check.
- Notify payroll of a hire runs on On Workflow Step Reached Add employee, with Call API, two headers and a mapped custom payload.
- The inspector received Rami Toufic’s notice with the four values and the key.
- Reaction Logs shows the key as
****. - The internal address was refused, and Hala Mansour got Payroll was not told about Sara Odeh.
- The API URL points at the inspector again.
Pass condition. A hire produces exactly one notice at payroll’s address with the agreed fields and the key, the key is masked in the platform’s history, and a failed notice reaches HR.
If something goes wrong
| What you see | What to do |
|---|---|
| No request arrives | Check the run in Reaction Logs: an unreachable or private address, or a timeout. Is the event On Workflow Step Reached Add employee? |
Placeholders arrive as {{name}} | The placeholder is not mapped, or its name differs from the mapping by a letter. |
| The save is refused with reserved header | One header name is reserved for the platform; use a different name for the key. |
| The failure branch did not run on the internal address | The failure branch must name Notify payroll of a hire and be active before the call runs. |
Model answer
The notice is a reaction on the workflow event that means “hired” (reaching Add employee),
because an approval is a workflow event, not an update. Its Call API action posts a payload
built only from mapped values, so nothing the card excludes, such as the passport, can leak. The
key travels in a credential header, which the history masks automatically. The failure branch
turns a refused or failed call into a notification HR acts on. Payroll’s side must check the key,
answer 2xx quickly, and ignore a repeated notice for the same application.
◇ Worked scenario (1 min) — Marketing’s spreadsheet
Section titled “◇ Worked scenario (1 min) — Marketing’s spreadsheet”Marketing wants every new hire added to a shared spreadsheet through Zapier. A colleague proposes Notify Zapier on the same event. Decide before reading on.
What Notify Zapier does. It posts the record to every Zapier subscription in the tenant, whatever entity or event the subscription was made for. Subscriptions are global, and the connector’s sample data is fixed.
The consequence. If Finance later subscribes a Zap to purchase orders, marketing’s Zap starts
receiving purchase orders too, unless every Zap filters on dataEntity.normalizedName and the
event type.
The decision. For one known destination, a Call API reaction posting to the Zap’s own catch address is narrower: only hires, only to marketing, with a payload you control. Use the Zapier connector when Zap authors must choose their own triggers, and require every Zap to filter by entity and event.
And the other way. If a Zap must make something happen in the suite, it calls the API with an OAuth token for a person (M5-S2), and only reactions you built respond.
✓ Practice (6 min) — Check your integration
Section titled “✓ Practice (6 min) — Check your integration”A reaction must notify finance when a purchase request is approved. The builder chose On Entry Updated. It never runs. Why?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
Payroll’s developers ask how to be sure a notice really comes from the suite. What do you tell them?
Check your answer
The correct answer is C. Open the explanation under each option to see why.
A Call API reaction posts to http://192.168.4.20/hooks and always fails, though the address
works from the builder’s laptop. Why?
Check your answer
The correct answer is A. Open the explanation under each option to see why.
After a server restart, payroll receives the same hire notice twice and creates two employees. Whose design should change?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
An integration reads a referenced record from an event’s value. What shape does it expect?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
↺ Recap (1 min) — Telling the world
Section titled “↺ Recap (1 min) — Telling the world”You know the events the platform emits and the record they carry, built an outbound webhook with a masked credential and a failure branch, and can write the receiver’s contract and choose among the integration surfaces.
Next. In M6-S2 a client stops asking and starts listening: HR’s wall screen, live.