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

> ## Agent Instructions
> H Platform has four products: the Agents API (managed computer-use agents, base URL https://agp.eu.hcompany.ai/api/v2 or https://agp.hcompany.ai/api/v2 for the US), the Models API (OpenAI-compatible Holo vision-language models at https://api.hcompany.ai/v1), HoloDesktop CLI (Holo on the user's own desktop), and HoloTab (a free no-code Chrome extension that runs Holo in the user's browser, with recordable routines and schedules).
> Authenticate with a bearer API key from the HAI_API_KEY environment variable. SDKs: `pip install hai-agents` (Python, `from hai_agents import Client`) and `npm install hai-agents` (TypeScript, `import { HaiAgentsClient } from "hai-agents"`). CLI: `hai`.
> Agents do work in a browser or on a desktop; describe the task as an imperative instruction. To run a task quickly, prefer the pre-built agent `h/web-surfer-flash`. Read results from the session's `latest_answer` after it reaches a terminal status.
> Sessions are the unit of work; wait for a terminal status (completed, failed, timed_out, interrupted) before reading the answer. Use webhooks or the `changes` long-poll endpoint to follow progress.

# Write file

> Upload a file to a cloud browser's machine for the agent to use.

Writes a file onto the machine hosting a cloud browser, so the agent can attach it to a form, upload it to a site, or read it. The content is sent base64-encoded; an existing file at the same path is overwritten.

**Returns** the written file's `path` and `size_bytes`.

<Note>
  `session_id` is the **browser session id** from the session's `RunnerSessionEvent`, not the agent session id. See [list files](/agents-api/sessions/list-files) for how to obtain it.
</Note>

Files are capped at 8 MiB; larger ones are rejected. Only `~/Downloads` is writable.

***

## Path parameters

<ParamField path="session_id" type="string" required>
  The browser session id.
</ParamField>

***

## Request body

<ParamField body="path" type="string" required>
  Destination path. Absolute, or relative to the browser's home (`~/Downloads/cv.pdf`).
</ParamField>

<ParamField body="content_base64" type="string" required>
  The file's bytes, base64-encoded.
</ParamField>

***

## Response

<ResponseField name="path" type="string">
  The written file's resolved path.
</ResponseField>

<ResponseField name="size_bytes" type="integer">
  Bytes written.
</ResponseField>

***

## Examples

<CodeGroup>
  ```bash cURL theme={"system"}
  curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$BROWSER_SESSION_ID/files/write_file \
    -H "Authorization: Bearer $HAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"path\": \"~/Downloads/cv.pdf\", \"content_base64\": \"$(base64 -i cv.pdf)\"}"
  ```

  ```python Python theme={"system"}
  import base64
  from hai_agents import Client

  client = Client()

  with open("cv.pdf", "rb") as f:
      content = base64.b64encode(f.read()).decode()

  client.session_files.write_file(browser_session_id, path="~/Downloads/cv.pdf", content_base64=content)
  ```

  ```typescript TypeScript theme={"system"}
  import { readFileSync } from "node:fs";
  import { HaiAgentsClient } from "hai-agents";

  const client = new HaiAgentsClient();

  await client.sessionFiles.writeFile({
    sessionId: browserSessionId,
    path: "~/Downloads/cv.pdf",
    contentBase64: readFileSync("cv.pdf").toString("base64"),
  });
  ```
</CodeGroup>

```json Response theme={"system"}
{
  "path": "/home/hai/Downloads/cv.pdf",
  "size_bytes": 182044
}
```

Tell the agent where the file is, for example with a [message](/agents-api/sessions/send-messages): "Upload `~/Downloads/cv.pdf` in the application form."
