> ## 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 /api-reference/openapi.yaml post /api/policy/v2/policies/validate
openapi: 3.1.0
info:
  title: Barndoor.ai Public API
  description: Unified public API specification for Barndoor.ai platform
  version: 2.18.0
servers:
  - url: https://{host}
    description: Barndoor public API
    variables:
      host:
        default: platform.barndoor.ai
        description: >-
          The host serving your Barndoor deployment. Defaults to production;
          override it for another environment or a dedicated deployment.
security:
  - ApiKey: []
  - OAuth2:
      - openid
      - profile
      - email
tags:
  - name: dlp
    x-group: Data Control Center
  - name: identity
    x-group: Identity
  - name: llm-gateway
    x-group: LLM Gateway
  - name: notification
    x-group: Notifications
  - name: policy
    x-group: Policies
  - name: registry
    x-group: MCP Gateway
  - name: system-management
    x-group: Log Exports
paths:
  /api/policy/v2/policies/validate:
    post:
      tags:
        - policy
      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
      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'
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:
            - type: array
              items:
                type: string
            - 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:
    ApiKey:
      type: http
      scheme: bearer
      description: >-
        A Barndoor API key, sent as `Authorization: Bearer <key>`. Keys are
        prefixed `bdai_` and are opaque — do not attempt to decode one.
        Interchangeable with an OAuth 2.0 access token.
    OAuth2:
      type: oauth2
      x-issuer: https://auth.barndoor.ai/realms/barndoor
      description: >-
        An OAuth 2.0 access token from Barndoor's identity provider, sent as
        `Authorization: Bearer <token>`. Public clients must use PKCE.
        Interchangeable with an API key.
      flows:
        authorizationCode:
          authorizationUrl: >-
            https://auth.barndoor.ai/realms/barndoor/protocol/openid-connect/auth
          tokenUrl: >-
            https://auth.barndoor.ai/realms/barndoor/protocol/openid-connect/token
          scopes:
            openid: Issue an OIDC ID token identifying the caller.
            profile: Read the caller's basic profile claims.
            email: Read the caller's email address.
            offline_access: Issue a refresh token. Optional — no operation requires it.
        clientCredentials:
          tokenUrl: >-
            https://auth.barndoor.ai/realms/barndoor/protocol/openid-connect/token
          scopes:
            openid: Issue an OIDC ID token identifying the caller.
            profile: Read the caller's basic profile claims.
            email: Read the caller's email address.
            offline_access: Issue a refresh token. Optional — no operation requires it.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.