# saveFilter

Create a saved filter. `type` CONTACT runs with filterContacts, PROPERTY with filterProperties, DEAL (status, title, pipeline stage, assignees, deal custom fields) with filterDeals: find deal filters with listDealFilters; the Deals board shows no saved-filter list, so tell the user it lives in the API. Other FilterType values are rejected. `root` is the filter-tree DSL, a recursive group: { id, operator: "AND"|"OR", negated?: boolean, conditions: [{ id, fieldId, value }], groups: [<group>] }. `negated: true` inverts a whole GROUP (group-level only): the way to say "not already on any of my lists". EVERY group and condition needs its own caller-minted non-empty `id` (mint a UUID each); missing ids are the most common rejection. Every `fieldId` must be a real field of the domain: an unknown one, or a bad value, rejects the whole save naming the field and saves nothing, so NEVER probe by saving: read listFilterFields FIRST. Geo conditions take ids: `countyFilters` a `fips` from searchCounties, `cityFilters` a city `id` from searchCities (a county name or unknown FIPS is rejected on any type, a bare city name on PROPERTY). To see what a tree DOES first (its count, whether it keeps records with no value) run it inline as `filterTree` on filterProperties/filterContacts/countContacts, which saves nothing. Save only the final filter the user asked for: a measuring filter is visible to them and their team. File it into a folder with `folderId` (listFilterFolders). Owner + org come from the API key; no userId/organizationId input, so a key cannot plant a filter in another tenant. The response may carry `warnings`: non-fatal notes on the saved criteria (e.g. same-named counties from DIFFERENT states, like Cook, IL + Cook, MN: saved, and it matches all of them). RELAY each one with the result, not as a failure; if the selection is not what the user meant, fix it with updateFilter.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "saveFilter", "variables": {...} }`
- Scope: `WRITE`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `type`: `FilterType!` (required, one of `PROPERTY`, `CONTACT`, `PIPELINE_ITEM`, `DEAL`, `OWNER`, `POST`, `ENTITY`, `PERSON`, `USER`, `ORGANIZATION`)
- `name`: `String!` (required)
- `root`: `JSON!` (required)
- `description`: `String`
- `folderId`: `ID`
- `isPrivate`: `Boolean`
- `isDefault`: `Boolean`
- `inSavedAreas`: `Boolean`

## Response (data, an example)

```json
{
  "filterMutation": {
    "saveFilter": {
      "id": "<ID>",
      "name": "…",
      "type": "PROPERTY",
      "isPrivate": true,
      "isDefault": true,
      "createdAt": "2026-01-01T00:00:00.000Z",
      "warnings": [
        "…"
      ]
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "saveFilter",
    "variables": {
      "type": "PROPERTY",
      "name": "<String>",
      "root": "<JSON>"
    }
  }'
```
