# Write one source file

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

`PUT /v1/agents/{id}/source/file` · scope `workspace:write`

Creates or replaces one file of the working copy. A file over the plan's size limit, a tree over the file-count or size limit, or a workspace over its source limit is refused with 413 and the limit named. Nothing is billed for source storage yet; it is measured per day.

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

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The agent id. Example: `"0192f5c2-6f7a-7b9c-8d1e-2f3a4b5c6d78"` |
| `path` | body | string | yes | The file, relative to the project root, with `/` between folders; no leading slash and no `.` or `..` parts. |
| `content` | body | string | yes | The file's content. |
| `encoding` | body | "utf8" \| "base64" | no | `utf8` (the default) when `content` is the text itself, or `base64` for a file that is not text. |

## Request

cURL:

```bash
curl -X PUT "https://api.vlayers.ai/v1/agents/$AGENT_ID/source/file" \
  -H "Authorization: Bearer $VOICELAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "src/index.ts",
    "content": "export const hello = 1;"
  }'
```

TypeScript:

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

const voicelayer = new VoiceLayer();

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

Python:

```python
from voicelayer import VoiceLayer

vl = VoiceLayer()

result = vl.hosting.put_agent_source_file(
    "<agent-id>",
    path="src/index.ts",
    content="export const hello = 1;",
)
print(result.file.sha256)
```

## Response `200`

```json
{
  "file": {
    "path": "src/index.ts",
    "sizeBytes": 31,
    "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "updatedAt": "2026-10-20T15:04:05.000Z"
  },
  "created": true,
  "totalBytes": 31
}
```
