# searchSpaces

One search across everything the Library rail reaches (FILES (folders and files), LIBRARY (templates, contracts, contract templates, forms, tables, pages) and DATA (uploads, downloads)) matching titles and, for templates and contracts, their content. Grouped by zone, best `limit` per zone, each hit with its own id (a Library item id, a template id, a contract id …), `kind` and the app link (`target.href`) to send the person. Narrow with `zones`. Each source applies its own page's access rule.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "searchSpaces", "variables": {...} }`
- Scope: `READ`
- Type: query
- Idempotency: a read; rejects `Idempotency-Key`
- Rate-limited: no
- Result cap: `limit` is clamped to 25, without an error

## Variables

- `query`: `String!` (required)
- `zones`: `[SpacesSearchZone!]` (one of `DATA`, `LIBRARY`, `FILES`, `RECORDS`). Where a Spaces search hit lives, as Spaces' rail groups it.
- `limit`: `Int` (default `10`)

## Response (data, an example)

```json
{
  "spacesQuery": {
    "spacesSearch": {
      "query": "…",
      "groups": [
        {
          "zone": "DATA",
          "total": 0,
          "totalIsLowerBound": true,
          "hits": [
            {
              "id": "<ID>",
              "zone": "DATA",
              "kind": "TEMPLATE",
              "title": "…",
              "subtitle": "…",
              "snippet": {
                "text": "…"
              },
              "location": "…",
              "fileType": "…",
              "updatedAt": "2026-01-01T00:00:00.000Z",
              "target": {
                "href": "…"
              }
            }
          ]
        }
      ],
      "incompleteZones": [
        "DATA"
      ]
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operationId": "searchSpaces",
    "variables": {
      "query": "<String>"
    }
  }'
```
