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

# Fetch entity

> Fetch a single entity by its Sublay entity ID

> [!NOTE]
>
> **Requires the `entities` bundle.** A project without the entities bundle returns `403 database/tables-not-available`. See [Bundles](https://docs.sublay.io/v7/bundles.md).

## Overview

`useFetchEntity` returns a function that fetches a single entity by its Sublay entity ID. Use this for on-demand fetches outside of `EntityProvider`.

## Usage Example

```tsx theme={null}
import { useFetchEntity } from "@sublay/react-js";

function EntityLoader({ entityId }: { entityId: string }) {
  const fetchEntity = useFetchEntity();

  const load = async () => {
    const entity = await fetchEntity({ entityId, include: ["user", "topComment"] });
    console.log(entity);
  };

  return <button onClick={load}>Load Entity</button>;
}
```

## Parameters

**entityId** `string` *required*

The Sublay entity ID to fetch.

**include** `string | string[]`

Optional. Populate related fields. Accepted values: `"user"`, `"space"`, `"topComment"`, `"saved"`, `"files"`, `"grants"`.

**spaceReputation** `object`

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` is purely additive and only appears when you
pass this object. **This object is the primary form** — it
replaces the deprecated flat props below. See the
[Reputation data model](https://docs.sublay.io/v7/data-models/reputation.md) for the
full contract.

**spaceReputation**

Which bucket to read. One of: 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 and the legacy
`general` / `null` aliases are rejected (400).
Missing buckets read as `0`.
Only honored when `spaceId` is an explicit space `<uuid>`.
When `true`, `spaceReputation` is the
**subtree sum** — the named space plus all of its
descendant spaces (the root space's own bucket included). Ignored for
`"none"`; not allowed with `"context"`.

**spaceReputationId** `string` *deprecated*

**Deprecated** — use the `spaceReputation`
object instead. The flat form of `spaceReputation.spaceId`.
Still accepted (the object wins if both are passed); removal is a later
major version. Accepts a space `<uuid>`, `"none"`, or
`"context"`.

**spaceReputationDescendants** `boolean` *deprecated*

**Deprecated** — use
`spaceReputation.includeDescendants` instead. The flat form,
only honored alongside an explicit `spaceReputationId` `<uuid>`.

## Returns

**Entity** `Entity`

The fetched entity. When `spaceReputation` is requested, the embedded author carries an added `spaceReputation` number. See [Entity data model](https://docs.sublay.io/v7/data-models/entity.md) and [Reputation](https://docs.sublay.io/v7/data-models/reputation.md).


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