> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Content

> Semantic search over entities, comments, and messages

Performs vector-similarity search over project content (entities, comments, and chat messages) using AI embeddings. Returns the most semantically relevant results for the given query.

**Requires a paid plan with semantic search enabled.**

**Requires an authenticated user.** Send the user's access token as `Authorization: Bearer <token>` — missing token → `401`, invalid/expired token → `403` (refresh and retry).

## Body Parameters

**query** `string` *required*

The natural language search query.

**sourceTypes** `string[]` (default: \["entity", "comment", "message"])

Content types to search. Any combination of `entity`, `comment`, `message`.

**spaceId** `string`

Restrict search to a specific space.

**includeChildSpaces** `boolean` (default: false)

Only applies with a `spaceId`. When `true`, the search also includes every space nested under it — children, grandchildren, the whole subtree at any depth — not just the named space. Ignored without a `spaceId`.

**conversationId** `string`

Restrict message search to a specific conversation.

**limit** `number` (default: 20)

Maximum number of results to return. Maximum `50`.

## Query Parameters

### Space-scoped reputation

This endpoint has a space in context, so it accepts the opt-in reputation params. They add a `spaceReputation` field to each result record's populated `user`, alongside the always-present `reputation` total. Requires the `reputation` bundle. See the [Reputation data model](https://docs.sublay.io/v7/data-models/reputation.md) for the full contract.

**spaceReputationId** `string`

Opt-in. Adds a `spaceReputation` number to each returned user,
scoped to a single space. Requires the `reputation` bundle.
The `reputation` total is always present regardless;
`spaceReputation` only appears when you pass this. See the
[Reputation data model](https://docs.sublay.io/v7/data-models/reputation.md) for the
full contract.

Accepts a space **`<uuid>`** (that
space's bucket), **`none`** (the
project-general, space-less bucket), or
**`context`** (the space derived from the
request context — resolved per-row on lists, or the single space on
member/team/conversation surfaces).

The empty string is rejected (400). The legacy `general` / `null` aliases
are rejected (400). Missing buckets read as `0`.
**spaceReputationDescendants** `boolean`

When `true`, `spaceReputation` is the
**subtree sum** — the named space plus all of its
descendant spaces (the root space's own bucket included).
Ignored unless `spaceReputationId` is a space
`<uuid>`.

## Response

Returns an array of result objects ordered by similarity (highest first):

```json theme={null}
[
  {
    "sourceType": "entity",
    "similarity": 0.87,
    "record": { ...Entity | Comment | ChatMessage... }
  }
]
```

Each result includes:

* `sourceType` — one of `"entity"`, `"comment"`, or `"message"`, indicating which type of record was matched.
* `similarity` — cosine similarity score between the query and the matched content.
* `record` — the fully populated entity, comment, or chat message object. A record's `user` is the author's public [User](https://docs.sublay.io/v7/data-models/user.md) — no email or other private fields.

### What's left out

Chat messages come only from conversations the user can read in the chat itself: ones they're an active member of, and, for a conversation they left or were removed or banned from, messages sent before they left. `conversationId` narrows the search; it never widens what the user can read. Messages their author deleted or a moderator removed are never returned. A request made with a service key gets no chat messages.

## Error Responses

> [accordion] Authentication Required — 401 / 403
>
> The endpoint requires an authenticated user. A missing token returns a bare `401`; an invalid or expired token returns a bare `403` — refresh the access token and retry.

> [accordion] Plan Required — 403
>
> ```json theme={null}
> { "error": "Semantic search requires a paid plan", "code": "project/plan-required" }
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.