> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Write File • AI Agent SDK

> write_file: Write a file to the sandbox.

# write\_file

<div className="flex items-center gap-2">
  <Badge color="blue">Async</Badge>
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**SandboxProtocol**](../classes/SandboxProtocol) class in the [**protocols**](../modules/protocols) module.

Write a file to the sandbox.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async def write_file(path: str, content: Union[str, bytes]) -> bool
```

## Parameters

<ParamField query="path" type="str" required={true}>
  Path within sandbox
</ParamField>

<ParamField query="content" type="Union" required={true}>
  File content
</ParamField>

### Returns

<ResponseField name="Returns" type="bool">
  True if successful
</ResponseField>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/sandbox/protocols.py#L296">
  `praisonaiagents/sandbox/protocols.py` at line 296
</Card>
