Approvals
A workflow step written call: praxis/approval opens an approval task (a HumanTask) for the people you name and then waits. Once an assignee decides in the Console or through the API, the workflow continues from that step and the decision is the step’s output. Waiting uses no compute and costs nothing; a workflow run can wait up to 30 days.
praxis/approval is a built-in function, not an Action: a script cannot call("approval"). Write it only in workflow YAML, and not inside a fork branch.
Open an approval
document: { dsl: "1.0.3", namespace: shop, name: refund, version: "1.0.0" }do: - approveRefund: call: praxis/approval with: title: "${ \"Refund $\" + (.amount | tostring) + \" for order \" + .order_id }" body: | The customer requested a refund. Check the order amount. context: "${ { order_id: .order_id, amount: .amount } }" assignees: users: [usr_finance_lead, usr_ops_manager] mode: any due: P2D on_timeout: { action: reject } form: type: object properties: refund_amount: { type: number, minimum: 0 } required: [refund_amount] - decide: switch: - approved: when: "${ .decision == \"approve\" }" then: refund - otherwise: then: end - refund: call: shop/refund with: order_id: "${ $workflow.input.order_id }" amount: "${ .values.refund_amount }"For a long wait, create the run with deadline_seconds longer than due (workflows allow up to 2592000 seconds, 30 days). due cannot exceed the run’s remaining time; when omitted it defaults to 3 days, cut to the run’s remaining time.
with arguments
| Argument | Meaning |
|---|---|
title | Required, at most 200 characters. |
body | Markdown details, up to 16 KiB. |
context | Attached JSON (for example the order), up to 32 KiB. |
actions | 1–6 buttons {id, label, style?, require_comment?}; style is primary, danger or default. Defaults to approve (primary) and reject (danger). |
form | The form assignees fill in: type: object with at most 30 string, number, integer, boolean or enum fields, plus optional required. |
assignees | Required, {users: [user ids…]}, 1–20 people. groups is not supported yet. |
mode | any (default), all, quorum, sequential; see below. |
quorum | Approvals needed in mode: quorum. |
allow_self_approval | Default false: the person who started the run cannot approve their own request. |
allow_agent_decision | Default false: agents cannot respond on someone’s behalf. |
due | ISO 8601 duration, default P3D, at most P30D. |
on_timeout | {action: reject | approve | fault}, default fault. escalate is not supported yet. |
remind | Up to 3 durations; stored, reminders are not sent yet. |
proposal | An agent’s proposal (JSON) for the assignees to consider. |
channels | console, email; stored, notification delivery is not wired yet. |
Arguments written as ${…} expressions are checked when the step runs; the rest are checked when you save and publish the workflow.
Step output
{ "decision": "approve", "values": { "refund_amount": 120 }, "comment": "Amount matches the order", "decided_by": { "id": "usr_finance_lead", "kind": "human", "display_name": null }, "responses": [ … ]}decision is the deciding action id. values and comment come from the deciding response; responses lists every response submitted.
Decision rules
mode | Rule |
|---|---|
any | The first response decides. |
all | Everyone must respond; any rejection rejects at once. |
quorum | quorum approvals approve; it rejects as soon as that many approvals are no longer possible. |
sequential | Assignees respond in users order; any rejection rejects at once and the last approval approves. |
all, quorum and sequential need exactly two buttons: one style: danger rejection and one approval. When two assignees respond at the same moment, exactly one decides and the other receives TASK_CLOSED.
Timeouts
If nobody decides by due, on_timeout applies and the task becomes expired:
reject/approve: the step output hasdecisiontimeout:rejectortimeout:approveanddecided_bynull.fault(default): the step raises atimeouterror, whichtrycan catch:
- guard: try: - approve: call: praxis/approval with: { title: Release to production, assignees: { users: [usr_release_owner] }, due: PT4H } catch: errors: with: { type: https://serverlessworkflow.io/spec/1.0.0/errors/timeout } do: - giveUp: set: { released: false }When an approval is cancelled, the step raises a runtime error with code HUMAN_TASK_CANCELLED. When a run ends (completed, faulted or cancelled), its open approvals are cancelled automatically.
Respond
An assignee’s inbox is List human tasks: by default the open tasks assigned to the caller.
curl --fail-with-body -sS "$PRAXIS_API_URL/automation/v1/human-tasks" \ -H "Authorization: Bearer $PRAXIS_API_KEY"Respond with the task id:
curl --fail-with-body -sS "$PRAXIS_API_URL/automation/v1/human-tasks/$TASK/respond" \ -H "Authorization: Bearer $PRAXIS_API_KEY" \ -H 'Content-Type: application/json' \ -H "Idempotency-Key: $(uuidgen)" \ --data '{"action_id":"approve","values":{"refund_amount":120},"comment":"Amount matches the order"}'It returns the updated task; once decided, status is completed and outcome is what the workflow receives. An assignee can also delegate to another user, and the initiator can cancel. An approval wait ends only this way: completing it through the run’s wait completion endpoint is refused.
| Error | When |
|---|---|
NOT_ASSIGNED | You are not an assignee, or it is not your turn in sequential mode. |
SELF_APPROVAL | The initiator responds to their own request without allow_self_approval. |
AGENT_NOT_ALLOWED | An agent session or run token responds without allow_agent_decision. |
ALREADY_RESPONDED | You already responded. |
COMMENT_REQUIRED | The chosen action requires a comment. |
INVALID_ACTION / INVALID_VALUES | No such action / values do not match form. |
TASK_CLOSED | The approval was already decided, expired or cancelled. |
Next steps
- Triggers: start a workflow on a schedule or a webhook.
- Approve, act and read back: wire an approval into a complete action flow.
- Limits and errors: approval timeouts, capacity and troubleshooting.