Skip to main content
sec0-sdk/guard is the smallest Sec0 integration surface. Use it when you want policy decisions in application code without wrapping a tool server. Typical uses:
  • outbound message checks before sending to Slack, Discord, email, or SMS
  • preflight checks around external API calls
  • tool or MCP decisions in apps that do not use sec0-sdk/middleware
  • approval workflows that need a simple create, wait, and resolve loop

Core API

createSec0Guard(...) returns three methods: Decision outcomes are:

Choose a Mode

Standalone Example

Use standalone mode when the application must work without network access:

Dashboard Example

Use dashboard mode when policy should come from the control plane:

Hybrid Example

Use hybrid mode when the remote policy should be primary but local fallback must still work:
If the remote policy fails after a prior successful fetch, the guard can continue from its remote cache. If no cache exists, hybrid mode falls back to the local provider.

Execute with Redaction or Block Handlers

guard.execute(...) lets you customize what happens on redact and block outcomes:

Escalations and Approvals Transport

The guard can create and wait on escalations, and it can forward those escalation events to the open-source approvals bridge.
The transport emits escalation.created and escalation.finalized events to the bridge. Deploy the reference worker in apps/sec0-approvals-bridge when you want Discord or Telegram approval flows. If your application already knows when to escalate and does not need policy evaluation, use createEscalationManager(...) from sec0-sdk/escalation instead of sec0-sdk/guard. Guard now builds on that same shared escalation lifecycle.

Waiting on an Existing Escalation

If your application stores the escalation id and resolves it later:
The final status is one of approved, rejected, expired, or timeout. The equivalent standalone API is:

When to Use Guard vs Middleware

Use sec0-sdk/guard when the action lives in application code. Use sec0-sdk/middleware when the action is a tool-server invocation and you want registry freeze, source hashing, signed envelopes, and server-side policy enforcement on every call.