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

# content.get()

> Read a file, symlink, or directory listing from a repository.

Read repository content without mounting MesaFS.

**Required scope: `read`**

```ts theme={null}
import { Buffer } from 'node:buffer';

const file = await mesa.content.get({ repo: 'app', path: 'README.md' });

if (file.type === 'file') {
  console.log(Buffer.from(file.content, 'base64').toString('utf8'));
}
```

Read a directory listing:

```ts theme={null}
const root = await mesa.content.get({ repo: 'app', path: '', depth: 1 });
if (root.type === 'dir') {
  for (const entry of root.entries) console.log(entry.type, entry.path);
}
```

## Options

<ParamField path="repo" type="string" required>
  Repository name.
</ParamField>

<ParamField path="org" type="string | undefined">
  Organization override.
</ParamField>

<ParamField path="path" type="string | undefined">
  Repository-relative path. Omit or pass an empty string for the repository root.
</ParamField>

<ParamField path="change_id" type="string | undefined">
  Change to read from. Defaults to the current change at the default bookmark tip.
</ParamField>

<ParamField path="depth" type="number | undefined">
  Directory traversal depth from `0` to `10`.
</ParamField>

## Response

<ResponseField name="type: 'file'" type="ContentFile">
  Regular file content.
</ResponseField>

<ResponseField name="type: 'symlink'" type="ContentSymlink">
  Symbolic link content.
</ResponseField>

<ResponseField name="type: 'dir'" type="ContentDirectory">
  Directory listing.
</ResponseField>

### ContentFile

<ResponseField name="type" type="'file'">
  Content variant discriminator.
</ResponseField>

<ResponseField name="name" type="string">
  Base name of the file.
</ResponseField>

<ResponseField name="path" type="string">
  Repository-relative path.
</ResponseField>

<ResponseField name="sha" type="string">
  Git object SHA.
</ResponseField>

<ResponseField name="is_conflicted" type="boolean | undefined">
  Whether this path is conflicted when known.
</ResponseField>

<ResponseField name="size" type="number">
  Size in bytes.
</ResponseField>

<ResponseField name="encoding" type="'base64'">
  Encoding used for `content`.
</ResponseField>

<ResponseField name="content" type="string">
  Base64-encoded file bytes.
</ResponseField>

<ResponseField name="mode" type="'100644' | '100755'">
  POSIX file mode.
</ResponseField>

<ResponseField name="xattrs" type="Record<string, string> | undefined">
  Extended attributes for this path. Values are base64-encoded.
</ResponseField>

### ContentSymlink

<ResponseField name="type" type="'symlink'">
  Content variant discriminator.
</ResponseField>

<ResponseField name="name" type="string">
  Base name of the symlink.
</ResponseField>

<ResponseField name="path" type="string">
  Repository-relative path.
</ResponseField>

<ResponseField name="sha" type="string">
  Git object SHA.
</ResponseField>

<ResponseField name="is_conflicted" type="boolean | undefined">
  Whether this path is conflicted when known.
</ResponseField>

<ResponseField name="size" type="number">
  Size in bytes.
</ResponseField>

<ResponseField name="encoding" type="'base64'">
  Encoding used for `content`.
</ResponseField>

<ResponseField name="content" type="string">
  Base64-encoded symlink target bytes.
</ResponseField>

<ResponseField name="mode" type="'120000'">
  POSIX symlink mode.
</ResponseField>

<ResponseField name="xattrs" type="Record<string, string> | undefined">
  Extended attributes for this path. Values are base64-encoded.
</ResponseField>

### ContentDirectory

<ResponseField name="type" type="'dir'">
  Content variant discriminator.
</ResponseField>

<ResponseField name="name" type="string">
  Base name of the directory.
</ResponseField>

<ResponseField name="path" type="string">
  Repository-relative path.
</ResponseField>

<ResponseField name="sha" type="string">
  Git object SHA.
</ResponseField>

<ResponseField name="child_count" type="number">
  Number of direct children in this directory.
</ResponseField>

<ResponseField name="entries" type="ContentDirectoryEntry[]">
  Directory entries returned for the requested depth.
</ResponseField>

<ResponseField name="xattrs" type="Record<string, string> | undefined">
  Extended attributes attached to this directory. Values are base64-encoded.
</ResponseField>

### ContentDirectoryEntry

<ResponseField name="type" type="'file' | 'symlink' | 'dir'">
  Entry variant discriminator.
</ResponseField>

<ResponseField name="name" type="string">
  Base name of the entry.
</ResponseField>

<ResponseField name="path" type="string">
  Repository-relative path.
</ResponseField>

<ResponseField name="sha" type="string">
  Git object SHA.
</ResponseField>

<ResponseField name="size" type="number | undefined">
  Size in bytes for file and symlink entries.
</ResponseField>

<ResponseField name="mode" type="'100644' | '100755' | '120000' | undefined">
  POSIX mode for file and symlink entries.
</ResponseField>
