# Search (API)

> The Sofia Space search API — one call that finds tasks, pages, projects, spaces, file names and messages you can see, with filters, sorting, facets, highlighted snippets and paging.

Source: https://docs.sofiaspace.uz/api/search/

`GET /api/v1/search` is the same search as the search box in the app: one query across **tasks, docs pages, projects, spaces, attachment file names, chat messages and channels**, returning only what you're allowed to see. Use it to find a task from a CRM note, show related pages next to a customer record, or check whether something already exists before creating it.

**Scope:** `tasks:read` or `docs:read`. **Limit:** bursts of 20, then 10 requests per second, per person.

## Search

`GET /api/v1/search`

| Parameter | Required | Meaning |
| --- | --- | --- |
| `q` | yes | What to look for. A task key such as `SALES-42` matches that task exactly. A single character searches titles only and returns at most 10 results |
| `types` | no | Only these kinds: `TASK`, `PAGE`, `PROJECT`, `SPACE`, `ATTACHMENT`, `MESSAGE`, `CHANNEL`. Repeat or comma-separate. **Always set it** — see below |
| `containers` | no | Only inside these projects, spaces or channels (IDs) |
| `authors` | no | Only by these people (user IDs) |
| `teams`, `components` | no | Only tasks owned by these teams / in these components |
| `from`, `to` | no | Updated in this window, ISO times such as `2026-11-01T00:00:00Z` |
| `sort` | no | `relevance` (default) or `newest` |
| `archived` | no | `true` also searches archived items |
| `facets` | no | `true` also returns counts per type, container, author, team and component |
| `limit`, `cursor` | no | [Paging](https://docs.sofiaspace.uz/api/pagination.md): default 20, at most 50 (a larger `limit` is cut to 50) |

```bash
curl -G https://acme.sofiaspace.uz/api/v1/search \
  -H "Authorization: Bearer $SOFIA_TOKEN" \
  --data-urlencode "q=deal 1042" \
  --data-urlencode "types=TASK,PAGE" \
  --data-urlencode "limit=10"
```

```json
{
  "items": [
    {
      "type": "TASK",
      "sourceId": "7c3e9a15-2d4f-4b6a-9e8c-1f3a5b7d9e20",
      "containerId": "9d2e7a10-4b6c-4e8f-a1d3-5c7e9b2f4a68",
      "title": "SALES-42 Onboard new customer (deal #1042)",
      "titleHighlight": { "text": "SALES-42 Onboard new customer (deal #1042)", "ranges": [ { "start": 31, "end": 35 }, { "start": 37, "end": 41 } ] },
      "snippet": { "text": "Contract signed on 12 November…", "ranges": [] },
      "authorId": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21",
      "authorName": "Ali Valiyev",
      "updatedAt": "2026-11-13T14:02:11Z",
      "displayJson": "{\"key\":\"SALES-42\",\"projectKey\":\"SALES\",\"projectName\":\"Sales pipeline\",\"status\":\"In Progress\",\"priority\":\"HIGH\",\"dueDate\":\"2026-11-20\"}",
      "score": 7.42
    }
  ],
  "nextCursor": null,
  "hasMore": false,
  "totalEstimate": 1,
  "exactMatch": false,
  "partial": false,
  "typeFacets": [],
  "containerFacets": [],
  "authorFacets": [],
  "teamFacets": [],
  "componentFacets": []
}
```

| Field | Meaning |
| --- | --- |
| `type`, `sourceId` | What was found and its ID — a task ID for `TASK`, a page ID for `PAGE`, and so on |
| `containerId` | The project, space or channel it's in |
| `titleHighlight`, `snippet` | Plain text plus the character `ranges` that matched (start inclusive, end exclusive). Never HTML |
| `displayJson` | Extra details for showing the hit, as a JSON string. For a task: `key`, `projectKey`, `projectName`, `status`, `priority`, `dueDate` and more. Fields differ by type and may grow |
| `totalEstimate` | Roughly how many results there are |
| `exactMatch` | `q` was a task key and matched exactly one task you can see |
| `partial` | One kind of content couldn't be searched just now, so those results are missing; try again |
| `*Facets` | With `facets=true`: `key`, `label` and `count` per value |

## Always set `types`

Without `types`, search returns every kind you can see — **including chat messages and channels**, even if the token only has `tasks:read`. Set `types=TASK` (or `TASK,PAGE`) so an integration only ever receives the kinds of content it's meant to handle.

An unknown value in `types` is ignored. If every value is unknown, the search runs as if you sent none — so check the spelling: `TASK`, not `TASKS`.

Results are always limited to what the token's owner can open in the app; the token's scopes don't narrow them further.

## Examples

Find the task a CRM note mentions by key:

```bash
curl -G https://acme.sofiaspace.uz/api/v1/search \
  -H "Authorization: Bearer $SOFIA_TOKEN" \
  --data-urlencode "q=SALES-42" --data-urlencode "types=TASK"
```

Pages in the `OPS` space changed this month, newest first:

```bash
curl -G https://acme.sofiaspace.uz/api/v1/search \
  -H "Authorization: Bearer $SOFIA_TOKEN" \
  --data-urlencode "q=price list" \
  --data-urlencode "types=PAGE" \
  --data-urlencode "containers=5a7c9e1b-3d5f-4a8c-b2e4-6f8a1c3e5d79" \
  --data-urlencode "from=2026-11-01T00:00:00Z" \
  --data-urlencode "sort=newest"
```

## What you can't do with the API

- You can't search inside file contents — only file names.
- You can't page past the first 1,000 results.
- An empty `q` isn't "list everything"; it's refused with `400`.
- Over the limit you get `429` without a `Retry-After` header; wait about a second.

## Related

- [Search](https://docs.sofiaspace.uz/workspace/search.md) — in the app
- [Pagination](https://docs.sofiaspace.uz/api/pagination.md)
- [Tasks](https://docs.sofiaspace.uz/api/tasks.md#list-tasks-in-a-project) — for exact lists with filters, list tasks instead of searching
