Require Approval
Configuring approval requirements for actions in your application
The requireApproval
Pattern
The core feature of OK!Gotcha is the ability to wrap functions with approval requirements. This is done using the requireApproval
decorator (Python) or higher-order function (TypeScript), which transforms regular functions into approval-gated functions.
How It Works
When a function is wrapped with requireApproval
:
- Calling the function creates an approval request instead of executing immediately
- The function’s parameters are captured and serialized
- Approvers are notified through configured channels
- The function remains pending until approved or rejected
- Upon approval, the original function executes with the captured parameters
- Results are returned to the original caller (if using await/async patterns)
OK!Gotcha handles all the complexities of managing approval state, notifications, and execution flow, allowing you to focus on your business logic.
Approval Configuration Options
The requireApproval
function accepts a configuration object with the following properties:
A short, descriptive title for the approval request.
A detailed description of what the approval request is for.
An array of approver IDs or teams who can approve or reject the request.
Time in seconds until the approval request expires (defaults to 24 hours).
Minimum number of approvals required (defaults to 1).
Additional custom data to store with the approval request.
Advanced Usage
Conditional Approval Requirements
You can dynamically determine if approval is required based on the function parameters:
Custom Approval Handlers
You can provide custom logic for handling approvals with the onApproved
and onRejected
callbacks:
Next Steps
- Learn about integration methods for implementing approvals
- Explore audit trails for tracking approval activities
- Set up notifications for approval requests