GebSecure Docs v0.1.0

Guides · Security

Human approvals

How approval requests are created, routed, decided, expired, escalated and consumed — and how agents resume.

When a decision is APPROVAL_REQUIRED, GebSecure creates an approval request bound to the exact action and routes it to the eligible reviewers. The action runs only after the approval is granted, and the approval can be used exactly once, for exactly that action.

What requires approval#

  • a require approval clause on an applicable permit, or an effect require_approval policy (GSL);
  • a risk score above the organization's approvalAbove threshold (policy id risk-threshold);
  • an agent tainted by prompt injection attempting a write, delete or admin action (injection-taint, see prompt injection);
  • outbound DLP with action REQUIRE_APPROVAL (dlp-outbound, see DLP);
  • the organization setting requireApprovalInProduction for agents in a production-tier environment (org-production-approval).

These platform gates require one approval from anyone holding approvals:decide. A dry run ("dryRun": true) never creates a request.

The snapshot#

The request stores a snapshot of the action — organization, environment, principal, action, resource, resource attributes, context and, for executions, {connectionId, action, requestHash} — canonicalized and hashed (snapshotHash). The hash is signed (a JWT with type gs-approval+jwt). A pending request for an identical snapshot is reused (approval.created: false) instead of creating a second one. Reviewers decide on the snapshot they saw: the decision must carry its snapshotHash, and the server refuses it if the request changed ("The action changed since you reviewed it; reload and review again").

Lifecycle#

Status Meaning
pending waiting for decisions
approved every step approved
rejected one reviewer rejected (remaining steps are cancelled)
expired not decided before expiresAt
cancelled cancelled by the requester, the owner or an administrator
consumed used by the approved action (single use)
  • Expiry — the expires of the approval block, capped by the organization's defaultApprovalTtlMinutes (default 60, 1–10080). The worker expires due requests every five seconds.
  • Escalation — halfway to expiry an undecided request escalates once: a new parallel step is added for the roles owner, admin and security_admin, and the event approval.escalated is emitted.
  • Steps — each parallel requirement is one step needing min approvals; a sequential requirement with min N becomes N one-approval steps decided in order (after all parallel steps). The request is approved when the last step is.

Who can approve#

  • Only humans (users, or API keys acting for them) approve; agents cannot.
  • Requesters can never approve their own actions, and each person decides a request at most once — min 2 needs two different people.
  • Approver kinds: role "<role>" (organization role, project role binding or custom role), team "<id or slug>", user "<id or email>", and owner (the agent's owner user or a member of its owner team). role and team approvers also need the approvals:decide permission. With no approvers listed, anyone holding approvals:decide may decide.
  • Built-in roles with approvals:decide: owner, admin, approver and the project role project_approver.

Deciding#

Channel How
Console the Approvals inbox; approval links are PUBLIC_CONSOLE_URL/approvals/{id}
API POST {api}/v1/approvals/{id}/decision with {decision: "approve" | "reject", snapshotHash, comment?, channel?}
Slack interactive Approve / Reject buttons, when the Slack channel has a bot token, signing secret and channel
Teams, email notifications with a link to the console

The SDKs wrap the reviewer API — this is the reviewer of the example agent:

examples/typescript-agent/src/approve.ts
// The inbox lists pending approvals this reviewer can decide right now; this reviewer handles refunds only.
const inbox = await reviewer.listApprovals({ inbox: true, status: 'pending' });
const refunds = inbox.data.filter((a) => a.action === 'rest:refunds.create');
for (const a of refunds) {
  // Decide on exactly what was reviewed: the snapshot hash binds the decision to the request.
  const details = await reviewer.getApprovalDetails(a.id);
  console.log(`${verdict} ${a.id}: ${details.action} on ${details.resource} — ${details.reason ?? ''}`);
  const result = await reviewer.decideApproval(a.id, {
    decision: verdict,
    snapshotHash: details.snapshotHash!,
    comment: verdict === 'approve' ? 'Verified the duplicate charge' : 'Refund not justified',
    channel: 'api',
  });
  console.log(`  → ${result.status}`);
}

Other endpoints: GET /v1/approvals (status, inbox=true for what you can decide now, agentId, projectId), GET /v1/approvals/{id} (steps, decisions, comments, history, canDecide), POST /v1/approvals/{id}/cancel and POST /v1/approvals/{id}/comments. Agents poll the agent-facing subset with GET {gateway}/v1/approvals/{id}.

Notifications#

Notification channels (POST /v1/notification-channels, permission approvals:configure) subscribe to approval.requested, approval.completed and approval.escalated (and security.alert) by default:

Type Configuration
webhook url; signed with a whsec_… secret (shown once) in gebsecure-signature, with gebsecure-event-type and gebsecure-event-id
email to[], includeApprovers (default true: owners, admins, security admins, approvers and the agent's owner); needs SMTP_URL
slack webhookUrl, or botToken + signingSecret + channel for interactive buttons
teams webhookUrl (Adaptive Card with a link to the console)

To decide from Slack, link the Slack user to a GebSecure user with POST /v1/chat-identities ({provider: "slack", externalId, userId?}). Deliveries are retried with backoff and dropped after eight attempts.

Resuming the agent#

How the agent asked After approval
POST /v1/authorize Call authorize again with the identical request and approvalId. The decision becomes ALLOW and the approval is consumed. A forbid still wins ("approval … cannot override a denial").
POST /v1/execute The execution is stored as awaiting_approval (HTTP 202). The worker resumes it within about a second of the approval, replaying the stored, encrypted input with the approval; poll GET /v1/executions/{executionId}. Rejected, expired or cancelled approvals close the execution as denied or cancelled (error code approval_<status>).
MCP tools/call Send the identical call again; the gateway finds and consumes the approved request for the same snapshot.
Database query (POST /v1/db/query), browser action HTTP 202 with approval.id; once approved, resend the identical request with approvalId. It runs once; any change is refused.

The example agent follows a resumed execution like this:

examples/typescript-agent/src/agent.ts
// 4. A larger refund needs a human approval (policy: amount > 100). The execution is stored as
//    awaiting_approval; once a reviewer approves, the GebSecure worker resumes it with the approval
//    (consumed exactly once, only for this exact request). The agent waits and follows the execution.
const large = await gs.execute({ connection, action: 'refunds.create', input: { chargeId: 'ch_0977', amount: 400, currency: 'USD' } }, child);
if (large.status === 'awaiting_approval' && large.approval && large.executionId) {
  console.log(`refund $400: waiting for approval ${large.approval.id} (${large.approval.url ?? 'console'})`);
  try {
    const approval = await gs.waitForApproval(large.approval.id, { ...child, timeoutMs: approvalTimeoutMs, pollIntervalMs: 2_000 });
    // "consumed" means the worker already resumed the execution with it.
    if (approval.status !== 'approved' && approval.status !== 'consumed') throw new ApprovalNotGrantedError(approval);
    const done = await waitForExecution(large.executionId);
    console.log(`refund $400: ${done.status} ${JSON.stringify(done.output ?? done.error)}`);
    outcomes.largeRefund = done.status;
  } catch (e) {
    if (e instanceof ApprovalNotGrantedError) outcomes.largeRefund = `approval ${e.approval.status}`;
    else if (e instanceof ApprovalTimeoutError) outcomes.largeRefund = 'approval timed out';
    else throw e;
    console.log(`refund $400: ${outcomes.largeRefund}`);
  }
} else {
  summarize('refund $400', large);
  outcomes.largeRefund = large.status;
}

The SDK helper executeWithApproval (execute_with_approval, ExecuteWithApproval, ExecuteWithApprovalAsync) does the same in one call from SDK 0.2.1: it executes, waits for the approval and then polls the execution until it is terminal. It never re-executes, raises ApprovalNotGranted for a rejected, expired or cancelled approval and returns a resumed execution that failed as a result with status: "failed".

Warning

SDK 0.2.0 and earlier re-executed the request after the approval and raced the worker ("Approval has already been used", consumed). Upgrade to 0.2.1; see troubleshooting.

Two-person rule for administrators#

Administrative actions can require a second administrator's approval: configure PUT /v1/governance/admin-policies with per-action {requireApproval, approverRole, min} for org.settings.update, members.role.change, members.remove, policies.deploy, secrets.delete, sso.connection.delete, api_keys.create or custom_roles.manage. The first call then fails with approval_required and details.approvalId; after the approval, repeat it with the header x-gebsecure-approval-id: <approvalId>.