How Approvals Work
- Step Configuration: A workflow step is configured with
type: "approval"and a list of authorized approvers. - Approval Request: When the workflow engine reaches that step, it creates a
WorkflowStepApprovalrecord and pauses the step inwaiting_for_approvalstatus. - Timeout: If
approval_timeout_secsis configured, the approval automatically expires if no action is taken within the window. - Human Action: An authorized approver calls the approve API endpoint.
- Resumption: Once approved, the step completes and the workflow engine triggers downstream dependent steps.
Defining an Approval Step
When creating a workflow, add a step withtype: "approval":
Approval Step Fields
Approving a Step
When a workflow reaches an approval step, call the approve endpoint:Request Body
approver field is required and must identify the person or system approving the step.
Response
Approval Data Model
TheWorkflowStepApproval record tracks the full approval lifecycle:
Approval Timeouts
Ifapproval_timeout_secs is set, the approval automatically expires after the specified duration:
- The approval status is set to
rejectedwith a timeout error message - The step run transitions to
failed - The workflow follows its normal failure handling (which may include step retry logic)
Multiple Approval Gates
You can have multiple approval steps in a single workflow:Monitoring Approvals
Check Pending Approvals
List workflow runs with steps waiting for approval:Webhook Notifications
When a step enters thewaiting_for_approval state, a workflow run webhook event is published. Configure your notification system (Slack, email, PagerDuty) to listen for these events and alert the appropriate approvers.
Approval steps do not require a
job_id since they don’t execute any job. They exist purely as workflow control flow gates.Event Trigger Integration
Approval steps automatically create a parallel Event Trigger when the workflow engine starts them. This means approvals can be resolved via either:- The approve API endpoint (legacy):
POST /v1/workflow-runs/{id}/steps/{ref}/approve - The event trigger API:
POST /v1/events/{eventKey}/sendwith the approval’s event key
- Real-time SSE streaming of approval status
- Webhook notifications when the approval is resolved
- Integration with external approval systems via the standard event API
Event trigger creation for approval steps is non-fatal. If the trigger creation fails (e.g., duplicate event key), the approval step still works normally via the legacy approve endpoint.
Best Practices
- Use descriptive step refs: Name approval steps clearly (e.g.,
security-review,prod-deploy-gate) so approvers understand what they are approving - Set reasonable timeouts: Avoid indefinite waits in production workflows. Set timeouts and handle the failure case
- Limit approver lists: Keep the approver list small and specific. Anyone in the list can approve
- Combine with conditions: Use step conditions to skip approval gates in low-risk scenarios (e.g., skip prod approval for hotfixes)
- Monitor pending approvals: Set up alerts for approvals that have been pending beyond a reasonable threshold
- Consider event triggers for complex approvals: For multi-party or external system approvals, use
wait_for_eventsteps instead ofapprovalsteps for more flexibility