# Restore filter

`POST /v1/operations/filters/{filterId}/restore`

Available as MCP tool `restore-filter` (Replace).

Filter endpoints allow you to review and manage filters for async messages. A filter can contain multiple rules, but you can only create one filter per subscription. [Learn about filters](https://docs.redoxengine.com/permalink/Zn8kiEw3GdyBFaSwQNSAN).

You can retrieve, create, update, or delete filters, as well as review and manage filter links.  

### Restore filter

Restore a filter to a previously used version. You can select which version to restore, whether going backward or forward.

To preview changes, set the `dryRun` query parameter to `true`. Otherwise, set the `dryRun` query parameter to `false` or omit altogether to immediately apply the restored version to the linked subscription.

> **Can’t restore an active or non-existent version**
>
> This endpoint results in an error if you try to restore to an already active version or a version that doesn’t exist.

## Request parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `dryRun` | query | boolean | No | Specifies whether the restore will be previewed or executed. Set to `true` to run a preview of restoring the asset; this keeps the asset at its current version. Set to `false` (or omit) to restore the version. |
| `filterId` | path | string | Yes | Displays the unique identifier of the filter. |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `version` | number | No |  |

## Request example

_Generated from the schema: the values are placeholders, not a real payload._

```bash
curl 'https://api.redoxengine.com/platform/v1/operations/filters/{filterId}/restore' \
--request POST \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
  "version": 0
}'
```

## Responses

### 200

Contains a payload object with the restore details.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `previous` | object | No | Contains a filter and its related details. |
| `previous.id` | string (uuid) | No | Contains the unique identifier of the asset. |
| `previous.name` | string | No | Contains the human-readable name of the asset. |
| `previous.rules` | Array of object | No | Contains a list of rules that determine when the filter is applied to a message. A filter is only applied if ALL rules are met. |
| `previous.rules[].path` | string | No | Specifies the path to the field(s) that should be evaluated when the filter is applied. This should be a `jsonpath` value. |
| `previous.rules[].values` | Array of string | No | Contains an array of string values that are matched against the path value when the rule is evaluated. |
| `previous.rules[].allowList` | boolean | No | Indicates whether the rule is an allow-list (matches when the value at the specified path is in the values array) or a deny-list (matches when the value at the specified path is NOT in the values array). Defaults to `true` (allow-list). |
| `previous.action` | string | No | Defines what action should be performed when the filter is applied to a message. Possible values: block-all, send |
| `previous.pathType` | string | No | Specifies the format of the field paths defined for this filter's rules. Both FHIR and data model filters use the `jsonpath` path type. Value: jsonpath |
| `previous.version` | string | No | Contains the API schema version used for this asset. |
| `previous.filterVersion` | number | No | Contains the numeric version of the asset. Version numbers start at 1 and increment in whole numbers whenever the asset is updated. |
| `previous.createdAt` | string | No | Displays the date and time that the asset was originally created in ISO 8601 format. |
| `previous.createdBy` | object | No | Contains the metadata about the user who created the asset. |
| `previous.createdBy.id` | number | No | Contains the unique identifier of the user. |
| `previous.createdBy.name` | string, nullable | No | Displays the user's full name. |
| `previous.updatedAt` | string | No | Displays the date and time that the asset was last updated in ISO 8601 format. |
| `previous.updatedBy` | object | No | Contains the metadata about the user who last updated the asset. |
| `previous.updatedBy.id` | number | No | Contains the unique identifier of the user. |
| `previous.updatedBy.name` | string, nullable | No | Displays the user's full name. |
| `previous.deletedAt` | string, nullable | No | Displays the date and time that the asset was deleted. Returns a `null` value if the asset hasn't been deleted. |
| `previous.deletedBy` | object, nullable | No | Contains the metadata about the user who deleted the asset. |
| `previous.deletedBy.id` | number | No | Contains the unique identifier of the user. |
| `previous.deletedBy.name` | string, nullable | No | Displays the user's full name. |
| `current` | object | No | Contains a filter and its related details. |
| `current.id` | string (uuid) | No | Contains the unique identifier of the asset. |
| `current.name` | string | No | Contains the human-readable name of the asset. |
| `current.rules` | Array of object | No | Contains a list of rules that determine when the filter is applied to a message. A filter is only applied if ALL rules are met. |
| `current.rules[].path` | string | No | Specifies the path to the field(s) that should be evaluated when the filter is applied. This should be a `jsonpath` value. |
| `current.rules[].values` | Array of string | No | Contains an array of string values that are matched against the path value when the rule is evaluated. |
| `current.rules[].allowList` | boolean | No | Indicates whether the rule is an allow-list (matches when the value at the specified path is in the values array) or a deny-list (matches when the value at the specified path is NOT in the values array). Defaults to `true` (allow-list). |
| `current.action` | string | No | Defines what action should be performed when the filter is applied to a message. Possible values: block-all, send |
| `current.pathType` | string | No | Specifies the format of the field paths defined for this filter's rules. Both FHIR and data model filters use the `jsonpath` path type. Value: jsonpath |
| `current.version` | string | No | Contains the API schema version used for this asset. |
| `current.filterVersion` | number | No | Contains the numeric version of the asset. Version numbers start at 1 and increment in whole numbers whenever the asset is updated. |
| `current.createdAt` | string | No | Displays the date and time that the asset was originally created in ISO 8601 format. |
| `current.createdBy` | object | No | Contains the metadata about the user who created the asset. |
| `current.createdBy.id` | number | No | Contains the unique identifier of the user. |
| `current.createdBy.name` | string, nullable | No | Displays the user's full name. |
| `current.updatedAt` | string | No | Displays the date and time that the asset was last updated in ISO 8601 format. |
| `current.updatedBy` | object | No | Contains the metadata about the user who last updated the asset. |
| `current.updatedBy.id` | number | No | Contains the unique identifier of the user. |
| `current.updatedBy.name` | string, nullable | No | Displays the user's full name. |
| `current.deletedAt` | string, nullable | No | Displays the date and time that the asset was deleted. Returns a `null` value if the asset hasn't been deleted. |
| `current.deletedBy` | object, nullable | No | Contains the metadata about the user who deleted the asset. |
| `current.deletedBy.id` | number | No | Contains the unique identifier of the user. |
| `current.deletedBy.name` | string, nullable | No | Displays the user's full name. |
| `dryRun` | boolean | No |  |

_Generated from the schema: the values are placeholders, not a real payload._

```json
{
  "previous": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "name": "string",
    "rules": [
      {
        "path": "$.Patient.Demographics.FirstName",
        "values": [
          "string"
        ],
        "allowList": true
      }
    ],
    "action": "send",
    "pathType": "jsonpath",
    "version": "1.0.0",
    "filterVersion": 2,
    "createdAt": "2024-04-25T18:17:16.719Z",
    "createdBy": {
      "id": 0,
      "name": "string"
    },
    "updatedAt": "2024-04-25T18:17:16.719Z",
    "updatedBy": {
      "id": 0,
      "name": "string"
    },
    "deletedAt": "2024-04-25T18:17:16.719Z",
    "deletedBy": {
      "id": 0,
      "name": "string"
    }
  },
  "current": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "name": "string",
    "rules": [
      {
        "path": "$.Patient.Demographics.FirstName",
        "values": [
          "string"
        ],
        "allowList": true
      }
    ],
    "action": "send",
    "pathType": "jsonpath",
    "version": "1.0.0",
    "filterVersion": 2,
    "createdAt": "2024-04-25T18:17:16.719Z",
    "createdBy": {
      "id": 0,
      "name": "string"
    },
    "updatedAt": "2024-04-25T18:17:16.719Z",
    "updatedBy": {
      "id": 0,
      "name": "string"
    },
    "deletedAt": "2024-04-25T18:17:16.719Z",
    "deletedBy": {
      "id": 0,
      "name": "string"
    }
  },
  "dryRun": true
}
```

### 400

Bad Request

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.id` | string | No | Contains a unique identifier for the given error instance. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Bad Request`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Bad Request",
      "code": "validation.error.bad.request",
      "detail": "Error details",
      "status": 400,
      "transient": false
    }
  }
}
```

### 403

Forbidden

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.errors` | Array of object | No |  |
| `payload.errors[].title` | string | No | Displays the high-level error message, typically something succinct like `Forbidden`. |
| `payload.errors[].code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |

```json
{
  "payload": {
    "errors": [
      {
        "title": "Forbidden",
        "code": "authorization.forbidden"
      }
    ]
  }
}
```

### 500

Internal Server Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Failed in step X`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Internal Server Error",
      "code": "failed.db.lookup",
      "detail": "Error details",
      "status": 500,
      "transient": true
    }
  }
}
```
