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

# Create Scoring Rule

> Adds a rule to the activity type of based_on_rule_id, scoring only the occurrences its conditions match. conditions is a list of {"field", "operator", "value"}; past the first, each may carry logicalOperator "AND" (default) or "OR". Fields come from the rule's available_condition_fields. Operators: eq, ne, contains, not_contains, starts_with, ends_with, gt, lt, is_empty, is_not_empty. A new rule is off unless enabled is true, and scores nothing until it has a weight. Two rules on one activity type cannot carry the same conditions.



## OpenAPI

````yaml POST /public/scoring/rules/
openapi: 3.0.3
info:
  title: RevyOps API
  version: 1.0.0
servers:
  - url: https://app.revyops.com/api
security:
  - ApiKeyAuth: []
paths:
  /public/scoring/rules/:
    post:
      tags:
        - public
      description: >-
        Adds a rule to the activity type of based_on_rule_id, scoring only the
        occurrences its conditions match. conditions is a list of {"field",
        "operator", "value"}; past the first, each may carry logicalOperator
        "AND" (default) or "OR". Fields come from the rule's
        available_condition_fields. Operators: eq, ne, contains, not_contains,
        starts_with, ends_with, gt, lt, is_empty, is_not_empty. A new rule is
        off unless enabled is true, and scores nothing until it has a weight.
        Two rules on one activity type cannot carry the same conditions.
      operationId: Create scoring rule
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScoringRuleCreate'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/ScoringRuleCreate'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ScoringRuleCreate'
        required: true
      responses:
        '200':
          description: No response body
components:
  schemas:
    ScoringRuleCreate:
      type: object
      properties:
        name:
          type: string
        weight:
          type: integer
          maximum: 1000
          minimum: -1000
          nullable: true
        decay_profile:
          type: integer
          nullable: true
        enabled:
          type: boolean
          default: false
        cap_mode:
          $ref: '#/components/schemas/CapModeEnum'
        cap_n:
          type: integer
          minimum: 1
        cap_unit:
          $ref: '#/components/schemas/CapUnitEnum'
        cap_identity_field:
          type: string
          nullable: true
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/ScoringCondition'
        based_on_rule_id:
          type: integer
          description: >-
            Any rule on the activity type to score, from the list. The new rule
            scores the same activity.
      required:
        - based_on_rule_id
    CapModeEnum:
      enum:
        - every
        - window
        - identity
      type: string
      description: |-
        * `every` - every
        * `window` - window
        * `identity` - identity
    CapUnitEnum:
      enum:
        - hour
        - day
        - week
        - month
      type: string
      description: |-
        * `hour` - Hour
        * `day` - Day
        * `week` - Week
        * `month` - Month
    ScoringCondition:
      type: object
      properties:
        field:
          type: string
        operator:
          $ref: '#/components/schemas/OperatorEnum'
        value:
          nullable: true
        logicalOperator:
          allOf:
            - $ref: '#/components/schemas/LogicalOperatorEnum'
          default: AND
      required:
        - field
        - operator
    OperatorEnum:
      enum:
        - eq
        - ne
        - contains
        - not_contains
        - starts_with
        - ends_with
        - gt
        - lt
        - is_empty
        - is_not_empty
      type: string
      description: |-
        * `eq` - Eq
        * `ne` - Ne
        * `contains` - Contains
        * `not_contains` - Not Contains
        * `starts_with` - Starts With
        * `ends_with` - Ends With
        * `gt` - Gt
        * `lt` - Lt
        * `is_empty` - Is Empty
        * `is_not_empty` - Is Not Empty
    LogicalOperatorEnum:
      enum:
        - AND
        - OR
      type: string
      description: |-
        * `AND` - AND
        * `OR` - OR
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.