> ## 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.

# Ask Content

> AI-powered Q&A grounded in your project's content

export const SpaceReputationParams = ({variant = "context", field = "path"}) => {
  const isUser = variant === "user";
  return <>
      <ParamField {...{
    [field]: "spaceReputation",
    type: "object"
  }}>
        Opt-in. Adds a <code>spaceReputation</code> number to each returned user,
        scoped to a single space. Requires the <code>reputation</code> bundle.
        The <code>reputation</code> total is always present regardless;{" "}
        <code>spaceReputation</code> is purely additive and only appears when you
        pass this object. <strong>This object is the primary form</strong> — it
        replaces the deprecated flat props below. See the{" "}
        <a href="/v8/data-models/reputation">Reputation data model</a> for the
        full contract.

        <Expandable title="spaceReputation">
          {isUser ? <ParamField name="spaceId" type="string | &quot;none&quot;" required>
              Which bucket to read. A space <strong><code>&lt;uuid&gt;</code></strong> reads that
              space's bucket; <strong><code>"none"</code></strong> reads the
              project-general (space-less) bucket.{" "}
              <strong><code>"context"</code> is rejected (400)</strong> on this
              endpoint — there is no space context to derive. The empty string
              and the legacy <code>general</code> / <code>null</code> aliases are
              also rejected. Missing buckets read as <code>0</code>.
            </ParamField> : <ParamField name="spaceId" type="string | &quot;none&quot; | &quot;context&quot;" required>
              Which bucket to read. One of: a space <strong><code>&lt;uuid&gt;</code></strong>{" "}
              (that space's bucket), <strong><code>"none"</code></strong> (the
              project-general, space-less bucket), or{" "}
              <strong><code>"context"</code></strong> (the space derived from the
              request context — resolved per-row on lists, or the single space on
              member/team/conversation surfaces). The empty string and the legacy{" "}
              <code>general</code> / <code>null</code> aliases are rejected (400).
              Missing buckets read as <code>0</code>.
            </ParamField>}
          <ParamField name="includeDescendants" type="boolean">
            Only honored when <code>spaceId</code> is an explicit space <code>&lt;uuid&gt;</code>.
            When <code>true</code>, <code>spaceReputation</code> is the{" "}
            <strong>subtree sum</strong> — the named space plus all of its
            descendant spaces (the root space's own bucket included). Ignored for{" "}
            <code>"none"</code>; not allowed with <code>"context"</code>.
          </ParamField>
        </Expandable>
      </ParamField>

      {isUser ? <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code> or <code>"none"</code> only —{" "}
          <code>"context"</code> is rejected (400) on this endpoint.
        </ParamField> : <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code>, <code>"none"</code>, or{" "}
          <code>"context"</code>.
        </ParamField>}

      <ParamField {...{
    [field]: "spaceReputationDescendants",
    type: "boolean",
    deprecated: true
  }}>
        <strong>Deprecated</strong> — use{" "}
        <code>spaceReputation.includeDescendants</code> instead. The flat form,
        only honored alongside an explicit <code>spaceReputationId</code> <code>&lt;uuid&gt;</code>.
      </ParamField>
    </>;
};

Answers a natural language question using content from your project as context. The endpoint first performs semantic retrieval to find relevant content, then sends the context to an LLM to generate a grounded answer. Responds via **Server-Sent Events (SSE)** for streaming output.

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

**Requires an authenticated user.** Send the user's access token as `Authorization: Bearer <token>`. Requests without a valid token are rejected before any work is done — missing token → `401`, invalid/expired token → `403` (refresh the access token and retry).

## Body Parameters

<ParamField body="query" type="string" required>
  The question to answer. Typos and ambiguous phrasing are handled gracefully.
</ParamField>

<ParamField body="sourceTypes" type="string[]" default="[&#x22;entity&#x22;, &#x22;comment&#x22;, &#x22;message&#x22;]">
  Content types to use as context. Any combination of `entity`, `comment`, `message`.
</ParamField>

<ParamField body="spaceId" type="string">
  Restrict the context lookup to a specific space.
</ParamField>

<ParamField body="includeChildSpaces" type="boolean" default="false">
  Only applies with a `spaceId`. When `true`, the context lookup also includes every space nested under it — children, grandchildren, the whole subtree at any depth — not just the named space. Use it to ask across a community and all of its channels at once. Ignored without a `spaceId`.
</ParamField>

<ParamField body="conversationId" type="string">
  Restrict message context lookup to a specific conversation.
</ParamField>

<ParamField body="limit" type="number" default="20">
  Maximum number of content chunks to retrieve for context. Maximum `50`.
</ParamField>

## 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 source record's populated `user`, alongside the always-present `reputation` total. Requires the `reputation` bundle. See the [Reputation data model](/v8/data-models/reputation) for the full contract.

<SpaceReputationParams variant="context" field="query" />

## Response

The response is a **Server-Sent Events** stream with `Content-Type: text/event-stream`. Three event types are emitted:

**`token`** — streamed LLM answer tokens:

```
event: token
data: {"content": "Based on"}

event: token
data: {"content": " the discussion..."}
```

**`sources`** — the content records used as context, sent after the answer is complete:

```
event: sources
data: [{"sourceType": "entity", "similarity": 0.87, "record": {...}}, ...]
```

Each source object follows the same shape as the [Search Content](/v8/api-reference/search/search-content) response — `sourceType`, `similarity`, and a fully populated `record`. An empty array is sent when no relevant context was found.

The answer is generated only from content the signed-in user can see: content by users they are block-edged with (in either direction), comments on an entity whose author has blocked them, and comments their author deleted, are never used as context or returned as sources.

**`done`** — signals the stream is finished:

```
event: done
data: {}
```

<Note>
  If no relevant content is found above the similarity threshold, the LLM response is skipped and the answer event immediately says "I couldn't find any relevant content to answer your question."
</Note>

## Error Responses

<AccordionGroup>
  <Accordion title="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. These are returned before streaming starts.
  </Accordion>

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

    Only returned when headers have not yet been sent (i.e., before streaming starts).
  </Accordion>

  <Accordion title="Error Event (during stream)">
    If an error occurs after streaming starts:

    ```
    event: error
    data: {"error": "Internal server error"}
    ```
  </Accordion>
</AccordionGroup>


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