Skip to content

Commit 52515b3

Browse files
Update Webhook Triggers: Add Async and Sync (#737)
* Update Webhook Triggers: Add Async and Sync This PR updates the webhook triggers documentation with async and synchronous modes. This also updates the Webhook Ttigger image. * Update triggers.md Fixing the mixed explanation and headers * run formatter * update docs --------- Co-authored-by: Taylor Downs <taylor@openfn.org>
1 parent 7632c8f commit 52515b3

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

docs/build/triggers.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,92 @@ Trigger by adding authentication, head over to our
2525
Learn how a workflow's initial `state` gets built from a webhook trigger
2626
[here](../jobs/state#webhook-triggered-runs).
2727

28+
## **Webhook Trigger Responses**
29+
30+
When a workflow is triggered via a webhook, OpenFn can run that workflow in one
31+
of two ways, depending on how the trigger is configured and what the calling
32+
system needs.
33+
34+
### **Asynchronous mode**
35+
36+
By default, workflows are executed **asynchronously**.
37+
38+
This means OpenFn sends an HTTP response **immediately after receiving the
39+
webhook request**, once the Work Order and Run have been created.
40+
41+
**Use this mode when:**
42+
43+
- The calling system only needs confirmation that the request was received
44+
- You want fast responses and minimal coupling
45+
- The calling system does not need the result of the workflow run (or expects
46+
knowledge of the result to be delivered to another endpoint)
47+
48+
**When the response is sent:**
49+
50+
Immediately, during the same HTTP request that triggered the workflow.
51+
52+
**What this response represents:**
53+
54+
It confirms that OpenFn has accepted the request and scheduled the workflow to
55+
run. It does **not** include the workflow’s output.
56+
57+
#### The async-mode response
58+
59+
- Status code: `200`
60+
- Body:
61+
```json
62+
{
63+
"work_order_id": "abc123",
64+
"run_id": "xyz456"
65+
}
66+
```
67+
68+
### **Synchronous response (after completion)**
69+
70+
Workflows triggered by webhooks can also be configured to respond
71+
**synchronously**, after the workflow has finished running.
72+
73+
In this mode, OpenFn sends a response **after the run finishes**, returning its
74+
final status (e.g., success, failed, killed) and state.
75+
76+
**Use this mode when:**
77+
78+
- The calling system needs the result of the workflow
79+
- You need to know whether the run succeeded or failed
80+
- You want access to the workflow’s final output
81+
82+
**When the response is sent:**
83+
84+
After the workflow completes, not during the original webhook request.
85+
86+
**What this response includes:**
87+
88+
- The final output of the workflow
89+
- Metadata describing the run and its outcome
90+
91+
#### The sync-mode response
92+
93+
- Status code: `201`
94+
- Body:
95+
```json
96+
97+
{
98+
"data": {
99+
"...final": "run state goes here..."
100+
},
101+
"meta": {
102+
"work_order_id": "abc123",
103+
"run_id": "xyz456",
104+
"state": "success",
105+
"error_type": null,
106+
"inserted_at": "2025-10-23T10:15:00Z",
107+
"started_at": "2025-10-23T10:15:05Z",
108+
"claimed_at": "2025-10-23T10:15:06Z",
109+
"finished_at": "2025-10-23T10:15:20Z"
110+
}
111+
}
112+
```
113+
28114
## Cron Triggers (formerly timers)
29115

30116
**Cron Triggers** run Workflows based on a cron schedule, and are good for

static/img/webhook_trigger.webp

-7.75 KB
Loading

0 commit comments

Comments
 (0)