> ## 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.

# Get one rule and its per-subject thresholds

> Resolves one rule, INCLUDING its `scopes` — the ordered list of « for these subjects, the threshold is this instead ». That list is what makes « reorder 110 % with this vendor, 130 % with that one » ONE rule rather than two; resolution takes the first scope whose criteria all designate the subject. Read it before updating: the `version` it returns is what the write expects. 404s on an unknown id.



## OpenAPI

````yaml /openapi.json get /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}:
    get:
      tags:
        - Settings
      summary: Get one rule and its per-subject thresholds
      description: >-
        Resolves one rule, INCLUDING its `scopes` — the ordered list of « for
        these subjects, the threshold is this instead ». That list is what makes
        « reorder 110 % with this vendor, 130 % with that one » ONE rule rather
        than two; resolution takes the first scope whose criteria all designate
        the subject. Read it before updating: the `version` it returns is what
        the write expects. 404s on an unknown id.
      operationId: getRule
      parameters:
        - schema:
            type: string
            minLength: 1
          in: path
          name: ruleId
          required: true
          description: The rule id, e.g. `rule-exchange-ratio`.
      responses:
        '200':
          description: The rule, its condition, its mode and its scopes.
          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, its condition, its mode and its scopes.
                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: 1
        '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'
        '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.

````