The OK!Gotcha SDK provides a direct integration path for adding human approval workflows to your applications. It offers fine-grained control over approval processes and seamlessly integrates with your existing code.
The core functionality of OK!Gotcha is to add approval requirements to your functions:
// Original functionconst deleteUser = async (userId: string): Promise<boolean> => { // Implementation to delete a user return true;};// Add approval requirementconst secureDeleteUser = ok.requireApproval({ title: "User Deletion", description: "Permanently delete a user account", approvers: ["admin-team"]})(deleteUser);// Usage remains the sametry { const result = await secureDeleteUser("user-123"); console.log("User deletion initiated, pending approval");} catch (error) { console.error("Error:", error);}
// Original functionconst deleteUser = async (userId: string): Promise<boolean> => { // Implementation to delete a user return true;};// Add approval requirementconst secureDeleteUser = ok.requireApproval({ title: "User Deletion", description: "Permanently delete a user account", approvers: ["admin-team"]})(deleteUser);// Usage remains the sametry { const result = await secureDeleteUser("user-123"); console.log("User deletion initiated, pending approval");} catch (error) { console.error("Error:", error);}
# Using decorator syntax@ok.require_approval( title="User Deletion", description="Permanently delete a user account", approvers=["admin-team"])def delete_user(user_id: str) -> bool: # Implementation to delete a user return True# Usage remains the sametry: result = delete_user("user-123") print("User deletion initiated, pending approval")except Exception as e: print(f"Error: {e}")
When a function is wrapped with requireApproval, it will not execute immediately. Instead, it creates an approval request and returns a promise/future that resolves when approval is granted.
// Get the approval ID from the result of a requireApproval functionconst { approvalId } = await secureFunction(arg1, arg2, { returnApprovalId: true });// Check statusconst status = await ok.getApprovalStatus(approvalId);console.log("Current status:", status);
// Get the approval ID from the result of a requireApproval functionconst { approvalId } = await secureFunction(arg1, arg2, { returnApprovalId: true });// Check statusconst status = await ok.getApprovalStatus(approvalId);console.log("Current status:", status);
# Get the approval ID from the result of a require_approval functionapproval_id = secure_function(arg1, arg2, return_approval_id=True)# Check statusstatus = ok.get_approval_status(approval_id)print(f"Current status: {status}")