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

# Revert a rule run

> Takes back the verdicts this run wrote, restoring what stood before it. Verdicts a person
dismissed afterwards, rows inside a reported batch, and rows a later run has since taken
over are left alone and reported as refusals in reversal_summary.

Corrections the run wrote are deleted and their readings put back to the values they
replaced, apart from those inside a filed report or since corrected on top of, which are
reported as refusals. reversal_summary counts them as corrections_planned and
corrections_deleted, separately from results.

Returns at once with the run in reversing, so a second call is refused; the unwinding runs
in the background. Check `reversible` first: when it is false, `non_reversible_reason`
says why, where there is a reason to give.

Requires the `write:rule` token scope.



## OpenAPI

````yaml POST /projects/{project_id}/rules/{rule_id}/runs/{id}/reverse
openapi: 3.1.0
info:
  title: Mangrove - API
  version: 1.1.0
  description: >
    ## Filtering and sorting


    List endpoints that accept `filter` take one query parameter per condition,
    written `filter[field][comparator]=value`, for example
    `filter[name][contains]=North`. The comparators are `eq`, `neq`, `gt`,
    `geq`, `lt`, `leq` and `contains`, and `filter[field]=value` is short for
    `eq`. Conditions combine with AND. `contains` matches part of the value, is
    case-sensitive, and applies only to text fields. An unknown field or
    comparator, a value that doesn't fit the field's type, or a list or object
    as the value returns 400 with a message naming the problem. Each list
    operation names its filterable fields; some take only `eq`, and say so.


    `sort` takes a comma-separated list of fields, for example
    `sort=-created_at,name`. Each field sorts ascending, or descending with a
    `-` prefix. Unknown sort fields are ignored. Sorting by `id` orders by the
    record's internal ID, not its friendly ID. Each list operation names its
    sortable fields.
servers:
  - url: https://app.gomangrove.com/api/v1
security:
  - sec0: []
paths:
  /projects/{project_id}/rules/{rule_id}/runs/{id}/reverse:
    post:
      summary: Revert a rule run
      description: >-
        Takes back the verdicts this run wrote, restoring what stood before it.
        Verdicts a person

        dismissed afterwards, rows inside a reported batch, and rows a later run
        has since taken

        over are left alone and reported as refusals in reversal_summary.


        Corrections the run wrote are deleted and their readings put back to the
        values they

        replaced, apart from those inside a filed report or since corrected on
        top of, which are

        reported as refusals. reversal_summary counts them as
        corrections_planned and

        corrections_deleted, separately from results.


        Returns at once with the run in reversing, so a second call is refused;
        the unwinding runs

        in the background. Check `reversible` first: when it is false,
        `non_reversible_reason`

        says why, where there is a reason to give.


        Requires the `write:rule` token scope.
      operationId: reverse-project-rule-run
      parameters:
        - $ref: '#/components/parameters/ProjectId'
        - name: rule_id
          in: path
          schema:
            type: string
          required: true
        - name: id
          in: path
          schema:
            type: string
          required: true
      responses:
        '200':
          description: The run, now reversing.
          content:
            application/json:
              examples:
                Result:
                  value:
                    id: rrun_aBcD1234eFgH5678
                    rule_id: rule_aBcD1234eFgH5678
                    state: reversing
                    phase: null
                    trigger: on_demand
                    range_start: '2026-07-01T00:00:00.000Z'
                    range_end: '2026-07-31T23:59:59.000Z'
                    started_at: '2026-08-28T14:22:06.000Z'
                    finished_at: '2026-08-28T14:24:51.000Z'
                    last_evaluated_at: '2026-08-28T14:24:50.000Z'
                    targets_total: 1450
                    targets_processed: 1450
                    passed_count: 1430
                    alerted_count: 20
                    results_changed_count: 12
                    newly_alerted_count: 9
                    newly_cleared_count: 3
                    reversible: false
                    non_reversible_reason: null
                    reversal_summary:
                      planned: 12
                      deleted: 0
                      restored: 0
                      corrections_planned: 0
                      corrections_deleted: 0
                    triggered_by: Example User
                    error_message: null
              schema:
                $ref: '#/components/schemas/RuleRun'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          description: The run cannot be reverted; the message says why.
          content:
            application/json:
              examples:
                Run still going:
                  value:
                    errors:
                      - message: >-
                          This run is still going. Revert is available once it
                          finishes.
                Revert in progress:
                  value:
                    errors:
                      - message: >-
                          Another revert is in progress for this rule. Try again
                          once it finishes.
                Evaluation in progress:
                  value:
                    errors:
                      - message: >-
                          An evaluation is in progress for this rule. Revert is
                          available once it finishes.
                Not revertible:
                  value:
                    errors:
                      - message: This run cannot be reverted.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    ProjectId:
      name: project_id
      in: path
      required: true
      description: The project's friendly ID (e.g. `prj_aBcD1234eFgH5678`).
      schema:
        type: string
  schemas:
    RuleRun:
      type: object
      description: >-
        One evaluation of a rule over a period. A run is created running and
        reaches completed, failed,

        superseded, reversing, reversed or reversal_failed. A completed run that
        changed nothing is a

        normal outcome, not a failure — results_changed_count is then 0.
      properties:
        id:
          type: string
          description: Friendly ID (e.g. rrun_abc123…)
          example: rrun_9f3c1d7b2e5a04
        rule_id:
          type: string
          description: Friendly ID of the rule this run evaluated.
        state:
          type: string
          enum:
            - running
            - completed
            - failed
            - superseded
            - reversing
            - reversed
            - reversal_failed
        phase:
          type:
            - string
            - 'null'
          enum:
            - queued
            - preparing
            - evaluating
            - null
          description: Where a running run has got to; null once it is no longer running.
        trigger:
          type: string
          enum:
            - authoring
            - ingestion
            - schedule_sweep
            - on_demand
          description: >-
            What started the run. Runs created through this endpoint are
            on_demand; authoring runs come from a rule edit, ingestion from
            arriving data.
        range_start:
          type: string
          format: date-time
          nullable: true
          description: Null on runs that were not period-scoped, such as ingestion runs.
        range_end:
          type: string
          format: date-time
          nullable: true
        started_at:
          type: string
          format: date-time
        finished_at:
          type: string
          format: date-time
          nullable: true
        last_evaluated_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            When the run last finished a chunk. Poll this to tell a working run
            from a stalled one.
        targets_total:
          type: integer
          nullable: true
          description: >-
            Null when counting the range would have been too expensive to bound
            up front.
        targets_processed:
          type: integer
        passed_count:
          type: integer
        alerted_count:
          type: integer
          description: Standing failures the run saw — not only the ones it newly raised.
        results_changed_count:
          type: integer
          description: >-
            Verdicts this run wrote. 0 means the run agreed with what was
            already recorded.
        newly_alerted_count:
          type: integer
        newly_cleared_count:
          type: integer
        reversible:
          type: boolean
          description: Whether this run can be reverted right now.
        non_reversible_reason:
          type: string
          nullable: true
          description: Why revert is unavailable, when there is a reason worth giving.
        reversal_summary:
          type: object
          nullable: true
          description: >-
            Present once a reversal has begun — what it planned, deleted,
            restored and refused. Results

            and corrections are counted apart: planned / deleted / restored are
            results,

            corrections_planned / corrections_deleted are corrections.
        triggered_by:
          type: string
          nullable: true
          description: >-
            Name of the person behind the run. Null for account-scoped tokens
            and for runs nobody triggered.
        error_message:
          type: string
          nullable: true
    ErrorResponse:
      type: object
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            type: object
            required:
              - message
            properties:
              message:
                type: string
                description: Human-readable error message
              field:
                type: string
                description: Attribute the error applies to (validation errors only)
              code:
                type: string
                description: Machine-readable error code (validation errors only)
              blocking:
                type: array
                description: >-
                  Bounded preview of the records blocking a destroy
                  (blocked-destroy errors only)
                items:
                  $ref: '#/components/schemas/DeletionBlockingRecord'
              blocking_count:
                type: integer
                description: >-
                  Total count of records blocking a destroy (blocked-destroy
                  errors only)
              config_key:
                type: string
                description: >-
                  The data feed source config setting to fix, when the error is
                  on `config` (data feed source validation errors only)
              count:
                type: number
                description: >-
                  The limit or comparison value the failed validation checked
                  against, e.g. a maximum length or a numeric bound (validation
                  errors only, when the validation has one)
              value:
                description: >-
                  The rejected value, e.g. on an inclusion or uniqueness failure
                  (validation errors only, when the validation reports one)
    DeletionBlockingRecord:
      type: object
      required:
        - type
      properties:
        type:
          type: string
        friendly_id:
          type: string
        name:
          type:
            - string
            - 'null'
          description: >-
            Display label, and the only identifier for records that have no
            friendly_id
  responses:
    Forbidden:
      description: >-
        The token lacks the scope the operation's description names, or a
        condition the description states applies, such as a feature that isn't
        enabled for your account.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            errors:
              - message: You are not authorized to perform this action
    NotFound:
      description: >-
        A resource named in the path doesn't exist in your account, or the token
        can't see it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            errors:
              - message: Record not found
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: Authorization
      x-bearer-format: ''

````

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