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

# Retrieve a rule



## OpenAPI

````yaml GET /projects/{project_id}/rules/{rule_id}
openapi: 3.1.0
info:
  title: Mangrove - API
  version: 1.1.0
servers:
  - url: https://app.gomangrove.com/api/v1
security:
  - sec0: []
paths:
  /projects/{project_id}/rules/{rule_id}:
    get:
      summary: Retrieve a rule
      operationId: get-project-rule
      parameters:
        - name: project_id
          in: path
          schema:
            type: string
          required: true
        - name: rule_id
          in: path
          description: >-
            Rule friendly ID in the `rule_XXXX` syntax. For example:
            `rule_Qb3k9TzdL0pWnXyz`
          schema:
            type: string
          required: true
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Rule'
        '404':
          description: '404'
          content:
            application/json:
              examples:
                Result:
                  value:
                    errors:
                      - message: Record not found
      deprecated: false
components:
  schemas:
    Rule:
      type: object
      description: >-
        A data rule on a project. The rule's identity is stable across edits;
        the condition lives on its latest version.
      properties:
        id:
          type: string
          description: Rule friendly ID.
          example: rule_Qb3k9TzdL0pWnXyz
        name:
          type: string
        rule_type:
          type: string
          enum:
            - alert
            - substitution
          description: Derived from `action`. Read-only.
        action:
          type: string
          enum:
            - alert
            - substitute
          description: >-
            `alert` flags the matching record and changes nothing. `substitute`
            replaces the matching value with one derived from `method_chain`.
            Only data point rules may substitute.
        method_chain:
          type: array
          description: >-
            Ordered substitution candidates. The first method that resolves
            wins. Empty on alert rules.
          items:
            $ref: '#/components/schemas/SubstitutionMethod'
        target_type:
          type: string
          enum:
            - data_point
            - model
          description: >-
            `data_point` evaluates event data as it arrives. `model` evaluates
            model outputs after a batch calculation.
        status:
          type: string
          enum:
            - active
        enabled:
          type: boolean
        rule_text:
          type: string
          description: The condition, in the rule expression language.
          example: '{{data-point.ambient-temperature-c}} < 0'
        subject_slugs:
          type: array
          items:
            type: string
          description: >-
            On an alert rule, narrows which of the values the condition reads
            may be flagged. On a substitute rule, names the single value the
            rule corrects.
        alert_message:
          type: string
          nullable: true
          description: >-
            Shown on the records this rule flags. Required on an alert rule.
            Optional on a substitute rule, where it covers the records whose
            method chain resolved nothing, and Mangrove supplies a default.
        version:
          type: integer
        effective_from:
          type: string
          format: date
          nullable: true
        effective_to:
          type: string
          format: date
          nullable: true
        model_id:
          type: string
          nullable: true
          description: Model rules only.
        model_name:
          type: string
          nullable: true
        created_by:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    SubstitutionMethod:
      type: object
      description: One candidate in a substitute rule's method chain.
      properties:
        method:
          type: string
          enum:
            - constant
            - fallback_to_dpt
            - forward_fill
            - backward_fill
            - trailing_average
            - trailing_min
            - trailing_max
          description: >-
            `constant` uses a fixed number and always resolves, so no method may
            follow it. `fallback_to_dpt` copies another data point type on the
            same event. `forward_fill` and `backward_fill` borrow the nearest
            earlier or later valid reading. The three trailing methods take the
            average, lowest or highest reading across a window.
        params:
          type: object
          description: >-
            `constant` takes `value`. `fallback_to_dpt` takes `slug`. The
            trailing methods take `window`. The two fills take no parameters.
          properties:
            value:
              type: number
              description: >-
                `constant` only. Rejected when the value would itself match the
                rule's condition.
            slug:
              type: string
              description: >-
                `fallback_to_dpt` only. A data point type slug on the same
                event.
            window:
              type: object
              description: Trailing methods only.
              properties:
                kind:
                  type: string
                  enum:
                    - rolling
                    - calendar
                value:
                  type: integer
                  description: Required on a rolling window. Not used on a calendar window.
                unit:
                  type: string
                  description: >-
                    Rolling windows take `second`, `minute`, `hour`, `day`,
                    `week`, `month` or `year`. Calendar windows take `day`,
                    `week`, `month`, `quarter` or `year`.
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: Authorization
      x-bearer-format: ''

````