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

# Update a ruleset

Updates one or more properties of an existing ruleset. All fields are optional - only provided fields will be updated. When updating priority, the system automatically reorders other rules to maintain consistent priority ordering. Validates that any updated trigger, filters, or actions are properly configured and compatible with each other.


## OpenAPI

````yaml https://api.getfernand.com/openapi.json patch /organization/rules/{id}
openapi: 3.0.3
info:
  title: Fernand API Documentation
  version: '3.0'
  description: This is the documentation for the [Fernand](https://getfernand.com) API.
  termsOfService: https://getfernand.com/terms
  contact:
    name: Fernand Support
    url: https://getfernand.com
    email: support@getfernand.com
  x-logo:
    url: https://app.getfernand.com/images/favicon/icon_128.png
servers:
  - url: https://api.getfernand.com
    description: ''
    x-last-modified: 1764750693905
security:
  - apiKeyHeader: []
externalDocs:
  description: You can access our documentation online by visiting https://api.fernand.help
  url: https://api.fernand.help
paths:
  /organization/rules/{id}:
    patch:
      tags:
        - Rulesets
      summary: Update a ruleset
      description: >-
        Updates one or more properties of an existing ruleset. All fields are
        optional - only provided fields will be updated. When updating priority,
        the system automatically reorders other rules to maintain consistent
        priority ordering. Validates that any updated trigger, filters, or
        actions are properly configured and compatible with each other.
      operationId: updateRuleset
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: ID of the ruleset to update.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 250
                  description: Name of the ruleset (optional).
                  example: Updated rule name
                trigger:
                  type: string
                  maxLength: 50
                  description: >
                    Event that triggers this rule (optional). Must be one of:

                    messages.new_conversation, messages.incoming,
                    messages.response, messages.disable_ai,
                    messages.delivery_failure, messages.spam, messages.note,
                    status.closed, status.opened, status.snoozed,
                    status.unsnoozed, teammates.assigned, teammate.mentioned,
                    time.unanswered_by_client, time.unanswered_by_team,
                    tickets.ticket_done
                  example: messages.response
                trigger_data:
                  type: string
                  description: >
                    Additional data for the trigger (optional):

                    - For "teammates.assigned" or "teammate.mentioned":
                    "no_one", "anyone", or an Agent ID

                    - For "time.*" triggers: duration and period in format
                    "{duration} {period}" (e.g., "2 hours", "3 days")
                  example: 3 hours
                filters:
                  type: array
                  description: Array of filter conditions (optional).
                  items:
                    type: object
                  example:
                    - field: message.content
                      operator: contains
                      value: urgent
                actions:
                  type: array
                  description: Array of actions to execute when rule matches (optional).
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        description: Name of the action to execute
                      data:
                        type: object
                        description: Optional data for the action
                  example:
                    - name: conversation.tag
                      data:
                        tag: urgent
                status:
                  type: string
                  enum:
                    - PAUSED
                    - LIVE
                  description: Status of the ruleset (optional).
                  example: PAUSED
                stop:
                  type: boolean
                  description: >-
                    If true, stops processing subsequent rules when this rule
                    matches (optional).
                  example: true
                priority:
                  type: integer
                  description: >-
                    Priority order for rule execution (optional). Other rules
                    are automatically reordered.
                  example: 1
      responses:
        '200':
          description: Ruleset updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Ruleset'
        '400':
          description: Invalid input or validation failed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message describing what went wrong
        '404':
          description: Ruleset not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
components:
  schemas:
    Ruleset:
      type: object
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier for the ruleset
        name:
          type: string
          maxLength: 250
          description: Name of the ruleset
          example: Auto-close spam conversations
        description:
          type: string
          maxLength: 500
          nullable: true
          description: Optional description of what the ruleset does
          example: Automatically closes conversations marked as spam
        status:
          type: string
          enum:
            - PAUSED
            - LIVE
          description: Current status of the ruleset
          example: LIVE
        priority:
          type: integer
          format: int16
          description: Priority order for rule execution (lower numbers execute first)
          example: 0
        stop:
          type: boolean
          description: If true, stops processing subsequent rules when this rule matches
          example: false
        trigger_name:
          type: string
          maxLength: 50
          description: |
            Event that triggers this rule. Accepted triggers:
            - messages.new_conversation
            - messages.incoming
            - messages.response
            - messages.delivery_failure
            - messages.spam
            - messages.note
            - messages.disable_ai
            - status.closed
            - status.opened
            - status.snoozed
            - status.unsnoozed
            - teammates.assigned
            - teammate.mentioned
            - time.unanswered_by_client
            - time.unanswered_by_team
            - tickets.ticket_done
          example: messages.incoming
        trigger_data:
          type: string
          maxLength: 250
          nullable: true
          description: >
            Additional data for the trigger (required for certain triggers):

            - For "teammates.assigned" or "teammate.mentioned": "no_one",
            "anyone", or an Agent ID

            - For "time.*" triggers: duration and period in format "{duration}
            {period}" (e.g., "2 hours", "3 days")
          example: 2 hours
        filters:
          type: array
          nullable: true
          description: |
            Array of filter conditions that must be met for the rule to execute.
            Each filter contains conditions to match against the entity.
          items:
            type: object
          example:
            - field: conversation.status
              operator: equals
              value: OPENED
        actions:
          type: array
          description: |
            Array of actions to execute when the rule matches.
            Each action has a name and optional data.
          items:
            type: object
            properties:
              name:
                type: string
                description: Name of the action to execute
              data:
                type: object
                description: Optional data for the action
          example:
            - name: conversation.close
              data: {}
        created:
          type: string
          format: date-time
          description: Timestamp when the ruleset was created (UTC)
          example: '2025-01-21T10:30:00Z'
        last_applied_at:
          type: string
          format: date-time
          nullable: true
          description: Timestamp when the rule was last applied (UTC)
          example: '2025-01-21T15:45:30Z'
        applied_count:
          type: integer
          format: int32
          description: Number of times this rule has been successfully applied
          example: 42
      required:
        - id
        - name
        - status
        - priority
        - stop
        - trigger_name
        - created
        - applied_count
      x-computed-hash: 825d70624279e89eaa8af56e2d0dde159a1fa02f03c1369b8e6285e19c4c5cd8
      x-last-modified: 1776152542
  securitySchemes:
    apiKeyHeader:
      type: apiKey
      description: >-
        Authenticate your account by including your secret key in API requests.

        You can manage your API keys in the
        [Dashboard](https://app.getfernand.com/).


        Authentication to the API is performed by using the HTTP Header
        X-API-Key.
      name: X-API-Key
      in: header
      x-last-modified: 1764750344730

````