Skip to content

M6-S1 — Webhooks and data-model events: tell the payroll system

Section titled “M6-S1 — Webhooks and data-model events: tell the payroll system”
ModuleM6 — Integrations and live data
After this session you canMake the suite tell another system what happened, reliably and safely, and agree the contract with the system’s developers.
TimeFacilitated: 45 min · On your own: 45 min
Before you startM5-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 deeperWebhooks & 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”

Everything that happens to a record is an event, and every integration surface is built on the same vocabulary:

DomainEventsIn a reaction
Record lifecyclecreated, updated (with the fields that changed), archived, restored, deletedOn Entry Created, On Entry Updated, On Entry Archived, On Entry Restored
Workflowstep reached, step exited, action executed, owner changedOn Workflow Step Reached, On Workflow Step Exited, On Workflow Action Executed, On Owner Changed
Your ownan announcement, a reaction’s success or failureOn 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.

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.

  • 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 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 platform does not sign its outbound calls. So the receiver must:

  1. Check a secret it issued, in a header, on every call.
  2. Reply with a 2xx quickly, and do slow work afterwards.
  3. Be idempotent: the same notice may arrive twice; deduplicate on the record id and event.
  4. Treat a notice as “this changed” and re-read the record over the API when it needs the authoritative state.
  5. Reconcile now and then: in rare operations, such as a restore from backup, a notice can be lost.

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

  1. Open Job Application › Reactions › +. Name Notify payroll of a hire.

  2. Event On Workflow Step Reached, step Add employee. Event Executor Type System.

  3. Action Type Call API. Choose HTTP Type POST; API URL your inspector’s address.

  4. API Headers: Content-Type application/json, and X-Api-Key payroll-test-key-001 (the fictional key “payroll issued”).

  5. Payload: turn on Enable custom payload and enter in Custom Payload:

    {"event": "candidate.hired", "fullName": "{{name}}", "email": "{{email}}", "startDate": "{{start}}", "jobTitle": "{{job}}"}
  6. 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

  1. 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

  1. As Hala Mansour, open Rami Toufic’s application and select Sign contract.
  2. In the inspector, a POST has arrived with your JSON and the header X-Api-Key: payroll-test-key-001.
  3. 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.
  4. 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.
  5. 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 seeWhat to do
No request arrivesCheck 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 headerOne header name is reserved for the platform; use a different name for the key.
The failure branch did not run on the internal addressThe 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”
PracticeChoose one answer.

A reaction must notify finance when a purchase request is approved. The builder chose On Entry Updated. It never runs. Why?

  1. Explanation for A

    ✗ Incorrect

    Not this one: without watched fields it runs on any update; the problem is that an approval is not an update. See the platform’s events.

  2. Explanation for B

    ✓ Correct

    Correct: use On Workflow Action Executed or On Workflow Step Reached for an approval. See the platform’s events.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the workflow events exist exactly for this. See the platform’s events.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

Payroll’s developers ask how to be sure a notice really comes from the suite. What do you tell them?

  1. Explanation for A

    ✗ Incorrect

    Not this one: the platform does not sign outbound calls. See the receiving endpoint’s contract.

  2. Explanation for B

    ✗ Incorrect

    Not this one: addresses change with the deployment, and it is not the agreed contract. See the receiving endpoint’s contract.

  3. Explanation for C

    ✓ Correct

    Correct: a key the receiver issues and checks on every call is the proof. See the receiving endpoint’s contract.

Check your answer

The correct answer is C. Open the explanation under each option to see why.

PracticeChoose one answer.

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?

  1. Explanation for A

    ✓ Correct

    Correct: Call API reaches public addresses only, for safety. See Call API, and what the platform allows.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the rule is about private networks, not the scheme. See Call API, and what the platform allows.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the limit is 30 seconds, and the call never reaches the endpoint. See Call API, and what the platform allows.

Check your answer

The correct answer is A. Open the explanation under each option to see why.

PracticeChoose one answer.

After a server restart, payroll receives the same hire notice twice and creates two employees. Whose design should change?

  1. Explanation for A

    ✗ Incorrect

    Not this one: a repeated run can happen, and the contract plans for it. See the receiving endpoint’s contract.

  2. Explanation for B

    ✓ Correct

    Correct: idempotency on the record id is part of the receiving contract. See the receiving endpoint’s contract.

  3. Explanation for C

    ✗ Incorrect

    Not this one: a duplicate payroll record is a real error, and it is preventable. See the receiving endpoint’s contract.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

An integration reads a referenced record from an event’s value. What shape does it expect?

  1. Explanation for A

    ✗ Incorrect

    Not this one: a reference stores which record, not its text, so it survives renames. See the record an event carries.

  2. Explanation for B

    ✓ Correct

    Correct: every reference is the pair entity plus record. See the record an event carries.

  3. Explanation for C

    ✗ Incorrect

    Not this one: an id alone does not say which entity it belongs to. See the record an event carries.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

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.