# Read a file

`GET https://app.whatsetter.com/api/v1/knowledge-bases/{id}/files/{fileId}`

One file with its whole text. `text_source` says where the text comes
from:

- `file`: the text of the file, to the character (a `.txt`, `.md` or
  `.csv` file). It comes with a `revision`: pass it back as
  `if_revision` when you rewrite the file.
- `passages`: put back together from the passages the agents hold (a
  PDF or Word file). The words are the file's, its layout is not, and
  it is not the file to the character: a word that ends one passage
  and starts the next can come back twice, or once.
- `passages_unordered`: the same, when the order of the passages is
  not known (a file read at an agent's creation, or a very long line
  cut in pieces).

While a change of a text file is being saved, and after one that was
cut short, the text returned is the last one that was saved. In the
rare case where that cannot be told, `revision` is `null`: send the
whole text then, without `if_revision`.

A long text comes in windows of `limit` characters: while
`next_offset` is not `null`, call again with `offset` set to it.
Requires scope `knowledge:read`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes |  |
| `fileId` | path | string | yes |  |
| `offset` | query | integer | no | Where to start reading, in characters. |
| `limit` | query | integer | no | How many characters to return. |

## Example request

```bash
curl --request GET \
  --url 'https://app.whatsetter.com/api/v1/knowledge-bases/{id}/files/{fileId}' \
  --header 'Authorization: Bearer ws_live_…'
```

## Responses

### 200: The file and its text

```json
{
  "data": {
    "id": "68e61c2a0019f0a4d3b1",
    "name": "opening-hours.txt",
    "status": "ready",
    "size_bytes": 72,
    "pages": null,
    "passages": 1,
    "editable": true,
    "created_at": "2026-10-09T08:40:10.000+00:00",
    "updated_at": "2026-10-09T08:40:10.000+00:00",
    "text": "Monday to Friday: 7 am to 10 pm.\nSaturday: 9 am to 6 pm.\nClosed on Sunday.",
    "text_source": "file",
    "revision": "5f2a9c81d04be637",
    "characters": 72,
    "offset": 0,
    "next_offset": null
  }
}
```

### 401: Missing, unknown or revoked API key

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 403: The key lacks the required scope (`insufficient_scope`), the plan does not have this part of the API (`not_in_plan`), or Instagram is not enabled on the workspace (`instagram_not_enabled`, Instagram routes)

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 404: Resource not found in this workspace

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 409: A PDF or Word file too long to be read whole through the API

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 422: `offset` or `limit` out of bounds

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 502: The knowledge store did not answer

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```


Source: https://docs.whatsetter.com/api-reference/operations/getknowledgefile/
