# write\_file

#### `write_file`: Write Content to File

Writes content to a file, creating it if it doesn't exist.

```python
def write_file(
    agent_name: str, 
    file_path: str,
    content: str,
    base_url: str = aios_kernel_url
) -> StorageResponse
```

**Parameters:**

* `agent_name`: Identifier for the agent making the request
* `file_path`: Path to the file to write
* `content`: Text content to write to the file
* `base_url`: API endpoint URL

**Returns:**

* `StorageResponse` object containing write operation status

**Example:**

```python
# Write a simple HTML file
html_content = """
<!DOCTYPE html>
<html>
<head>
    <title>AIOS Project</title>
</head>
<body>
    <h1>Welcome to AIOS</h1>
    <p>This is a sample project page.</p>
</body>
</html>
"""

response = write_file(
    "web_developer",
    "projects/website/index.html",
    html_content
)

print(response["response]["response_message"])
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aios.foundation/aios-docs/aios-agent-sdk/storage-api/write_file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
