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

# Update a Rule

> Use this endpoint to partially update a rule. Only provided fields are updated. Expression can only be modified when rule is in DRAFT status.



## OpenAPI

````yaml /en/openapi/v3-current/tracer.yaml patch /v1/rules/{id}
openapi: 3.1.0
info:
  title: Tracer API
  description: >-
    Complete API reference for Tracer services including transaction validation,
    rules management, spending limits, and audit events for SOX/GLBA compliance.
  version: 1.0.0
servers:
  - url: https://tracer.lerian.io
security: []
tags:
  - name: Health API
    description: >-
      Health check endpoints for liveness and readiness probes. These endpoints
      do not require authentication.
  - name: Validations API
    description: >-
      Transaction validation endpoints. Performance target is under 80ms (p99).
      Validations are not idempotent.
  - name: Rules API
    description: >-
      Validation rule management endpoints. Rules use CEL (Common Expression
      Language) expressions.
  - name: Limits API
    description: >-
      Spending limit management endpoints. Limits control transaction amounts by
      scope and period.
  - name: Audit Events API
    description: >-
      Audit trail endpoints for SOX/GLBA compliance. All validation decisions
      and configuration changes are recorded.
paths:
  /v1/rules/{id}:
    patch:
      tags:
        - Rules API
      summary: Update a Rule
      description: >-
        Use this endpoint to partially update a rule. Only provided fields are
        updated. Expression can only be modified when rule is in DRAFT status.
      operationId: updateRule
      parameters:
        - $ref: '#/components/parameters/RuleId'
        - $ref: '#/components/parameters/ContentType'
        - $ref: '#/components/parameters/XApiKey'
        - $ref: '#/components/parameters/XRequestId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateRuleInput'
            example:
              name: Updated rule name
              description: Updated description
      responses:
        '200':
          description: Indicates that the rule was successfully updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Rule'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorFormat'
              examples:
                Error0001:
                  $ref: '#/components/examples/Error0001'
                Error0002:
                  $ref: '#/components/examples/Error0002'
                Error0003:
                  $ref: '#/components/examples/Error0003'
                Error0007:
                  $ref: '#/components/examples/Error0007'
                Error0083:
                  $ref: '#/components/examples/Error0083'
                Error0084:
                  $ref: '#/components/examples/Error0084'
                Error0085:
                  $ref: '#/components/examples/Error0085'
                Error0104:
                  $ref: '#/components/examples/Error0104'
                Error0107:
                  $ref: '#/components/examples/Error0107'
                Error0109:
                  $ref: '#/components/examples/Error0109'
                Error0111:
                  $ref: '#/components/examples/Error0111'
                Error0112:
                  $ref: '#/components/examples/Error0112'
                Error0113:
                  $ref: '#/components/examples/Error0113'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorFormat'
              examples:
                Error0010:
                  $ref: '#/components/examples/Error0010'
                Error0011:
                  $ref: '#/components/examples/Error0011'
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorFormat'
              examples:
                Error0100:
                  $ref: '#/components/examples/Error0100'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorFormat'
              examples:
                Error0101:
                  $ref: '#/components/examples/Error0101'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorFormat'
              examples:
                Error0004:
                  $ref: '#/components/examples/Error0004'
      security: []
components:
  parameters:
    RuleId:
      name: id
      in: path
      description: >-
        The unique identifier of the rule that you want to retrieve, update or
        delete.
      required: true
      example: 019c96a0-1071-7a0d-9916-a831221de252
      schema:
        type: string
        format: uuid
    ContentType:
      name: Content-Type
      in: header
      description: The type of media of the resource. Must be `application/json`.
      required: true
      example: application/json
      schema:
        type: string
    XApiKey:
      name: X-API-Key
      in: header
      description: >-
        The API Key for authentication. **This header is required for all
        endpoints except health checks**.
      required: true
      schema:
        type: string
    XRequestId:
      name: X-Request-Id
      in: header
      description: A unique identifier used to trace and track each request.
      required: false
      example: 019c96a0-10ce-75fc-a273-dc799079a99c
      schema:
        type: string
        format: uuid
  schemas:
    UpdateRuleInput:
      type: object
      description: Input for updating a rule. At least one field must be provided.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
        description:
          type: string
          maxLength: 1000
        expression:
          type: string
          minLength: 1
          maxLength: 5000
          description: CEL expression (only modifiable for DRAFT rules).
        action:
          type: string
          enum:
            - ALLOW
            - DENY
            - REVIEW
        scopes:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/Scope'
    Rule:
      type: object
      description: Validation rule.
      properties:
        ruleId:
          type: string
          format: uuid
          description: Unique identifier for the rule.
        name:
          type: string
          description: Human-readable rule name (globally unique).
          maxLength: 255
        description:
          type: string
          description: Rule purpose and logic explanation.
          maxLength: 1000
        expression:
          type: string
          description: CEL expression that must evaluate to boolean.
          maxLength: 5000
        action:
          type: string
          enum:
            - ALLOW
            - DENY
            - REVIEW
          description: Action taken when rule expression evaluates to true.
        scopes:
          type: array
          items:
            $ref: '#/components/schemas/Scope'
          description: Scopes that determine which transactions this rule applies to.
        status:
          type: string
          enum:
            - DRAFT
            - ACTIVE
            - INACTIVE
            - DELETED
          description: Rule lifecycle status.
        createdAt:
          type: string
          format: date-time
          description: When the rule was created.
        updatedAt:
          type: string
          format: date-time
          description: When the rule was last modified.
        activatedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: When rule was last activated (null if never activated).
        deactivatedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: When rule was last deactivated (null if never deactivated).
        deletedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: When rule was deleted (null if not deleted).
    ErrorFormat:
      type: object
      description: The response message error.
      required:
        - code
        - title
        - message
      properties:
        code:
          type: string
          description: A unique, stable identifier for the error.
        title:
          type: string
          description: A brief summary of the issue.
        message:
          type: string
          description: Detailed guidance for resolving the error.
        fields:
          type: object
          additionalProperties: true
          description: Additional information about the fields that caused the error.
    Scope:
      type: object
      description: Scope definition for rules and limits. At least one field must be set.
      properties:
        segmentId:
          type: string
          format: uuid
          description: Apply to transactions from this segment.
        portfolioId:
          type: string
          format: uuid
          description: Apply to transactions from this portfolio.
        accountId:
          type: string
          format: uuid
          description: Apply to transactions from this specific account.
        merchantId:
          type: string
          format: uuid
          description: Apply to transactions to this specific merchant.
        transactionType:
          type: string
          enum:
            - CARD
            - WIRE
            - PIX
            - CRYPTO
          description: Apply to this transaction type only.
        subType:
          type: string
          maxLength: 50
          description: Apply to this transaction subType only.
  examples:
    Error0001:
      summary: Generic Validation Error
      value:
        code: TRC-0001
        title: Validation Error
        message: >-
          Field validation failed. Please verify the provided data and try
          again.
    Error0002:
      summary: At Least One Field Required
      value:
        code: TRC-0002
        title: At Least One Field Required
        message: >-
          At least one field must be provided for update. Please include at
          least one field and try again.
    Error0003:
      summary: Invalid Request Body
      value:
        code: TRC-0003
        title: Invalid Request Body
        message: >-
          The request body is invalid or malformed. Please verify the JSON
          format and try again.
    Error0007:
      summary: Invalid Path Parameter
      value:
        code: TRC-0007
        title: Invalid Path Parameter
        message: >-
          The provided ID is not a valid UUID format. Please verify the ID and
          try again.
    Error0083:
      summary: Invalid CEL Expression Syntax
      value:
        code: TRC-0083
        title: Expression Syntax Error
        message: >-
          The CEL expression contains a syntax error. Please verify the
          expression syntax and try again.
    Error0084:
      summary: Expression Must Return Boolean
      value:
        code: TRC-0084
        title: Expression Type Error
        message: >-
          The CEL expression must evaluate to a boolean value. Please modify the
          expression to return true or false.
    Error0085:
      summary: Expression Cost Exceeded
      value:
        code: TRC-0085
        title: Expression Cost Exceeded
        message: >-
          The CEL expression computational cost exceeds the allowed limit.
          Please simplify the expression.
    Error0104:
      summary: Expression Not Modifiable
      value:
        code: TRC-0104
        title: Expression Not Modifiable
        message: >-
          The expression can only be modified when the rule is in DRAFT status.
          Please deactivate the rule first.
    Error0107:
      summary: Rule Name Exceeds Maximum Length
      value:
        code: TRC-0107
        title: Name Too Long
        message: >-
          The name exceeds the maximum length of 255 characters. Please reduce
          the name size.
    Error0109:
      summary: Expression Exceeds Maximum Length
      value:
        code: TRC-0109
        title: Expression Too Long
        message: >-
          The expression exceeds the maximum length of 5000 characters. Please
          reduce the expression size.
    Error0111:
      summary: Scope Must Have At Least One Field
      value:
        code: TRC-0111
        title: Invalid Scope
        message: >-
          Each scope must have at least one field set. Please provide at least
          one field in the scope.
    Error0112:
      summary: Description Exceeds Maximum Length
      value:
        code: TRC-0112
        title: Description Too Long
        message: >-
          The description exceeds the maximum length of 1000 characters. Please
          reduce the description size.
    Error0113:
      summary: Scopes Exceed Maximum Entries
      value:
        code: TRC-0113
        title: Scopes Exceed Maximum
        message: >-
          The scopes exceed the maximum of 100 entries. Please reduce the number
          of scopes.
    Error0010:
      summary: API Key Missing
      value:
        code: TRC-0010
        title: API Key Missing
        message: >-
          A valid API Key must be provided in the X-API-Key header. Please
          include your API Key and try again.
    Error0011:
      summary: Invalid API Key
      value:
        code: TRC-0011
        title: Invalid API Key
        message: >-
          The provided API Key is invalid or expired. Please provide a valid API
          Key and try again.
    Error0100:
      summary: Rule Not Found
      value:
        code: TRC-0100
        title: Rule Not Found
        message: >-
          The requested rule does not exist. Please verify the rule ID and try
          again.
    Error0101:
      summary: Rule Name Conflict
      value:
        code: TRC-0101
        title: Rule Name Conflict
        message: >-
          A rule with this name already exists. Please choose a different name
          and try again.
    Error0004:
      summary: Internal Server Error
      value:
        code: TRC-0004
        title: Internal Server Error
        message: >-
          An unexpected error occurred. Please try again later or contact
          support if the issue persists.

````