> ## 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.

# Clone Policy

> Clone an existing policy, creating a new policy with the same configuration
but with a modified name (appending " Copy") and DRAFT status.



## OpenAPI

````yaml POST /api/v2/policies/{policy_id}/clone
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/{policy_id}/clone:
    post:
      summary: Clone Policy
      description: >-
        Clone an existing policy, creating a new policy with the same
        configuration

        but with a modified name (appending " Copy") and DRAFT status.
      operationId: clone_policy_admin_v2_policies__policy_id__clone_post
      parameters:
        - name: policy_id
          in: path
          required: true
          schema:
            type: string
            title: Policy Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolicyDetailResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    PolicyDetailResponse:
      properties:
        policy:
          $ref: '#/components/schemas/PolicyDetail'
      type: object
      required:
        - policy
      title: PolicyDetailResponse
      description: Envelope for detail responses.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PolicyDetail:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        organization_id:
          type: string
          title: Organization Id
        name:
          type: string
          title: Name
        status:
          type: string
          title: Status
        support_contact:
          anyOf:
            - type: string
            - type: 'null'
          title: Support Contact
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        mcp_server_id:
          type: string
          title: Mcp Server Id
        application_ids:
          items:
            type: string
          type: array
          title: Application Ids
        tags:
          items:
            type: string
          type: array
          title: Tags
        rules:
          items:
            $ref: '#/components/schemas/PolicyRule-Output'
          type: array
          title: Rules
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        created_by_user_id:
          type: string
          title: Created By User Id
        updated_by_user_id:
          type: string
          title: Updated By User Id
      type: object
      required:
        - id
        - organization_id
        - name
        - status
        - mcp_server_id
        - created_at
        - updated_at
        - created_by_user_id
        - updated_by_user_id
      title: PolicyDetail
      description: Detailed representation of a policy including rules.
    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
    PolicyRule-Output:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Optional display name for the rule
          default: ''
        authorized:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Authorized
          description: Determines if the actions are allowed (True) or denied (False)
          default: false
        actions:
          items:
            type: string
          type: array
          title: Actions
          description: Actions this rule applies to
        roles_groups:
          items:
            type: string
          type: array
          title: Roles Groups
          description: Roles or groups this rule applies to
        condition:
          anyOf:
            - $ref: '#/components/schemas/PolicyRuleCondition-Output'
            - type: 'null'
          description: Optional condition that must be met for the rule to apply
      type: object
      title: PolicyRule
      description: Represents a single policy rule with compatible conditions.
    PolicyRuleCondition-Output:
      properties:
        match:
          oneOf:
            - $ref: '#/components/schemas/Expression'
            - $ref: '#/components/schemas/OperatorAll-Output'
            - $ref: '#/components/schemas/OperatorAny-Output'
            - $ref: '#/components/schemas/OperatorNone-Output'
          title: Match
      type: object
      required:
        - match
      title: PolicyRuleCondition
    Expression:
      properties:
        expr:
          type: string
          title: Expr
      type: object
      required:
        - expr
      title: Expression
    OperatorAll-Output:
      properties:
        all:
          $ref: '#/components/schemas/ConditionOf-Output'
      type: object
      required:
        - all
      title: OperatorAll
    OperatorAny-Output:
      properties:
        any:
          $ref: '#/components/schemas/ConditionOf-Output'
      type: object
      required:
        - any
      title: OperatorAny
    OperatorNone-Output:
      properties:
        none:
          $ref: '#/components/schemas/ConditionOf-Output'
      type: object
      required:
        - none
      title: OperatorNone
    ConditionOf-Output:
      properties:
        of:
          items:
            oneOf:
              - $ref: '#/components/schemas/Expression'
              - $ref: '#/components/schemas/OperatorAll-Output'
              - $ref: '#/components/schemas/OperatorAny-Output'
              - $ref: '#/components/schemas/OperatorNone-Output'
          type: array
          title: Of
      type: object
      required:
        - of
      title: ConditionOf
  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

````