# Saved searches

> Searches a user has saved, with a daily email of what's new for them when alerts are on.

Searches a user has saved, with a daily email of what's new for them when alerts are on. Generated from the [OpenAPI spec](https://dev.mongrl.com/openapi.json). Each endpoint says which key it needs; see [Authentication](https://dev.mongrl.com/guides/authentication.md).

| Method | Path | What it does |
|---|---|---|
| GET | [`/v1/me/saved-searches`](#list-saved-searches) | List saved searches |
| POST | [`/v1/me/saved-searches`](#save-a-search) | Save a search |
| DELETE | [`/v1/me/saved-searches/{id}`](#delete-a-saved-search) | Delete a saved search |
| PUT | [`/v1/me/saved-searches/{id}/alerts`](#turn-a-saved-searchs-emails-on-or-off) | Turn a saved search's emails on or off |

## List saved searches

`GET /v1/me/saved-searches` · operation `listSavedSearches`

Newest first.

**Auth:** your secret key (`Authorization: Bearer sk_…`) and the user's session (`X-User-Session: …`), from your server

**Responses:** `200` [ListSavedSearchesResponse](#listsavedsearchesresponse) · `default` [a problem](https://dev.mongrl.com/reference/conventions.md#errors)

## Save a search

`POST /v1/me/saved-searches` · operation `saveSearch`

The filters are GET /v1/listings's. With alerts on (the default), the customer is emailed once a day what's been put on sale for it, if anything, in one email for all their searches. Up to 50 per customer.

**Auth:** your secret key (`Authorization: Bearer sk_…`) and the user's session (`X-User-Session: …`), from your server

**Body** (`application/json`): [SaveSearchRequest](#savesearchrequest)

**Responses:** `201` [SavedSearchBody](#savedsearchbody) · `default` [a problem](https://dev.mongrl.com/reference/conventions.md#errors)

## Delete a saved search

`DELETE /v1/me/saved-searches/{id}` · operation `deleteSavedSearch`

**Auth:** your secret key (`Authorization: Bearer sk_…`) and the user's session (`X-User-Session: …`), from your server

**Parameters**

| Name | In | Type | Notes |
|---|---|---|---|
| `id` * | path | string |  |

**Responses:** `204` No Content · `default` [a problem](https://dev.mongrl.com/reference/conventions.md#errors)

## Turn a saved search's emails on or off

`PUT /v1/me/saved-searches/{id}/alerts` · operation `setSavedSearchAlerts`

**Auth:** your secret key (`Authorization: Bearer sk_…`) and the user's session (`X-User-Session: …`), from your server

**Parameters**

| Name | In | Type | Notes |
|---|---|---|---|
| `id` * | path | string |  |

**Body** (`application/json`): [SetSavedSearchAlertsRequest](#setsavedsearchalertsrequest)

**Responses:** `200` [SavedSearchBody](#savedsearchbody) · `default` [a problem](https://dev.mongrl.com/reference/conventions.md#errors)

## Schemas

Fields marked * are always present in responses and required in requests.

### ListSavedSearchesResponse

| Field | Type | Notes |
|---|---|---|
| `items` * | [SavedSearchBody](#savedsearchbody)[] |  |

### SaveSearchRequest

| Field | Type | Notes |
|---|---|---|
| `alerts` | boolean | Email what's new for it; true when omitted |
| `filters` * | [SearchFilters](#searchfilters) |  |
| `link` | string | Where the shop shows it, as a path (/shop/lighting?brand=…), for the emails to link to. max 2000 chars |
| `name` * | string | What the customer calls it, e.g. Louis Poulsen lamps. max 100 chars |

### SavedSearchBody

| Field | Type | Notes |
|---|---|---|
| `alerts` * | boolean | Emailed what's new for it, once a day |
| `created_at` * | string (date-time) |  |
| `filters` * | [SearchFilters](#searchfilters) |  |
| `id` * | string |  |
| `link` | string |  |
| `name` * | string |  |

### SetSavedSearchAlertsRequest

| Field | Type | Notes |
|---|---|---|
| `alerts` * | boolean |  |

### SearchFilters

| Field | Type | Notes |
|---|---|---|
| `attr` | string[] | key:value, e.g. condition:excellent |
| `categories` | string[] | In any of these categories, each with its subcategories |
| `category` | string |  |
| `currency` | string | The prices' currency |
| `location` | string[] | Stored at any of these locations (ids), or seller: still with the seller |
| `max_price` | integer | In minor units of currency. ≥ 0 |
| `min_price` | integer | In minor units of currency. ≥ 0 |
| `q` | string | max 200 chars |
| `term` | string[] | Catalogue term ids |
