> ## 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 data feed run

> Asynchronously reverts a data feed run — reverses its publication, deleting any events, derived data points, and orphaned evidence that the run produced. Reversible runs are:

  - `complete` runs (full lifecycle revert)
  - `failed` runs past collection that have published events (partial publication cleanup)
  - `reversal_failed` runs (retrying a revert that errored)

A run already `reversing` or `reversed` returns 200 with its current state and starts nothing new, so a client that times out can repeat the request and read `status`. A run in any other state returns 422 "Pipeline run cannot be reverted". A run whose data points have been used by a model run is not reversible either and returns 422 naming those model runs; free the data points first.

Otherwise the run moves to `reversing` and the revert continues in the background. Poll `GET /data_feeds/{data_feed_friendly_id}/runs/{run_friendly_id}` until `status` is `reversed`, after which the run can be deleted. Model-run use is checked again when the revert runs, so a run used in the meantime lands in `reversal_failed` with the reason in `error_message`. A run that stays `reversing` far longer than expected needs support; repeating the request does not restart it. Requires the `write:data_feed` token scope.




## OpenAPI

````yaml POST /data_feeds/{data_feed_friendly_id}/runs/{run_friendly_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:
  /data_feeds/{data_feed_friendly_id}/runs/{run_friendly_id}/reverse:
    post:
      tags:
        - Data Ingestion
      summary: Revert a data feed run
      description: >
        Asynchronously reverts a data feed run — reverses its publication,
        deleting any events, derived data points, and orphaned evidence that the
        run produced. Reversible runs are:

          - `complete` runs (full lifecycle revert)
          - `failed` runs past collection that have published events (partial publication cleanup)
          - `reversal_failed` runs (retrying a revert that errored)

        A run already `reversing` or `reversed` returns 200 with its current
        state and starts nothing new, so a client that times out can repeat the
        request and read `status`. A run in any other state returns 422
        "Pipeline run cannot be reverted". A run whose data points have been
        used by a model run is not reversible either and returns 422 naming
        those model runs; free the data points first.


        Otherwise the run moves to `reversing` and the revert continues in the
        background. Poll `GET
        /data_feeds/{data_feed_friendly_id}/runs/{run_friendly_id}` until
        `status` is `reversed`, after which the run can be deleted. Model-run
        use is checked again when the revert runs, so a run used in the meantime
        lands in `reversal_failed` with the reason in `error_message`. A run
        that stays `reversing` far longer than expected needs support; repeating
        the request does not restart it. Requires the `write:data_feed` token
        scope.
      operationId: reverse-data-feed-run
      parameters:
        - $ref: '#/components/parameters/DataFeedFriendlyId'
        - $ref: '#/components/parameters/RunFriendlyId'
      responses:
        '200':
          description: >
            Revert initiated, or already underway or finished. Returns the run;
            read `status` for `reversing` or `reversed`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataFeedRun'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Data feed or run not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                errors:
                  - message: Run not found
        '422':
          description: >
            Run cannot be reverted — wrong state, or its data points are used by
            a model run. See message; a model-run refusal names up to three of
            the blocking runs.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                usedByModelRun:
                  value:
                    errors:
                      - message: >-
                          Some events from this run have data points used in
                          model runs, including Biochar Production v3
                          (mr_aBcD1234eFgH5678)
                wrongState:
                  value:
                    errors:
                      - message: Pipeline run cannot be reverted
components:
  parameters:
    DataFeedFriendlyId:
      name: data_feed_friendly_id
      in: path
      required: true
      description: The data feed's friendly ID (e.g. `datafd_aBcD1234eFgH5678`).
      schema:
        type: string
    RunFriendlyId:
      name: run_friendly_id
      in: path
      required: true
      description: The data feed run's friendly ID (e.g. `run_aBcD1234eFgH5678`).
      schema:
        type: string
  schemas:
    DataFeedRun:
      type: object
      description: A data feed run.
      properties:
        id:
          type: string
          description: The data feed run's friendly ID.
          example: run_aBcD1234eFgH5678
        data_feed_id:
          type: string
          description: The data feed's friendly ID.
          example: datafd_aBcD1234eFgH5678
        stage:
          type: string
          enum:
            - collection
            - transformation
            - publication
            - completed
        status:
          type: string
          enum:
            - running
            - failed
            - retrying
            - reversing
            - reversed
            - reversal_failed
            - paused
            - complete
        error_message:
          type:
            - string
            - 'null'
          description: Why the run failed, or why a retry or revert was refused, or null.
        steps:
          type: array
          description: The steps created so far, in stage order.
          items:
            type: object
            properties:
              name:
                type: string
                enum:
                  - collection
                  - transformation
                  - publication
              state:
                type: string
                enum:
                  - pending
                  - running
                  - failed
                  - complete
                  - reversed
              progress:
                type:
                  - integer
                  - 'null'
                minimum: 0
                maximum: 100
              error_message:
                type:
                  - string
                  - 'null'
        events_count:
          type: integer
          description: Number of events the run has created.
        started_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When collection started; null until a worker picks the run up.
        finished_at:
          type:
            - string
            - 'null'
          format: date-time
        created_at:
          type: string
          format: date-time
      example:
        id: run_aBcD1234eFgH5678
        data_feed_id: datafd_aBcD1234eFgH5678
        stage: collection
        status: running
        error_message: null
        steps:
          - name: collection
            state: pending
            progress: null
            error_message: null
        events_count: 0
        started_at: null
        finished_at: null
        created_at: '2026-05-04T10:30:00.000Z'
    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:
    Unauthorized:
      description: >-
        The API token is missing, invalid or expired. The body is empty, except
        for an expired token, which returns the error below.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            errors:
              - message: API token has expired
    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
  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.