API version: 0.3.0

---

# Saved searches

A search pipeline is sent with every [`POST /search`](/api/post-search.md) request. To share a search, bookmark it or
reuse it from different clients, store the pipeline in a **saved search**: an ordinary element of the type `SavedSearch`
which is run with [`POST /search/<uuid>`](/api/post-saved-search.md).

A saved search runs as the person who runs it, with their permissions and their access filter, never the ones of the
author. Who may run it is decided by its own access type, `HAS_EXECUTE_ACCESS`, which is independent of who may read it.

## Creating a saved search

The pipeline is stored in the property `query`: an object with the list of `steps`, which are the same as the ones of
a normal search request, and optional default `parameters`. Every other property is free user data, e.g. a name.

```json
{
  "type": "SavedSearch",
  "data": {
    "name": "Reports by name",
    "query": {
      "steps": [
        {
          "type": "elasticsearch-query-dsl-mixin",
          "query": {
            "match": {
              "name": "{{term}}"
            }
          },
          "parameters": {
            "nodeTypes": [
              "Data"
            ]
          }
        },
        {
          "type": "element-hydration"
        }
      ],
      "parameters": {
        "term": "quarterly"
      }
    }
  }
}
```

Saved searches are managed through the [element endpoints](/api/post-index.md) and the usual access model, so they can be
read, changed, deleted and shared like any other element. The answer points to the new element:

```http
Access-Control-Allow-Headers: Authorization, Content-Type
Access-Control-Allow-Methods: GET, HEAD, OPTIONS, POST
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location
Allow: GET, HEAD, OPTIONS, POST
Cache-Control: no-cache, private
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Sun, 29 Nov 2026 15:44:39 GMT
Location: /02IiNr0GPCzvqvxLbJxRo826EEZAayOPVb2Bv
X-Powered-By: Ember Nexus API
```

The query is validated every time `query` is written, and again before every run: unknown properties and step types,
queries of the wrong shape, Cypher queries which can not be parsed and unsupported Elasticsearch features are refused
with `400`. A saved search without a `query` can be stored, but not run.

> **ℹ The query is not indexed**
>
> The query of a saved search is not part of the search index: it can neither be searched nor highlighted, as it
> may be hidden from people who are allowed to search the element.

## Running a saved search

The request is optional. It can only contain `parameters` and `debug`, the steps are the ones which are stored.
Parameters of the request override the stored defaults, while parameters which are set on a step stay fixed:

```bash
curl -X POST \
  -H 'Authorization: Bearer secret-token:0FRdQiGVBRB3eoUl42crKA' \
  -H 'Content-Type: application/json' \
  -d '{
        "debug": true,
        "parameters": {
          "term": "beta"
        }
      }' \
  https://api.example.com/search/02IiNr0GPCxzIN6hmvSLRX0Rd8SeJCE6GcOJw
```

The response is the same as the one of a normal search:

##### Response Body

```json
{
  "type": "_SearchResultResponse",
  "results": [
    {
      "type": "Data",
      "id": "02IiNr0GPCxzIN7fcgG5BuqZJi30Pcu4LtxB5",
      "data": {
        "name": "Quarterly report beta",
        "scenario": "endpoint.search.postSavedSearch",
        "createdAt": "2026-12-05T12:15:19+00:00",
        "updatedAt": "2026-12-05T12:15:19+00:00"
      },
      "metadata": {
        "score": 5.290415
      }
    }
  ],
  "debug": [
    {
      "input": {
        "type": "elasticsearch-query-dsl-mixin",
        "query": {
          "match": {
            "name": "{{term}}"
          }
        },
        "parameters": {
          "term": "beta",
          "nodeTypes": [
            "Data"
          ],
          "stepResults": []
        }
      },
      "step-handler": "elasticsearch-query-dsl-mixin (App\\EventSystem\\SearchStep\\EventListener\\ElasticsearchQueryDslMixinSearchStepEventListener)",
      "start": 1796473120.904066,
      "indices": "node_data",
      "combinedQuery": {
        "_source": [
          "_id"
        ],
        "from": 0,
        "size": 25,
        "query": {
          "bool": {
            "must": [
              {
                "match": {
                  "name": "beta"
                }
              }
            ],
            "filter": [
              {
                "bool": {
                  "should": [
                    {
                      "terms": {
                        "_groupsWithSearchAccess.keyword": []
                      }
                    },
                    {
                      "term": {
                        "_usersWithSearchAccess.keyword": {
                          "value": "02IiNr0GPCxzIMazG2zjDm9W91ZRqkVtsJfT8"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        }
      },
      "end": 1796473120.994841,
      "duration": 0.090775
    },
    {
      "input": {
        "type": "element-hydration",
        "query": null,
        "parameters": {
          "term": "beta",
          "stepResults": [
            {
              "elements": [
                {
                  "id": "02IiNr0GPCxzIN7fcgG5BuqZJi30Pcu4LtxB5",
                  "type": "Data",
                  "metadata": {
                    "score": 5.290415
                  }
                }
              ],
              "totalHits": 1,
              "maxScore": 5.290415
            }
          ]
        }
      },
      "step-handler": "element-hydration (App\\EventSystem\\SearchStep\\EventListener\\ElementHydrationSearchStepEventListener)",
      "start": 1796473120.995141,
      "accessibleElementIds": [
        "02IiNr0GPCxzIN7fcgG5BuqZJi30Pcu4LtxB5"
      ],
      "end": 1796473121.001303,
      "duration": 0.006162
    }
  ]
}
```

##### Response Headers

```http
Access-Control-Allow-Headers: Authorization, Content-Type, Prefer
Access-Control-Allow-Methods: OPTIONS, POST
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Preference-Applied
Allow: OPTIONS, POST
Cache-Control: no-cache, private
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Dec 2026 12:24:53 GMT
Transfer-Encoding: chunked
Vary: Prefer, Accept-Encoding
X-Powered-By: Ember Nexus API
```

## Who may run a saved search

`HAS_EXECUTE_ACCESS` is an [access relation](/reference/access-model.md) like the others: it is inherited through ownership
and groups, can carry conditions, and `OWNS` includes it. Users and groups are given it with a relation to the saved
search, see [sharing elements](/guide/sharing-elements.md) and [managing groups](/guide/managing-groups.md):

```json
{
  "type": "HAS_EXECUTE_ACCESS",
  "start": "02IiNr0GPCxzIN6P6HyyHLXSpBnMGoAbxIhFL",
  "end": "02IiNr0GPCzFieWU2rTfKsjYiT2yK4AKikSZF"
}
```

```http
Access-Control-Allow-Headers: Authorization, Content-Type
Access-Control-Allow-Methods: GET, HEAD, OPTIONS, POST
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location
Allow: GET, HEAD, OPTIONS, POST
Cache-Control: no-cache, private
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Sun, 29 Nov 2026 15:44:39 GMT
Location: /02IiNr0GPCzvwyboBosjw0GIdu1Evd7bP5TtM
X-Powered-By: Ember Nexus API
```

Execute access and read access do not imply each other:

| Read | Execute | What happens                                                                               |
| ---- | ------- | ------------------------------------------------------------------------------------------ |
| no   | yes     | The search runs. The query can not be read, and `debug` is disabled as it would reveal it. |
| yes  | no      | The query can be read, but the search does not run: `403`.                                 |
| yes  | yes     | The search runs and `debug` is available.                                                  |
| no   | no      | The saved search does not exist for the caller: `404`.                                     |

Giving execute access to a group, or to the anonymous user, makes a search available to many without making its
definition public. This is the answer for a user who may run a saved search, but not read it; it only contains what the
user may search themselves:

```json
{
  "type": "_SearchResultResponse",
  "results": [
    {
      "type": "Data",
      "id": "02IiNr0GPCxzIN70epBm17I5DESJInjrq8kap",
      "data": {
        "name": "Quarterly report alpha",
        "scenario": "endpoint.search.postSavedSearch",
        "createdAt": "2026-12-03T12:05:16+00:00",
        "updatedAt": "2026-12-03T12:05:16+00:00"
      },
      "metadata": {
        "score": 4.372641
      }
    }
  ]
}
```

If the caller can read the saved search, but has no execute access, the answer is:

```json
{
  "type": "http://api/error/403/forbidden",
  "title": "Forbidden",
  "status": 403,
  "instance": "urn:uuid:02IiNrOdaupnPqXMB75MHeqgDjQ19kRzTIVGA",
  "detail": "Running a saved search requires execute access to it."
}
```

`HAS_EXECUTE_ACCESS` only has an effect on executable elements, currently saved searches. It is only checked by the
endpoints which execute something, and, as it can not change what can be found, is not part of the search index.

---

Home: [Ember Nexus API docs](/index.md)

Full site map: [llms.txt](/llms.txt)

Previous: [Understanding search errors](/guide/search/understanding-search-errors.md)

Next: [Working with files](/guide/working-with-files.md)
