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

# Update Rule

> Update an existing rule.

Only the fields you send are changed. Changing the condition source
re-validates the operator and value against the new source.



## OpenAPI

````yaml https://api.usetuner.ai/public/openapi.json put /api/v1/workspaces/{workspace_id}/agents/{agent_id}/settings/rules/{rule_id}
openapi: 3.1.0
info:
  title: My Public API
  version: 1.0.0
servers:
  - url: https://api.usetuner.ai
security: []
tags:
  - name: calls
    x-group: Calls
  - name: workspaces
    x-group: Workspaces
  - name: agent-settings
    x-group: Agent Settings
  - name: agents
    x-group: Agents
  - name: simulation
    x-group: Simulation
  - name: providers
    x-group: Providers
paths:
  /api/v1/workspaces/{workspace_id}/agents/{agent_id}/settings/rules/{rule_id}:
    put:
      tags:
        - agent-settings
      summary: Update Rule
      description: |-
        Update an existing rule.

        Only the fields you send are changed. Changing the condition source
        re-validates the operator and value against the new source.
      operationId: >-
        update_rule_api_v1_workspaces__workspace_id__agents__agent_id__settings_rules__rule_id__put
      parameters:
        - name: rule_id
          in: path
          required: true
          schema:
            type: integer
            title: Rule Id
        - name: agent_id
          in: path
          required: true
          schema:
            type: integer
            description: Tuner's internal numeric ID for the agent.
            title: Agent Id
          description: Tuner's internal numeric ID for the agent.
        - name: workspace_id
          in: path
          required: true
          schema:
            type: integer
            description: Workspace ID. Find this in Workspace > General Settings.
            title: Workspace Id
          description: Workspace ID. Find this in Workspace > General Settings.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RuleUpdate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RuleResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              example:
                detail: Not authenticated
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: You do not have access to this workspace.
          content:
            application/json:
              example:
                detail: User does not have access to workspace 42
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            The agent has no settings record, or no rule with this ID exists for
            it.
          content:
            application/json:
              example:
                detail: Rule with ID 8 not found
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - Bearer: []
components:
  schemas:
    RuleUpdate:
      properties:
        condition_source_type:
          anyOf:
            - type: string
            - type: 'null'
          enum:
            - eval
            - voice_metric
            - data_extraction_field
            - call_metadata
            - latency
          title: Condition Source Type
          description: Category of call data the condition tests.
        condition_source_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Condition Source Id
        operator:
          anyOf:
            - type: string
            - type: 'null'
          enum:
            - '='
            - '!='
            - '>='
            - <=
            - '>'
            - <
            - exists
            - not_exists
            - contains
            - starts_with
          title: Operator
          description: >-
            How to compare. Which operators are valid depends on the source's
            `input_datatype`.
        condition_value:
          anyOf:
            - {}
            - type: 'null'
          title: Condition Value
        output_type:
          anyOf:
            - type: string
            - type: 'null'
          enum:
            - label
            - red_flag
          title: Output Type
          description: Whether a matching call gets a label or a red flag.
        output_tag_name:
          anyOf:
            - type: string
              maxLength: 200
              minLength: 1
            - type: 'null'
          title: Output Tag Name
        output_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Description
          description: Optional note explaining what this rule is for.
      type: object
      title: RuleUpdate
      description: Schema for updating a rule.
    RuleResponse:
      properties:
        id:
          type: integer
          title: Id
          description: Tuner's ID for this rule.
        condition_source_type:
          type: string
          title: Condition Source Type
          description: Category of call data the condition tests.
        condition_source_id:
          type: integer
          title: Condition Source Id
          description: ID of the eval, metric, or field the condition tests.
        condition_source_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Condition Source Name
          description: Display name of the referenced eval, metric, or field.
        operator:
          type: string
          title: Operator
          description: How the value is compared.
        condition_value:
          title: Condition Value
          description: Value the condition compares against.
        output_type:
          type: string
          title: Output Type
          description: Whether matching calls get a label or a red flag.
        output_tag_name:
          type: string
          title: Output Tag Name
          description: Tag applied to matching calls.
        output_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Description
          description: Note explaining what this rule is for.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the rule was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When the rule was last updated.
      type: object
      required:
        - id
        - condition_source_type
        - condition_source_id
        - operator
        - condition_value
        - output_type
        - output_tag_name
        - created_at
        - updated_at
      title: RuleResponse
      description: Response schema for a rule.
    ErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable description of what went wrong.
      type: object
      required:
        - detail
      title: ErrorResponse
      description: Error body returned when a request fails.
    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:
    Bearer:
      type: http
      description: >-
        Use Tuner API key (tr_api_...) or user session token. Find your API key
        in Workspace Settings > API Keys.
      scheme: bearer

````