# Read one source file

Source: https://docs.vlayers.ai/reference/hosting/get-agent-source-file

`GET /v1/agents/{id}/source/file` · scope `workspace:read`

Reads one file of the working copy, or of a snapshot when you pass `snapshotId`. Text comes back as text; pass `encoding=base64` for a file that is not text (a text read of one is refused with 422).

Requires an API key with the `workspace:read` scope.

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The agent id. Example: `"0192f5c2-6f7a-7b9c-8d1e-2f3a4b5c6d78"` |
| `path` | query | string | yes | The file, relative to the project root, with `/` between folders. Example: `"src/index.ts"` |
| `snapshotId` | query | string | no | Read the file as it was in this snapshot. Example: `"0192f5c1-5e6f-7a8b-9c0d-1e2f3a4b5c67"` |
| `encoding` | query | "utf8" \| "base64" | no | `utf8` (the default) or `base64`. Example: `"utf8"` |

## Request

cURL:

```bash
curl "https://api.vlayers.ai/v1/agents/$AGENT_ID/source/file?path=src/index.ts" \
  -H "Authorization: Bearer $VOICELAYER_API_KEY"
```

TypeScript:

```ts
import { VoiceLayer } from '@voicelayer/api';

const voicelayer = new VoiceLayer();

const { content } = await voicelayer.hosting.getAgentSourceFile('<agent-id>', {
  path: 'src/index.ts'
});
console.log(content);
```

Python:

```python
from voicelayer import VoiceLayer

vl = VoiceLayer()

result = vl.hosting.get_agent_source_file("<agent-id>", path="src/index.ts")
print(result.content)
```

## Response `200`

```json
{
  "path": "src/index.ts",
  "sizeBytes": 31,
  "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "encoding": "utf8",
  "content": "export const hello = 'world';\n"
}
```
