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

# Create Policy Version

> Create a new policy version or list all versions of a specific policy

Create a new version of an existing policy. The new version is automatically set as the current version for the policy.

<Info>
  Creating a new version does not modify existing versions. All previous versions remain accessible and can be restored using the [Set Current Version](/api-reference/policies/set-current-version) endpoint.
</Info>

## Path Parameters

| Parameter   | Type | Required | Description                            |
| ----------- | ---- | -------- | -------------------------------------- |
| `policy_id` | uuid | Yes      | UUID of the policy to add a version to |

## Query Parameters

| Parameter         | Type | Required | Description                                 |
| ----------------- | ---- | -------- | ------------------------------------------- |
| `organization_id` | uuid | Yes      | UUID of the organization for access control |

## Request Body

| Field          | Type   | Required | Description                                                               |
| -------------- | ------ | -------- | ------------------------------------------------------------------------- |
| `version_name` | string | No       | Name for this version (auto-generated if not provided, e.g., "version 2") |
| `content`      | object | Yes      | Policy content structure (see below)                                      |

### Content Object

The `content` field accepts a JSON object with the following optional sections:

| Field                                         | Type   | Description                                                     |
| --------------------------------------------- | ------ | --------------------------------------------------------------- |
| `guidelines`                                  | object | Hierarchical structure with `categories` array containing rules |
| `guidelines.categories[].title`               | string | Category title (required)                                       |
| `guidelines.categories[].description`         | string | Category description (optional)                                 |
| `guidelines.categories[].rules`               | array  | List of rules in this category                                  |
| `guidelines.categories[].rules[].title`       | string | Rule title (required)                                           |
| `guidelines.categories[].rules[].description` | string | Rule description (optional)                                     |
| `guidelines.categories[].rules[].flag`        | string | `GREEN_FLAG` or `RED_FLAG` (optional)                           |
| `guidelines.categories[].rules[].sub_rules`   | array  | Nested sub-rules (optional)                                     |
| `instructions`                                | string | Free-form text instructions for the agent                       |
| `dispositions`                                | object | Classification options with `classifications` array             |
| `dispositions.classifications[].name`         | string | Classification name (required)                                  |
| `dispositions.classifications[].description`  | string | Classification description (optional)                           |
| `dispositions.classifications[].prompt`       | string | Prompt for when to use this classification (optional)           |
| `summary_template`                            | object | Template for generating summaries                               |
| `summary_template.template`                   | string | Handlebars-style template string                                |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url "https://api.roe-ai.com/v1/policies/POLICY_ID/versions/?organization_id=YOUR_ORG_ID" \
    --header "Authorization: Bearer YOUR_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{
      "version_name": "version 2",
      "content": {
        "guidelines": {
          "categories": [
            {
              "title": "Updated Verification Rules",
              "rules": [
                {
                  "title": "Enhanced signature validation",
                  "description": "All signatures must be verified against the authorized signatory list",
                  "flag": "RED_FLAG"
                }
              ]
            }
          ]
        },
        "instructions": "Apply enhanced review procedures.",
        "dispositions": {
          "classifications": [
            {"name": "Approved", "description": "Document passes all checks"},
            {"name": "Rejected", "description": "Document fails one or more checks"}
          ]
        }
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": "456e7890-e89b-12d3-a456-426614174002",
    "version_name": "version 2",
    "content": {
      "guidelines": {
        "categories": [
          {
            "title": "Updated Verification Rules",
            "rules": [
              {
                "title": "Enhanced signature validation",
                "description": "All signatures must be verified against the authorized signatory list",
                "flag": "RED_FLAG"
              }
            ]
          }
        ]
      },
      "instructions": "Apply enhanced review procedures.",
      "dispositions": {
        "classifications": [
          {"name": "Approved", "description": "Document passes all checks"},
          {"name": "Rejected", "description": "Document fails one or more checks"}
        ]
      }
    }
  }
  ```

  ```json 400 Missing required fields theme={null}
  {
    "content": ["This field is required."]
  }
  ```

  ```json 400 Invalid content structure theme={null}
  {
    "content": ["Invalid new format content: guidelines.categories[0].rules[0].title must be a non-empty string"]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /policies/{policy_id}/versions/
openapi: 3.1.0
info:
  title: Roe AI API
  version: 1.0.0
  description: Complete API documentation for Roe AI platform
servers:
  - url: https://api.roe-ai.com
    description: Production API
security: []
paths:
  /policies/{policy_id}/versions/:
    post:
      tags:
        - policies
      description: Create a new policy version or list all versions of a specific policy
      operationId: policies_versions_create
      parameters:
        - in: path
          name: policy_id
          schema:
            type: string
            format: uuid
          required: true
        - name: organization_id
          in: query
          required: false
          schema:
            type: string
            format: uuid
          description: >-
            Organization ID. This is required for access control. It can be
            provided via query or request body depending on the endpoint.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePolicyVersionRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePolicyVersion'
          description: ''
      security:
        - jwtAuth: []
components:
  schemas:
    CreatePolicyVersionRequest:
      type: object
      description: Serializer for creating a new policy version
      properties:
        version_name:
          type: string
          minLength: 1
          description: Version name (auto-generated if not provided)
          maxLength: 255
        content: {}
        base_version_id:
          type: string
          format: uuid
          writeOnly: true
          description: ID of the version this was derived from
      required:
        - content
    CreatePolicyVersion:
      type: object
      description: Serializer for creating a new policy version
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        version_name:
          type: string
          description: Version name (auto-generated if not provided)
          maxLength: 255
        content: {}
      required:
        - content
        - id
  securitySchemes:
    jwtAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````