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
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 - 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. 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 noresourcePolicy wrapper.
Important v2 fields:
name: Unique policy name within the organizationmcp_server_id: MCP server this policy controlsapplication_ids: Agents or applications this policy applies tostatus:DRAFT,ACTIVE,INACTIVE, orARCHIVEDrules: Array of policy rules
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: Review the created policy
Capture the returnedpolicy.id from the create response, then fetch the full policy document.
Confirm the following before rollout:
- The
statusis stillDRAFT - The correct
application_idsare attached - The
mcp_server_idis correct - The returned
rulesmatch your intended behavior
GET /api/v2/policies/{policy_id}
Step 5: Activate or update the policy
Once reviewed, move the policy intoACTIVE.
Reference: PATCH /api/v2/policies/{policy_id}
Step 6: List, search, and summarize policies
List policies: References:Step 7: 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
GET /api/v2/policies/{policy_id}/revisions
Step 8: 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:Best Practices
- Create policies as
DRAFTfirst, then promote toACTIVE - Validate before both create and update operations
- Keep
application_idsnarrow to avoid overlap with other active policies - Use descriptive tags and a
support_contactso ownership is clear - Review revisions instead of maintaining a separate manual change log
- Clone stable policies before making large behavior changes