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

# Set policy mode for an agent

> **Auth:** organization API key with `write` scope, or a signed-in user.

Body: `{"enforcement_mode": "enforce" | "monitor"}`. Runs the policy in its own mode for one agent it covers, for example enforced for one agent and monitored for another. `404` if the policy doesn't cover the agent.



## OpenAPI

````yaml https://cp.xenovia.io/openapi.json put /api/v1/policies/{policy_id}/agents/{agent_id}/mode
openapi: 3.1.0
info:
  title: Xenovia Control Plane API
  version: 1.0.0
  description: >-
    Management API for agents, providers, policies, telemetry, alerts and
    organization settings.
servers:
  - url: https://cp.xenovia.io
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v1/policies/{policy_id}/agents/{agent_id}/mode:
    put:
      tags:
        - policies
      summary: Set policy mode for an agent
      description: >-
        **Auth:** organization API key with `write` scope, or a signed-in user.


        Body: `{"enforcement_mode": "enforce" | "monitor"}`. Runs the policy in
        its own mode for one agent it covers, for example enforced for one agent
        and monitored for another. `404` if the policy doesn't cover the agent.
      operationId: >-
        set_policy_agent_mode_route_api_v1_policies__policy_id__agents__agent_id__mode_put
      parameters:
        - name: policy_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Policy Id
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Agent Id
        - name: X-Request-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Request-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PolicyAgentModeSet'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolicyRead'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    PolicyAgentModeSet:
      properties:
        enforcement_mode:
          type: string
          enum:
            - enforce
            - monitor
          title: Enforcement Mode
      type: object
      required:
        - enforcement_mode
      title: PolicyAgentModeSet
      description: 'PUT /policies/{id}/agents/{agent_id}/mode: the mode for that agent.'
    PolicyRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        agent_ids:
          items:
            type: string
            format: uuid
          type: array
          title: Agent Ids
        agents:
          items:
            $ref: '#/components/schemas/PolicyAgentRef'
          type: array
          title: Agents
        agent_modes:
          additionalProperties:
            type: string
          propertyNames:
            format: uuid
          type: object
          title: Agent Modes
        org_id:
          type: string
          format: uuid
          title: Org Id
        owner_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Owner Id
        name:
          type: string
          title: Name
        category:
          type: string
          title: Category
        summary:
          type: string
          title: Summary
        rego:
          type: string
          title: Rego
        enabled:
          type: boolean
          title: Enabled
        stage:
          type: string
          title: Stage
        enforcement_mode:
          type: string
          title: Enforcement Mode
          default: enforce
        template_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Template Id
        template_version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Template Version
        framework_tags:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Framework Tags
        control_mappings:
          anyOf:
            - items:
                $ref: '#/components/schemas/ControlMapping'
              type: array
            - type: 'null'
          title: Control Mappings
        parameter_values:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Parameter Values
        version:
          type: integer
          title: Version
          default: 1
        baseline_target:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Baseline Target
        conformance_cases:
          anyOf:
            - items:
                $ref: '#/components/schemas/ConformanceCase'
              type: array
            - type: 'null'
          title: Conformance Cases
        conformance:
          anyOf:
            - $ref: '#/components/schemas/ConformanceResult'
            - type: 'null'
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        warnings:
          items:
            type: string
          type: array
          title: Warnings
          readOnly: true
        group:
          type: string
          title: Group
          readOnly: true
        template_controls_outdated:
          type: boolean
          title: Template Controls Outdated
          readOnly: true
      type: object
      required:
        - id
        - org_id
        - owner_id
        - name
        - category
        - summary
        - rego
        - enabled
        - stage
        - created_at
        - updated_at
        - warnings
        - group
        - template_controls_outdated
      title: PolicyRead
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PolicyAgentRef:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        name:
          type: string
          title: Name
        provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider
        coding_tool:
          anyOf:
            - type: string
            - type: 'null'
          title: Coding Tool
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
      type: object
      required:
        - id
        - name
      title: PolicyAgentRef
      description: |-
        An agent a policy covers; ``provider`` is its primary provider's kind,
        ``coding_tool`` the coding tool it governs (claude_code, codex, cursor).
    ControlMapping:
      properties:
        framework:
          type: string
          minLength: 1
          title: Framework
        controls:
          items:
            type: string
          type: array
          minItems: 1
          title: Controls
        rationale:
          type: string
          maxLength: 280
          title: Rationale
          default: ''
      type: object
      required:
        - framework
        - controls
      title: ControlMapping
      description: |-
        A template's claim, carried by the policies made from it, that the
        rule contributes evidence for these controls of one framework. IDs are
        the catalog's (app/compliance/control_catalog.yaml).
    ConformanceCase:
      properties:
        name:
          type: string
          maxLength: 120
          minLength: 1
          title: Name
        stage:
          anyOf:
            - type: string
              enum:
                - request
                - response
            - type: 'null'
          title: Stage
        parameters:
          additionalProperties: true
          type: object
          title: Parameters
        input:
          additionalProperties: true
          type: object
          title: Input
        expect:
          $ref: '#/components/schemas/ConformanceExpectation'
      type: object
      required:
        - name
        - input
        - expect
      title: ConformanceCase
    ConformanceResult:
      properties:
        ran_at:
          type: string
          format: date-time
          title: Ran At
        opa_version:
          anyOf:
            - type: string
            - type: 'null'
          title: Opa Version
        source:
          type: string
          enum:
            - template
            - policy
          title: Source
        passed:
          type: integer
          title: Passed
        failed:
          type: integer
          title: Failed
        cases:
          items:
            $ref: '#/components/schemas/ConformanceCaseResult'
          type: array
          title: Cases
      type: object
      required:
        - ran_at
        - opa_version
        - source
        - passed
        - failed
        - cases
      title: ConformanceResult
      description: |-
        The last run of a policy's cases: what an auditor reads next to the
        control the policy is evidence for.
    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
    ConformanceExpectation:
      properties:
        action:
          type: string
          maxLength: 32
          minLength: 1
          title: Action
        rule:
          anyOf:
            - type: string
              maxLength: 255
            - type: 'null'
          title: Rule
      type: object
      required:
        - action
      title: ConformanceExpectation
    ConformanceCaseResult:
      properties:
        name:
          type: string
          title: Name
        stage:
          type: string
          enum:
            - request
            - response
          title: Stage
        expected_action:
          type: string
          title: Expected Action
        expected_rule:
          anyOf:
            - type: string
            - type: 'null'
          title: Expected Rule
        got_action:
          type: string
          title: Got Action
        got_rule:
          anyOf:
            - type: string
            - type: 'null'
          title: Got Rule
        ok:
          type: boolean
          title: Ok
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
      type: object
      required:
        - name
        - stage
        - expected_action
        - got_action
        - ok
      title: ConformanceCaseResult
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token: an organization API key (`ak_…`) created under Settings →
        API Keys, or a dashboard user session token. Agent keys (`xe_…`) are not
        accepted here. Endpoints marked as user-only in their description reject
        organization keys with `403`.

````

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