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

# Change a rule's threshold, mode, perimeter or switch

> Changes what the merchant owns: the threshold, the enforcement mode, when it fires, its per-subject scopes, its priority and its switch. It CANNOT repoint the rule at another measurement — that would be a rule builder, and the catalogue is closed on purpose. Sending `scopes` REPLACES the whole list, so read the rule first. `expectedVersion` is required and never defaulted: a stale write is refused with 409 rather than silently overwriting the administrator who saved thirty seconds earlier.



## OpenAPI

````yaml /openapi.json put /v1/rules/{ruleId}
openapi: 3.0.3
info:
  title: Solya POS API
  version: 1.0.0
  description: >-
    The Solya POS backend HTTP surface. Every documented operation is
    agent-ready: it carries an `operationId`, an agent-facing `description`, the
    `pos.*` scopes it enforces (`x-required-permissions`) and an `x-agent-tier`.
    Success responses return the payload as raw JSON; failures return the
    `ErrorResponse` envelope (`{ error: { code, message, statusCode } }`).
servers:
  - url: /
    description: The backend, relative to its deployed origin.
security: []
paths:
  /v1/rules/{ruleId}:
    put:
      tags:
        - Settings
      summary: Change a rule's threshold, mode, perimeter or switch
      description: >-
        Changes what the merchant owns: the threshold, the enforcement mode,
        when it fires, its per-subject scopes, its priority and its switch. It
        CANNOT repoint the rule at another measurement — that would be a rule
        builder, and the catalogue is closed on purpose. Sending `scopes`
        REPLACES the whole list, so read the rule first. `expectedVersion` is
        required and never defaulted: a stale write is refused with 409 rather
        than silently overwriting the administrator who saved thirty seconds
        earlier.
      operationId: updateRule
      parameters:
        - schema:
            type: string
            minLength: 1
          in: path
          name: ruleId
          required: true
          description: The rule id, e.g. `rule-exchange-ratio`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                expectedVersion:
                  type: integer
                  minimum: 0
                  exclusiveMinimum: true
                  maximum: 9007199254740991
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
                description:
                  nullable: true
                  type: string
                  maxLength: 2000
                thresholdValue:
                  type: number
                enforcementMode:
                  type: string
                  enum:
                    - BLOCK
                    - WARN
                    - LOG
                checkLevel:
                  type: string
                  enum:
                    - SHOP
                    - BRAND
                    - PRODUCT
                    - VARIANT
                    - INVENTORY_ITEM
                    - PLAN
                    - PLAN_ITEM
                evaluationPoints:
                  minItems: 1
                  type: array
                  items:
                    type: string
                    enum:
                      - PRE_PLAN_ITEM_ADD
                      - PRE_PLAN_VALIDATE
                      - RECOMMENDATION_GENERATION
                      - WORKFLOW_EXECUTION
                      - MANUAL_CHECK
                category:
                  type: string
                  enum:
                    - CAPACITY
                    - ASSORTMENT
                    - ORDERING
                    - TRANSFER
                    - PRICING
                    - DISTRIBUTION
                    - COMPLIANCE
                scopes:
                  type: array
                  items:
                    type: object
                    properties:
                      position:
                        type: integer
                        minimum: 0
                        maximum: 9007199254740991
                      criteria:
                        type: array
                        items:
                          oneOf:
                            - type: object
                              properties:
                                kind:
                                  type: string
                                  enum:
                                    - TAG
                                tagId:
                                  type: string
                                  minLength: 1
                              required:
                                - kind
                                - tagId
                            - type: object
                              properties:
                                kind:
                                  type: string
                                  enum:
                                    - ENTITY
                                entityType:
                                  type: string
                                  enum:
                                    - PRODUCT
                                    - BRAND
                                    - VARIANT
                                    - INVENTORY_ITEM
                                    - SUPPLIER
                                    - FAMILY
                                entityId:
                                  type: string
                                  minLength: 1
                              required:
                                - kind
                                - entityType
                                - entityId
                      thresholdValue:
                        type: number
                    required:
                      - position
                      - criteria
                      - thresholdValue
                active:
                  type: boolean
                priority:
                  type: integer
                  minimum: -9007199254740991
                  maximum: 9007199254740991
              required:
                - expectedVersion
              example:
                expectedVersion: 1
                thresholdValue: 120
                enforcementMode: BLOCK
                scopes:
                  - position: 0
                    criteria:
                      - kind: ENTITY
                        entityType: SUPPLIER
                        entityId: supplier-sportswear
                    thresholdValue: 130
      responses:
        '200':
          description: The rule as it now stands, at its new version.
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      id:
                        type: string
                        minLength: 1
                      name:
                        type: string
                        minLength: 1
                        maxLength: 255
                      description:
                        nullable: true
                        type: string
                        maxLength: 2000
                      category:
                        type: string
                        enum:
                          - CAPACITY
                          - ASSORTMENT
                          - ORDERING
                          - TRANSFER
                          - PRICING
                          - DISTRIBUTION
                          - COMPLIANCE
                      condition:
                        type: object
                        properties:
                          contextType:
                            type: string
                            minLength: 1
                          contextParams:
                            type: object
                            additionalProperties:
                              anyOf:
                                - type: string
                                - type: number
                                - type: boolean
                          operator:
                            type: string
                            enum:
                              - LOWER_THAN
                              - LOWER_OR_EQUAL
                              - GREATER_THAN
                              - GREATER_OR_EQUAL
                              - EQUAL
                              - NOT_EQUAL
                          thresholdValue:
                            type: number
                        required:
                          - contextType
                          - contextParams
                          - operator
                          - thresholdValue
                        additionalProperties: false
                      enforcementMode:
                        type: string
                        enum:
                          - BLOCK
                          - WARN
                          - LOG
                      checkLevel:
                        type: string
                        enum:
                          - SHOP
                          - BRAND
                          - PRODUCT
                          - VARIANT
                          - INVENTORY_ITEM
                          - PLAN
                          - PLAN_ITEM
                      evaluationPoints:
                        type: array
                        items:
                          type: string
                          enum:
                            - PRE_PLAN_ITEM_ADD
                            - PRE_PLAN_VALIDATE
                            - RECOMMENDATION_GENERATION
                            - WORKFLOW_EXECUTION
                            - MANUAL_CHECK
                      actionFamily:
                        nullable: true
                        type: string
                        enum:
                          - RESTOCK_PLAN
                          - REBALANCE_PLAN
                          - MARKDOWN_PLAN
                          - PRE_SEASON_PLAN
                          - SUPPLIER_RETURN_PLAN
                          - SUPPLIER_EXCHANGE_PLAN
                          - RECOMMENDATION
                          - WORKFLOW
                      scopes:
                        type: array
                        items:
                          type: object
                          properties:
                            position:
                              type: integer
                              minimum: 0
                              maximum: 9007199254740991
                            criteria:
                              type: array
                              items:
                                oneOf:
                                  - type: object
                                    properties:
                                      kind:
                                        type: string
                                        enum:
                                          - TAG
                                      tagId:
                                        type: string
                                        minLength: 1
                                    required:
                                      - kind
                                      - tagId
                                    additionalProperties: false
                                  - type: object
                                    properties:
                                      kind:
                                        type: string
                                        enum:
                                          - ENTITY
                                      entityType:
                                        type: string
                                        enum:
                                          - PRODUCT
                                          - BRAND
                                          - VARIANT
                                          - INVENTORY_ITEM
                                          - SUPPLIER
                                          - FAMILY
                                      entityId:
                                        type: string
                                        minLength: 1
                                    required:
                                      - kind
                                      - entityType
                                      - entityId
                                    additionalProperties: false
                            thresholdValue:
                              type: number
                          required:
                            - position
                            - criteria
                            - thresholdValue
                          additionalProperties: false
                      active:
                        type: boolean
                      priority:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                      templateId:
                        nullable: true
                        type: string
                        minLength: 1
                      phase:
                        nullable: true
                        type: string
                        enum:
                          - SCORING
                          - SIZING
                          - SOURCING
                          - APPROVAL
                      paradigm:
                        type: string
                        enum:
                          - VALIDATION
                          - DECISION_SHAPING
                      origin:
                        type: string
                        enum:
                          - centrale
                          - os
                      payload:
                        nullable: true
                    required:
                      - id
                      - name
                      - description
                      - category
                      - condition
                      - enforcementMode
                      - checkLevel
                      - evaluationPoints
                      - actionFamily
                      - scopes
                      - active
                      - priority
                      - templateId
                      - phase
                      - paradigm
                      - origin
                      - payload
                    additionalProperties: false
                  - type: object
                    properties:
                      version:
                        type: integer
                        minimum: 0
                        exclusiveMinimum: true
                        maximum: 9007199254740991
                    required:
                      - version
                    additionalProperties: false
                description: The rule as it now stands, at its new version.
                example:
                  id: rule-exchange-ratio
                  name: Ratio de recommande
                  description: >-
                    Sur un échange, recommander au moins 110 % de ce qui est
                    renvoyé.
                  category: COMPLIANCE
                  condition:
                    contextType: EXCHANGE_RECEIVE_RATIO
                    contextParams: {}
                    operator: LOWER_THAN
                    thresholdValue: 110
                  enforcementMode: BLOCK
                  checkLevel: PLAN
                  evaluationPoints:
                    - PRE_PLAN_VALIDATE
                  actionFamily: SUPPLIER_EXCHANGE_PLAN
                  scopes:
                    - position: 0
                      criteria:
                        - kind: ENTITY
                          entityType: SUPPLIER
                          entityId: supplier-sportswear
                      thresholdValue: 130
                  active: true
                  priority: 0
                  templateId: exchange_reorder_ratio
                  phase: null
                  paradigm: VALIDATION
                  payload: null
                  version: 2
        '400':
          description: >-
            The request failed schema validation; `error.fieldErrors` lists the
            fields.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: No valid credential was presented — send a bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: The actor is authenticated but lacks the required `pos.*` scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: No resource matches the addressed identifier.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: The request is well-formed but violates a domain rule.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: An unexpected server error — safe to retry idempotent requests.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    ValidationErrorResponse:
      type: object
      required:
        - error
      additionalProperties: false
      description: >-
        A `VALIDATION_FAILED` envelope carrying the offending fields in
        `fieldErrors`.
      properties:
        error:
          type: object
          required:
            - code
            - message
            - statusCode
          additionalProperties: false
          properties:
            code:
              type: string
              enum:
                - VALIDATION_FAILED
            message:
              type: string
            statusCode:
              type: integer
            fieldErrors:
              type: array
              description: >-
                One entry per rejected field: the field path and why it was
                rejected.
              items:
                type: object
                required:
                  - field
                  - message
                additionalProperties: false
                properties:
                  field:
                    type: string
                    description: Dot-path of the offending field.
                  message:
                    type: string
                    description: Why the field was rejected.
    ErrorResponse:
      type: object
      required:
        - error
      additionalProperties: false
      description: The uniform failure envelope every non-2xx response returns.
      properties:
        error:
          type: object
          required:
            - code
            - message
            - statusCode
          additionalProperties: false
          properties:
            code:
              type: string
              enum:
                - VALIDATION_FAILED
                - UNAUTHORIZED
                - FORBIDDEN
                - NOT_FOUND
                - CONFLICT
                - BUSINESS_RULE_VIOLATION
                - INTERNAL_ERROR
              description: >-
                Machine-readable kernel `ResultCode` — branch on this, not on
                `message`.
            message:
              type: string
              description: >-
                Human-readable explanation. Safe to surface; never leaks server
                internals.
            statusCode:
              type: integer
              description: >-
                The HTTP status, mirrored into the body so a client need not
                read headers.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        `Authorization: Bearer <token>`. Accepts EITHER a Keycloak access token
        (scopes-in-token) OR an opaque POS session token; both resolve to the
        same `pos.*` scope vocabulary the route guards enforce.

````