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

# Delete Policy

> Retrieve, update, or delete a single policy by ID

Delete a policy and all of its versions. This operation is irreversible.

<Warning>
  Policies cannot be deleted while they are in use by any agent. You must first unlink all agents from the policy before deleting it.
</Warning>

## Path Parameters

| Parameter | Type | Required | Description                  |
| --------- | ---- | -------- | ---------------------------- |
| `id`      | uuid | Yes      | UUID of the policy to delete |

## Query Parameters

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

<RequestExample>
  ```bash cURL theme={null}
  curl --request DELETE \
    --url "https://api.roe-ai.com/v1/policies/POLICY_ID/?organization_id=YOUR_ORG_ID" \
    --header "Authorization: Bearer YOUR_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 204 theme={null}
  // No content - policy successfully deleted
  ```

  ```json 409 theme={null}
  {
    "error": "Cannot delete policy - it is in use by agents",
    "dependent_agents": [
      {
        "base_agent_id": "abc12345-e89b-12d3-a456-426614174000",
        "agent_name": "Document Reviewer",
        "version_id": "def67890-e89b-12d3-a456-426614174001",
        "version_name": "v2"
      }
    ]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml DELETE /policies/{id}/
openapi: 3.1.0
info:
  title: Roe API
  version: 1.0.0
  description: Complete API documentation for Roe platform
servers:
  - url: https://api.roe-ai.com
    description: Production API
security: []
paths:
  /policies/{id}/:
    delete:
      tags:
        - policies
      description: Retrieve, update, or delete a single policy by ID
      operationId: policies_destroy
      parameters:
        - in: path
          name: 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.
      responses:
        '204':
          description: Policy deleted successfully.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetailResponse'
          description: Policy not found.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolicyDeleteConflict'
          description: Policy is in use by agents and cannot be deleted.
      security:
        - jwtAuth: []
components:
  schemas:
    ErrorDetailResponse:
      type: object
      description: 'DRF default error body: NotFound, PermissionDenied, Http404, etc.'
      properties:
        detail:
          type: string
          description: Human-readable error detail
      required:
        - detail
    PolicyDeleteConflict:
      type: object
      description: 409 body when a policy cannot be deleted because agents reference it.
      properties:
        error:
          type: string
        dependent_agents:
          type: array
          items:
            $ref: '#/components/schemas/DependentAgentInfo'
      required:
        - dependent_agents
        - error
    DependentAgentInfo:
      type: object
      description: An agent version that references a policy (see get_agents_using_policy).
      properties:
        base_agent_id:
          type: string
          format: uuid
        agent_name:
          type: string
        version_id:
          type: string
          format: uuid
        version_name:
          type: string
      required:
        - agent_name
        - base_agent_id
        - version_id
        - version_name
  securitySchemes:
    jwtAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````