# Take a source snapshot

Source: https://docs.vlayers.ai/reference/hosting/create-agent-source-snapshot

`POST /v1/agents/{id}/source/snapshots` · scope `workspace:write`

Copies the working copy into a snapshot. Pass `version` to tie it to a hosted version of the agent (each version has one snapshot; a second is refused with 409 `snapshot_exists_for_version`). A file changed while the copy ran fails it with 409 `changed_during_snapshot`: take it again. An empty working copy is refused with 422. Deleting the version, the agent or the workspace deletes its snapshots.

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"` |
| `version` | body | integer | no | Tie the snapshot to this version number of the agent. Leave it out for a free-standing snapshot. |
| `note` | body | string | no | A line kept with the snapshot (up to 500 characters). |

## Request

cURL:

```bash
curl -X POST "https://api.vlayers.ai/v1/agents/$AGENT_ID/source/snapshots" \
  -H "Authorization: Bearer $VOICELAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "Before the refund change"
  }'
```

TypeScript:

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

const voicelayer = new VoiceLayer();

const { snapshot } = await voicelayer.hosting.createAgentSourceSnapshot('<agent-id>', {
  note: 'Before the refund change'
});
console.log(snapshot.id);
```

Python:

```python
from voicelayer import VoiceLayer

vl = VoiceLayer()

result = vl.hosting.create_agent_source_snapshot(
    "<agent-id>",
    note="Before the refund change",
)
print(result.snapshot.id)
```

## Response `201`

```json
{
  "snapshot": {
    "id": "0192f5c1-5e6f-7a8b-9c0d-1e2f3a4b5c67",
    "agentId": "0192f5c2-6f7a-7b9c-8d1e-2f3a4b5c6d78",
    "versionId": null,
    "version": null,
    "note": "Before the refund change",
    "fileCount": 1,
    "totalBytes": 1204,
    "manifestHash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "createdAt": "2026-10-20T15:04:05.000Z",
    "createdBy": "user_2abc"
  }
}
```
