# Save a search

> Saves a search the way the Save search button does: the filters are read again on the server, and only what a browse page accepts is kept. New matches arrive as notifications.


`POST https://dev.siteswap.pro/api/v1/saved-searches`

Saves a search the way the Save search button does: the filters are read again on the server, and only what a browse page accepts is kept. New matches arrive as notifications.

Needs the `alerts` scope.

## Body

- `marketplace` (string, required): A marketplace key, as `GET /marketplaces` lists them, for example `materials`
- `query` (string): The filters as a query string, with the names of `GET /listings` (or of a browse address on the site), for example `q=rebar&zip=01801&radius=50`
- `name` (string, required)
- `mode` ("instant" | "daily")

```json
{
  "marketplace": "materials",
  "query": "q=rebar&zip=01801&radius=50",
  "name": "Rebar near the yard",
  "mode": "daily"
}
```

## Responses

- 201: Created
- 400: bad_request, key_in_url or invalid_json: the request could not be read
- 401: missing_key or invalid_key: no key, or a key that is not valid or was revoked
- 403: key_pending, key_declined, scope_missing, terms_required or account_unavailable: see Errors
- 404: not_found: nothing here that you may see
- 413: too_large: the body is over 256 KB
- 429: rate_limited or daily_quota: wait for Retry-After seconds

## Response fields

- `id` (string)
- `name` (string)
- `marketplace` (string)
- `query` (string): The browse address it watches
- `mode` ("instant" | "daily"): A notification per match, or one summary a day
- `paused` (boolean)
- `matches` (integer): Listings matched so far
- `created_at` (string): When it was saved. ISO 8601 in UTC

```json
{
  "data": {
    "id": "string",
    "name": "string",
    "marketplace": "string",
    "query": "string",
    "mode": "instant",
    "paused": false,
    "matches": 0,
    "created_at": "string"
  },
  "meta": {
    "request_id": "3f9a1c0b7d2e",
    "api_version": "v1"
  }
}
```

## Example

```bash
curl -X POST "https://dev.siteswap.pro/api/v1/saved-searches" \
  -H "Authorization: Bearer ssk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"marketplace":"materials","query":"q=rebar&zip=01801&radius=50","name":"Rebar near the yard","mode":"daily"}'
```