# Search Filters

This page describes the `searchFilter` endpoint.

{% hint style="info" %}
Additional fields may be included in some responses you receive; however, these attributes are for internal purposes and are therefore undocumented.
{% endhint %}

## Search filter workflow

1. [Save a new search filter.](#save-a-new-search-filter)
2. [Search for saved search filters.](#search-saved-search-filters)
3. [Delete a search filter.](#delete-a-search-filter)

## Save a new search filter

<mark style="color:green;">`POST`</mark> `/searchFilter`

Save a new search filter.

#### Payload parameters

| Attribute | Description                                                                                                                                                                                                                                        | Required |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| filter    | `array` Includes facets to use in the search filter, such as `searchText` (the base search string for data sources/projects), `tag`, `column`, `connectionString`, `schema`, and `type` (type of models to search for: `datasource` or `project`). | **Yes**  |
| name      | `string` Name to be used for the search filter.                                                                                                                                                                                                    | No       |

#### Response parameters

| Attribute | Description                                                                                                                                                                                                                                      |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| filter    | `array` The facets used in the search filter, such as `searchText` (the base search string for data sources/projects), `tag`, `column`, `connectionString`, `schema`, and `type` (type of models used in the filter: `datasource` or `project`). |
| name      | `string` The name of the search filter.                                                                                                                                                                                                          |

### Request example

The following request saves a new search filter.

```bash
curl \
    --request POST \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example_payload.json
    https://your-immuta-url.com/searchFilter
```

#### Payload example

```json
{
  "name": "Medical Claims",
  "filter": {
    "searchText": "",
    "column": ["income_greater_than_50k"],
    "type": "datasource",
    "tag": ["Discovered.Entity.Medicare Number"]
  }
}
```

### Response example

```json
{
  "name": "Medical Claims",
  "filter": {
    "searchText": "",
    "column": ["income_greater_than_50k"],
    "type": "datasource",
    "tag": ["Discovered.Entity.Medicare Number"]
  }
}
```

## Search saved search filters

<mark style="color:green;">`GET`</mark> `/searchFilter`

Retrieve saved search filters.

#### Query parameters

| Attribute  | Description                                                                                                       | Required |
| ---------- | ----------------------------------------------------------------------------------------------------------------- | -------- |
| searchText | `string` A string used to filter returned saved filters. The query is executed with a wildcard prefix and suffix. | No       |

#### Response parameters

| Attribute | Description                                                                                                                                                                                                                                                          |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| values    | `array` Details regarding the search filters, including `name`, `filter`, `searchText` (the base search string for data sources/projects), `tag`, `column`, `connectionString`, `schema`, and `type` (type of models used in the filter: `datasource` or `project`). |

### Request example

The following request retrieves all saved search filters.

```bash
curl \
    --request GET \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    https://your-immuta-url.com/searchFilter
```

### Response example

```json
{
  "values": [{
    "name": "States",
    "filter": {
      "type": "datasource",
      "column": ["state"],
      "searchText": ""
    }
  }]
}
```

## Delete a search filter

<mark style="color:green;">`DELETE`</mark> `/searchFilter/{searchFilterName}`

Delete a search filter by name.

**Requirement**: `APPLICATION_ADMIN` or `USER_ADMIN` Immuta permission or user must be the creator of the search filter

#### Query parameters

| Attribute        | Description                                      | Required |
| ---------------- | ------------------------------------------------ | -------- |
| searchFilterName | `string` The name of the specific search filter. | **Yes**  |

#### Response parameters

| Attribute | Description                                                                                                                                                                                                                                                          |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| values    | `array` Details regarding the search filters, including `name`, `filter`, `searchText` (the base search string for data sources/projects), `tag`, `column`, `connectionString`, `schema`, and `type` (type of models used in the filter: `datasource` or `project`). |

### Request example

The following request deletes the `Medical Claims` search filter.

```bash
curl \
    --request DELETE \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    https://your-immuta-url.com/searchFilter/Medical%20Claims
```

### Response example

```json
{
  "name": "Medical Claims",
  "filter": {
    "tag": ["Discovered.Entity.Medicare Number"],
    "type": "datasource",
    "column": ["income_greater_than_50k"],
    "searchText": ""
  }
}
```
