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:
Copy
// 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);}
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);