> ## Documentation Index
> Fetch the complete documentation index at: https://docs.barndoor.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Validate Policy

> Validate a policy before creation or update.
Checks for duplicate names and overlapping MCP server/agent combinations.
When exclude_policy_id is provided (edit mode), that policy is excluded from validation.



## OpenAPI

````yaml POST /api/v2/policies/validate
openapi: 3.1.0
info:
  title: Barndoor Platform API
  version: 1.0.0
  description: >
    REST API for the Barndoor Platform - manage MCP servers, OAuth connections,
    and proxy MCP requests.


    ## Authentication


    All endpoints require a JWT Bearer token obtained through Barndoor's

    OAuth 2.0 authorization-code flow with PKCE. The SDK handles the OAuth

    flow automatically using interactive login.


    ## MCP Integration


    The `/mcp/{mcp_server_name}` endpoints provide streaming proxy access to
    third-party MCP servers

    (Salesforce, Notion, Slack, etc.) with automatic authentication and session
    management.
  contact:
    name: Barndoor Support
    url: https://barndoor.ai
servers:
  - url: https://{organization_id}.platform.barndoor.ai
    description: Trial (Production)
    variables:
      organization_id:
        description: Your organization identifier
        default: your-org
  - url: https://{organization_id}.platform.barndoor.ai
    description: Enterprise (Production)
    variables:
      organization_id:
        description: Your organization identifier
        default: your-org
  - url: https://{organization_id}.platform.barndooruat.com
    description: Enterprise (Production)
    variables:
      organization_id:
        description: Your organization identifier
        default: your-org
  - url: https://{organization_id}.platform.barndoordev.com
    description: Enterprise (Production)
    variables:
      organization_id:
        description: Your organization identifier
        default: your-org
security:
  - BearerAuth: []
tags:
  - name: Servers
    description: Manage MCP server instances
  - name: Connections
    description: Manage OAuth connections to MCP servers
  - name: Policies
    description: Manage access control policies for agents and servers
  - name: Agents
    description: Manage AI agent registrations
  - name: MCP Proxy
    description: Proxy requests to MCP servers
paths:
  /api/v2/policies/validate:
    post:
      summary: Validate Policy
      description: >-
        Validate a policy before creation or update.

        Checks for duplicate names and overlapping MCP server/agent
        combinations.

        When exclude_policy_id is provided (edit mode), that policy is excluded
        from validation.
      operationId: validate_policy_admin_v2_policies_validate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidatePolicyRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidatePolicyResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ValidatePolicyRequest:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
          description: Policy name to validate
        mcp_server_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Mcp Server Id
          description: MCP server ID to check for overlaps
        application_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Application Ids
          description: Application IDs to check for overlaps
        exclude_policy_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Exclude Policy Id
          description: Policy ID to exclude from validation (for edit mode)
      type: object
      required:
        - name
      title: ValidatePolicyRequest
      description: Request body for validating a policy before creation.
    ValidatePolicyResponse:
      properties:
        name_is_unique:
          type: boolean
          title: Name Is Unique
          description: Whether the policy name is unique within the organization
        no_overlap_if_active:
          type: boolean
          title: No Overlap If Active
          description: Whether the policy would overlap with existing active policies
        overlapping_policy_names:
          items:
            type: string
          type: array
          title: Overlapping Policy Names
          description: Names of overlapping active policies, if any
      type: object
      required:
        - name_is_unique
        - no_overlap_if_active
      title: ValidatePolicyResponse
      description: Response for policy validation.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        JWT token obtained through Barndoor's OAuth 2.0 authorization-code

        flow with PKCE.


        The token should be included in the Authorization header:

        `Authorization: Bearer <your-jwt-token>`


        Use the Barndoor SDK's `loginInteractive()` function to obtain tokens
        automatically.
    HTTPBearer:
      type: http
      scheme: bearer

````