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

# Write File

> Create or update a file in a session

## Request

<ParamField body="sessionId" type="string" required>
  Session ID to write file in
</ParamField>

<ParamField body="path" type="string" required>
  File path relative to /workspace
</ParamField>

<ParamField body="content" type="string" required>
  File content (max 10MB on free tier, 50MB on paid)
</ParamField>

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key
</ParamField>

## Response

<ResponseField name="path" type="string">
  Path of written file
</ResponseField>

<ResponseField name="size" type="integer">
  File size in bytes
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.buntime.sh/files/write \
    -H "Authorization: Bearer $BUNTIME_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "sessionId": "ses_abc123",
      "path": "hello.ts",
      "content": "console.log(\"Hello World!\");"
    }'
  ```

  ```typescript TypeScript theme={null}
  await client.files.write({
    sessionId: 'ses_abc123',
    path: 'hello.ts',
    content: 'console.log("Hello World!");'
  });
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "path": "hello.ts",
    "size": 29
  }
  ```
</ResponseExample>
