You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docs/content/docs/en/blocks/human-in-the-loop.mdx
+93-12Lines changed: 93 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ Defines the fields approvers fill in when responding. This data becomes availabl
78
78
}
79
79
```
80
80
81
-
Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
81
+
Access resume data in downstream blocks using `<blockId.fieldName>`.
82
82
83
83
## Approval Methods
84
84
@@ -93,11 +93,12 @@ Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
93
93
<Tab>
94
94
### REST API
95
95
96
-
Programmatically resume workflows using the resume endpoint. The `contextId` is available from the block's `resumeEndpoint` output or from the paused execution detail.
96
+
Programmatically resume workflows using the resume endpoint. The `contextId` is available from the block's `resumeEndpoint` output or from the `_resume` object in the paused execution response.
97
97
98
98
```bash
99
99
POST /api/resume/{workflowId}/{executionId}/{contextId}
100
100
Content-Type: application/json
101
+
X-API-Key: your-api-key
101
102
102
103
{
103
104
"input": {
@@ -107,23 +108,56 @@ Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
107
108
}
108
109
```
109
110
110
-
The response includes a new `executionId` for the resumed execution:
111
+
The resume endpoint automatically respects the execution mode used in the original execute call:
112
+
113
+
- **Sync mode** (default) — The response waits for the remaining workflow to complete and returns the full result:
If the resumed workflow hits another HITL block, the response returns `"status": "paused"` with new `_resume` URLs in the output.
126
+
127
+
- **Stream mode** (`stream: true` on the original execute call) — The resume response streams SSE events with `selectedOutputs` chunks, just like the initial execution.
128
+
129
+
- **Async mode** (`X-Execution-Mode: async` on the original execute call) — The resume dispatches execution to a background worker and returns immediately with `202`, including a `jobId` and `statusUrl` for polling:
111
130
112
131
```json
113
132
{
114
-
"status": "started",
133
+
"success": true,
134
+
"async": true,
135
+
"jobId": "<jobId>",
115
136
"executionId": "<resumeExecutionId>",
116
-
"message": "Resume execution started."
137
+
"message": "Resume execution queued",
138
+
"statusUrl": "/api/jobs/<jobId>"
117
139
}
118
140
```
119
141
120
-
To poll execution progress after resuming, connect to the SSE stream:
142
+
#### Polling execution status
143
+
144
+
Poll the `statusUrl` from the async response to check when the resume completes:
121
145
122
146
```bash
123
-
GET /api/workflows/{workflowId}/executions/{resumeExecutionId}/stream
147
+
GET /api/jobs/{jobId}
148
+
X-API-Key: your-api-key
124
149
```
125
150
126
-
Build custom approval UIs or integrate with existing systems.
151
+
Returns job status and, when completed, the full workflow output.
152
+
153
+
To check on a paused execution's pause points and resume links:
154
+
155
+
```bash
156
+
GET /api/resume/{workflowId}/{executionId}
157
+
X-API-Key: your-api-key
158
+
```
159
+
160
+
Returns the paused execution detail with all pause points, their statuses, and resume links. Returns `404` when the execution has completed and is no longer paused.
127
161
</Tab>
128
162
<Tab>
129
163
### Webhook
@@ -132,6 +166,53 @@ Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
132
166
</Tab>
133
167
</Tabs>
134
168
169
+
## API Execute Behavior
170
+
171
+
When triggering a workflow via the execute API (`POST /api/workflows/{id}/execute`), HITL blocks cause the execution to pause and return the `_resume` data in the response:
Blocks before the HITL stream their `selectedOutputs` normally. When execution pauses, the final SSE event includes `status: "paused"` and the `_resume` data:
On resume, blocks after the HITL stream their `selectedOutputs` the same way.
206
+
207
+
<Callouttype="info">
208
+
HITL blocks are automatically excluded from the `selectedOutputs` dropdown since their data is always included in the pause response.
209
+
</Callout>
210
+
</Tab>
211
+
<Tab>
212
+
Returns `202` immediately. Use the polling endpoint to check when the execution pauses.
213
+
</Tab>
214
+
</Tabs>
215
+
135
216
## Common Use Cases
136
217
137
218
**Content Approval** - Review AI-generated content before publishing
@@ -161,9 +242,9 @@ Agent (Generate) → Human in the Loop (QA) → Gmail (Send)
161
242
**`response`** - Display data shown to the approver (json)
162
243
**`submission`** - Form submission data from the approver (json)
163
244
**`submittedAt`** - ISO timestamp when the workflow was resumed
164
-
**`resumeInput.*`** - All fields defined in Resume Form become available after the workflow resumes
245
+
**`<fieldName>`** - All fields defined in Resume Form become available at the top level after the workflow resumes
165
246
166
-
Access using `<blockId.resumeInput.fieldName>`.
247
+
Access using `<blockId.fieldName>`.
167
248
168
249
## Example
169
250
@@ -187,7 +268,7 @@ Access using `<blockId.resumeInput.fieldName>`.
187
268
**Downstream Usage:**
188
269
```javascript
189
270
// Condition block
190
-
<approval1.resumeInput.approved>===true
271
+
<approval1.approved>===true
191
272
```
192
273
The example below shows an approval portal as seen by an approver after the workflow is paused. Approvers can review the data and provide inputs as a part of the workflow resumption. The approval portal can be accessed directly via the unique URL, `<blockId.url>`.
193
274
@@ -204,7 +285,7 @@ The example below shows an approval portal as seen by an approver after the work
204
285
<FAQitems={[
205
286
{ question: "How long does the workflow stay paused?", answer: "The workflow pauses indefinitely until a human provides input through the approval portal, the REST API, or a webhook. There is no automatic timeout — it will wait until someone responds." },
206
287
{ question: "What notification channels can I use to alert approvers?", answer: "You can configure notifications through Slack, Gmail, Microsoft Teams, SMS (via Twilio), or custom webhooks. Include the approval URL in your notification message so approvers can access the portal directly." },
207
-
{ question: "How do I access the approver's input in downstream blocks?", answer: "Use the syntax <blockId.resumeInput.fieldName> to reference specific fields from the resume form. For example, if your block ID is 'approval1' and the form has an 'approved' field, use <approval1.resumeInput.approved>." },
288
+
{ question: "How do I access the approver's input in downstream blocks?", answer: "Use the syntax <blockId.fieldName> to reference specific fields from the resume form. For example, if your block name is 'approval1' and the form has an 'approved' field, use <approval1.approved>." },
208
289
{ question: "Can I chain multiple Human in the Loop blocks for multi-stage approvals?", answer: "Yes. You can place multiple Human in the Loop blocks in sequence to create multi-stage approval workflows. Each block pauses independently and can have its own notification configuration and resume form fields." },
209
290
{ question: "Can I resume the workflow programmatically without the portal?", answer: "Yes. Each block exposes a resume API endpoint that you can call with a POST request containing the form data as JSON. This lets you build custom approval UIs or integrate with existing systems like Jira or ServiceNow." },
210
291
{ question: "What outputs are available after the workflow resumes?", answer: "The block outputs include the approval portal URL, the resume API endpoint URL, the display data shown to the approver, the form submission data, the raw resume input, and an ISO timestamp of when the workflow was resumed." },
0 commit comments