-
Notifications
You must be signed in to change notification settings - Fork 19
Update Webhook Triggers: Add Async and Sync #737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,92 @@ Trigger by adding authentication, head over to our | |
| Learn how a workflow's initial `state` gets built from a webhook trigger | ||
| [here](../jobs/state#webhook-triggered-runs). | ||
|
|
||
| ## **Webhook Trigger Responses** | ||
|
|
||
| When a workflow is triggered via a webhook, OpenFn can run that workflow in one | ||
| of two ways, depending on how the trigger is configured and what the calling | ||
| system needs. | ||
|
|
||
| ### **Asynchronous mode** | ||
|
|
||
| By default, workflows are executed **asynchronously**. | ||
|
|
||
| This means OpenFn sends an HTTP response **immediately after receiving the | ||
| webhook request**, once the Work Order and Run have been created. | ||
|
|
||
| **Use this mode when:** | ||
|
|
||
| - The calling system only needs confirmation that the request was received | ||
| - You want fast responses and minimal coupling | ||
| - The calling system does not need the result of the workflow run (or expects | ||
| knowledge of the result to be delivered to another endpoint) | ||
|
|
||
| **When the response is sent:** | ||
|
|
||
| Immediately, during the same HTTP request that triggered the workflow. | ||
|
|
||
| **What this response represents:** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add ? at the end
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put this down as a statement more than a question Tuch. Do you think it'll make more sense as a question?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh okay 🤔 , If the explanation is in a newline then it looks like a question but if it's oneline it's fine as is |
||
|
|
||
| It confirms that OpenFn has accepted the request and scheduled the workflow to | ||
| run. It does **not** include the workflow’s output. | ||
|
|
||
| #### The async-mode response | ||
|
|
||
| - Status code: `200` | ||
| - Body: | ||
| ```json | ||
| { | ||
| "work_order_id": "abc123", | ||
| "run_id": "xyz456" | ||
| } | ||
| ``` | ||
|
|
||
| ### **Synchronous response (after completion)** | ||
|
|
||
| Workflows triggered by webhooks can also be configured to respond | ||
| **synchronously**, after the workflow has finished running. | ||
|
|
||
| In this mode, OpenFn sends a response **after the run finishes**, returning its | ||
| final status (e.g., success, failed, killed) and state. | ||
|
|
||
| **Use this mode when:** | ||
|
|
||
| - The calling system needs the result of the workflow | ||
| - You need to know whether the run succeeded or failed | ||
| - You want access to the workflow’s final output | ||
|
|
||
| **When the response is sent:** | ||
|
|
||
| After the workflow completes, not during the original webhook request. | ||
|
|
||
| **What this response includes:** | ||
|
|
||
| - The final output of the workflow | ||
| - Metadata describing the run and its outcome | ||
|
|
||
| #### The sync-mode response | ||
|
|
||
| - Status code: `201` | ||
| - Body: | ||
| ```json | ||
|
|
||
| { | ||
| "data": { | ||
| "...final": "run state goes here..." | ||
| }, | ||
| "meta": { | ||
| "work_order_id": "abc123", | ||
| "run_id": "xyz456", | ||
| "state": "success", | ||
| "error_type": null, | ||
| "inserted_at": "2025-10-23T10:15:00Z", | ||
| "started_at": "2025-10-23T10:15:05Z", | ||
| "claimed_at": "2025-10-23T10:15:06Z", | ||
| "finished_at": "2025-10-23T10:15:20Z" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Cron Triggers (formerly timers) | ||
|
|
||
| **Cron Triggers** run Workflows based on a cron schedule, and are good for | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add ? at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put this down as a statement more than a question Tuch. Do you think it'll make more sense as a question?