# read_file

Source: https://modulify.ai/docs/api/code/read-file

Reads one text file from a site's source code by its exact path.

- Title: Read one source file
- Scope: `code:read`
- Access: Read only
- Endpoint: `POST /v1/read_file`

Like `list_files`, it reads the preview branch of the site repository rather than the running container, so just after a generation the content can still be the version from before the agent edited it. Take the path from `list_files`, and the answer carries the file's `path`, `size` and `content`.

Binary files and files larger than 200 KB are refused rather than truncated, so read a narrower file instead. A read that fails on GitHub's side returns an error, never empty content, and a path that is not in the site answers `That file was not found in this site!` See [Read a file](https://modulify.ai/docs/editor/files-and-code#read-a-file).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/read_file`, sending the inputs below as a JSON object. The token needs the `code:read` scope.

It only reads and changes nothing, so retrying it is safe.

```bash
curl -X POST https://api.modulify.ai/v1/read_file \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","path":"PATH"}'
```

Over MCP, the same method is the [read_file tool](https://modulify.ai/docs/mcp/code/read-file).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `path` | string | Yes | The exact file path, for example `app/page.tsx`. A leading slash is ignored. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.