Skip to main content
Barndoor policies define which MCP tools an agent can use and under what conditions. This guide walks through the full policy lifecycle with the v2 API, from drafting a policy to activating it, revising it, and reviewing its history.
Estimated Time: 15-20 minutes

Before You Begin

Before getting started with policy management, you’ll need:
  • A Barndoor account with admin privileges
  • A valid bearer token for the Barndoor API
  • At least one registered MCP server
  • At least one registered agent or application
Example shell setup:
The v2 policy API replaces the older policy-style wrapper. In v2, you send a single policy object directly to /api/v2/policies, use application_ids to scope the policy, and define each rule with authorized, actions, roles_groups, and optional condition.

What You’ll Learn

In this guide, you will:
  • Validate policy scope before creation
  • Create a policy in DRAFT
  • Grant a tool outright or subject to user approval
  • Review and activate the policy
  • Update rules and metadata safely
  • List, search, and summarize policies
  • Audit policy changes through revisions
  • Clone and retire policies as part of normal lifecycle management

Step-by-Step Guide

Step 1: Validate your policy before creating it

Validate checks whether the policy name is unique and whether an active policy would overlap with the same MCP server and application scope.
Use exclude_policy_id when validating an update to an existing policy so the current record is ignored during overlap checks.
Reference: POST /api/v2/policies/validate

Step 2: Create the policy as a draft

In v2, the request body is a single policy object. There is no resourcePolicy wrapper. Important v2 fields:
  • name: Unique policy name within the organization
  • mcp_server_id: MCP server this policy controls
  • application_ids: Agents or applications this policy applies to
  • status: DRAFT, ACTIVE, INACTIVE, or ARCHIVED
  • rules: Array of policy rules
Reference: POST /api/v2/policies

Step 3: Understand the v2 rule model

Each rule in v2 uses a simpler structure than the older effect-based format.

Step 4: Require approval for a tool

A rule can grant a tool outright or grant it subject to user approval. The difference is carried in the action string: append :approve to the tool call. This is the API-level view of the same three states the portal exposes per tool — see Granular Tool Use Confirmations for the UI walkthrough and the enforcement caveats.
Use one form per tool per rule, never both. :approve is the whole grant — a tool listed as tools/call:create_issue:approve is granted, with an approval gate attached. Listing the plain action alongside it makes the approval gate moot, because the plain grant already permits the call unconfirmed.
The tri-state has no explicit deny form. “Off” is absence — a tool that no applicable rule grants is denied because nothing granted it, so turning a tool off means removing it from the rule rather than adding a rule against it. That is different from an authorized: false rule (Step 3), which serializes to a real deny and overrides any allow that would otherwise apply. Use authorized: false with a condition to carve a specific exception out of a grant; use omission to express “this group does not get this tool”.
The :approve suffix is reserved. It may appear at most once, at the end of a tool-call action — the API rejects a doubled tools/call:X:approve:approve.

How overlapping grants resolve

A user is usually in more than one group, and rules are evaluated together rather than in order. The most permissive grant wins, regardless of the order rules appear in:
This makes a broad grant capable of silencing a narrow one. If an unscoped rule (roles_groups: ["*"]) grants tools/call:create_issue plainly, then a group-scoped rule granting tools/call:create_issue:approve is dormant — those users are already allowed unconfirmed, so no approval fires. The narrower rule is not broken and does not need rewriting: remove or downgrade the broad grant and the approval requirement takes effect. Read the whole rule set, not just the rule you are editing, before concluding a tool is gated.
The same resolution is what the app’s policy detail view renders, so the UI and the API agree about a given tool’s effective state.
Approval prompting happens through Barndoor’s tool router only. On the direct MCP path, a tool granted tools/call:X:approve is permitted and executes with no prompt — the approval ceremony lives in the tool router, not in the proxy. Treat :approve as a control for tool-router traffic; for a hard stop on every path, omit the tool instead.

Step 5: Review the created policy

Capture the returned policy.id from the create response, then fetch the full policy document. Confirm the following before rollout:
  • The status is still DRAFT
  • The correct application_ids are attached
  • The mcp_server_id is correct
  • The returned rules match your intended behavior
Reference: GET /api/v2/policies/{policy_id}

Step 6: Activate or update the policy

Once reviewed, move the policy into ACTIVE. Reference: PATCH /api/v2/policies/{policy_id}

Step 7: List, search, and summarize policies

List policies: References:

Step 8: Review revision history

Every meaningful change is available through the revisions endpoint. Use revisions to:
  • Review what changed
  • See who changed it
  • Understand when the policy moved between lifecycle states
Reference: GET /api/v2/policies/{policy_id}/revisions

Step 9: Clone, deactivate, or archive a policy

Clone a policy to create a safe variation without rebuilding the rule set: References:

Legacy Endpoints

The older engine-level toggles still exist:
For new policy lifecycle workflows, prefer the v2 endpoints and the status field. Use the legacy endpoints only when you explicitly need the older engine-level toggles.

Best Practices

  • Create policies as DRAFT first, then promote to ACTIVE
  • Validate before both create and update operations
  • Keep application_ids narrow to avoid overlap with other active policies
  • Before relying on a :approve grant, check that no broader rule grants the same tool plainly — the plain grant wins and the approval never fires
  • Use descriptive tags and a support_contact so ownership is clear
  • Review revisions instead of maintaining a separate manual change log
  • Clone stable policies before making large behavior changes