writeFile
Writes or creates a file in a CodeSandbox sandbox via a stateless per-call connection using sandboxId and sessionId, with encoding, create, and overwrite options.
Instructions
Write a file in the sandbox filesystem. Stateless: connects per call using sandboxId+sessionId.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sandboxId": "<sandboxId>",
"sessionId": "<sessionId>",
"path": "<path>",
"content": "<content>"
},
"name": "writeFile"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | Optional environment variables if the session is created. | |
| path | Yes | Absolute path to the file in the sandbox. | |
| create | No | Whether to create the file if it does not exist. Defaults to true. | |
| content | Yes | Content to write (encoded as per 'encoding'). | |
| encoding | No | Encoding of 'content'. Defaults to 'utf8'. | |
| overwrite | No | Whether to overwrite an existing file. Defaults to true. | |
| sandboxId | Yes | Target sandbox ID to operate on. | |
| sessionId | Yes | Session identifier to connect with. If missing in the sandbox, it will be created. | |
| permission | No | Optional permission if session needs to be created. Must be 'write' to modify files if server is not read-only. |