Approval (PbotApproval)
PbotApproval pauses workflow execution and waits for a person to decide. An approval resumes the workflow. A rejection ends the run and keeps the decision in its record.
Basic Usage
{
"type": "PbotApproval",
"properties": {
"comment": "Please review this expense for ${{input.amount}}",
"request_payload": {
"expense_id": "@input.id",
"amount": "@input.amount",
"category": "@input.category",
"submitted_by": "@input.employee_name"
}
}
}
When execution reaches this step, the run status changes to paused. The workflow stays paused until the approval is submitted.
Properties Reference
| Property | Type | Required | Description |
|---|---|---|---|
comment |
string | Yes | Human-readable description of what needs review. Supports {{ }} templates |
request_payload |
object | No | Structured data presented to the reviewer |
approver_role |
string | No | Role expected to review the task |
expiry_seconds |
integer | No | Time allowed for a decision |
on_expiry |
string | No | "reject": settle an undecided approval as expired and fail the run once expiry_seconds pass. See Expiry |
cases |
object | No | Decide each case in the payload separately. See Decisions per case |
result_key |
string | No | With cases, the context key that receives the outcome |
Approval Flow
1. Workflow pauses
The engine changes the run status to paused and emits a pbot_approval_requested webhook.
2. Reviewer decides
The reviewer sees the comment and request_payload. They submit their decision:
curl -X POST https://your-hyphen.example.com/approvals/{runId}/0 \
-H "X-Org-Id: acme-corp" \
-H "Content-Type: application/json" \
-d '{
"approved": true,
"comment": "Reviewed and approved - receipt verified"
}'
/approvals/:runId/:stepIdSubmit an approval decision for a paused workflow.
3. Hyphen applies the decision
An approved run resumes from the next step with the decision in context. A rejected run ends with a failed status. In both cases, the approval record keeps the reviewer, decision, comment, and timestamp.
Expiry
expiry_seconds sets how long the approval waits for a decision. on_expiry decides what happens when that time passes and nobody has decided.
{
"type": "PbotApproval",
"properties": {
"comment": "Approve the payment batch {{input.batch_id}}",
"expiry_seconds": 86400,
"on_expiry": "reject"
}
}
With on_expiry: "reject":
- A background sweep, which runs every minute, settles the approval as expired. The run status becomes
failedand no later step runs, and theworkflow_run_failedwebhook is sent with reasonapproval_expired. - The
pbot_approval_decidedwebhook is sent withapproved: false,expired: true, andreason: "expired". The run's evidence records anapproval.decidedevent withexpired: true. - A decision submitted after the expiry time is refused with
409:approval_expired, orapproval_already_decidedonce the sweep has settled the approval. A late decision that arrives before the sweep settles the approval as expired in the same way. - A decision and the sweep that arrive at the same moment produce one outcome: the decision applies or the approval expires, never both.
- In a workflow started per item by a loop with
iteration: "child_run", every approval must declareexpiry_secondsandon_expiry: "reject". The parent loop records an expired approval as that item'sexpiredoutcome.
Without on_expiry, behavior is unchanged: the approval stays pending and the run stays paused after expiry_seconds pass. A decision submitted after that time is refused with 409 (approval_expired), and the run stays paused.
on_expiry requires expiry_seconds; a workflow that declares one without the other is refused when it is validated.
Approval Response Format
| Field | Type | Required | Description |
|---|---|---|---|
approved |
boolean | Yes | Whether the reviewer approved |
comment |
string | No | Reviewer's comment |
decisions |
array | No | With cases: one decision per case. See Decisions per case |
Decisions per case
A packet of exceptions rarely gets one answer. Declare where the cases are, and the reviewer decides each one:
{
"type": "PbotApproval",
"properties": {
"comment": "Decide each receivables exception.",
"approver_role": "ar_clerk",
"request_payload": { "cases": "@proposal.cases" },
"cases": { "from": "cases", "id": "case_id", "editable": ["proposal.proposed_disposition", "proposal.message"], "undecided": "open" },
"result_key": "review"
}
}
| Field | Default | Description |
|---|---|---|
from |
"cases" |
The request_payload key, or dotted path, that holds the list of cases |
id |
"case_id" |
The field that identifies a case; ids must be present and unique |
editable |
[] |
Fields, or dotted paths into a case, a reviewer may correct when approving it |
undecided |
"open" |
What happens to a case the reviewer does not decide: "open", "approve", or "reject" |
The reviewer approves the approval and decides cases in the same call:
{
"approved": true,
"comment": "Reviewed",
"decisions": [
{ "case_id": "INV-1049", "decision": "approve" },
{ "case_id": "INV-1058", "decision": "approve", "overrides": { "proposal.proposed_disposition": "open_not_due" } },
{ "case_id": "INV-1060", "decision": "reject", "comment": "Applied to the wrong invoice." }
]
}
- Every
case_idmust be a case the reviewer was shown; the approval's fingerprint binds them. A case decided twice, a correction to a field that is not editable, and a correction on a rejected case are refused with a 400, and nothing is recorded. - Corrections are text, numbers,
trueorfalse, ornull. approved: falsestill rejects the approval and every case, and fails the run. It cannot carrydecisions.- A step without
casesrefusesdecisions. A step withcasesstill accepts a plain{ "approved": true }; every case then followsundecided. - Cases are checked when the approval is requested; a payload whose cases cannot be decided fails the step there.
The outcome is in context under @__approval_decisions.<step>.cases and, with result_key, under that key:
| Field | Contents |
|---|---|
approved_ids, rejected_ids, open_ids |
Case ids by outcome, in payload order |
approved, rejected, open |
The cases themselves; approved cases carry the reviewer's corrections |
decisions |
Each decision as made, with its comment and corrections |
undecided |
The rule that placed the undecided cases |
A later step writes only what a person approved, for example "rows": { "from": "@review.approved" } in a custom-table transaction. The ids are also on the pbot_approval_decided webhook and the approval record. Pending tasks for such a step carry case_policy (from, id, editable, undecided), so a review screen can show a control per case.
Context after approval
After an approval resumes the run, the following keys are available in context:
| Context Key | Value |
|---|---|
@__approved |
Boolean value true |
@__comment |
Comment text from the review decision |
Use the context in the next step:
{
"type": "process_expense",
"properties": {
"expense_id": "@input.id",
"approval_comment": "@__comment"
}
}
Conditional Approval
Combine with filter to only require approval under certain conditions:
{
"type": "PbotApproval",
"filter": {
"condition": {
"or": [
{ "greaterThan": ["@input.amount", 10000] },
{ "equal": ["@input.vendor_status", "new"] }
]
}
},
"properties": {
"comment": "High-value or new-vendor expense requires review",
"request_payload": {
"amount": "@input.amount",
"vendor": "@input.vendor_name"
}
}
}
When the filter evaluates to false, the step is skipped and the workflow continues. The @__approved context key is not set in this case.
Listing Pending Approvals
/approvals/:runIdList all pending approval requests for a workflow run.
Webhook Notification
When a PbotApproval step pauses a workflow, a pbot_approval_requested webhook event is emitted. Use this to notify reviewers via your application, Slack, email, or any external system.
The webhook payload includes the run_id, step_id, comment, and request_payload so your notification system can provide full context.
→ Next: Form (PbotForm)