Read file
curl --request POST \
--url https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"path": "<string>"
}
'import requests
url = "https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file"
payload = { "path": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({path: '<string>'})
};
fetch('https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'path' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file"
payload := strings.NewReader("{\n \"path\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"path\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"path\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"path": "<string>",
"content_base64": "<string>",
"size_bytes": 123,
"modified_at": "<string>"
}Sessions
Read file
Download a file from a cloud browser’s machine, base64-encoded.
POST
/
api
/
v2
/
sessions
/
{session_id}
/
files
/
read_file
Read file
curl --request POST \
--url https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"path": "<string>"
}
'import requests
url = "https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file"
payload = { "path": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({path: '<string>'})
};
fetch('https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'path' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file"
payload := strings.NewReader("{\n \"path\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"path\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/sessions/{session_id}/files/read_file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"path\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"path": "<string>",
"content_base64": "<string>",
"size_bytes": 123,
"modified_at": "<string>"
}Reads one file from the machine hosting a cloud browser and returns it base64-encoded, with its size and modification time. Pair it with list files to pull out what the agent downloaded.
Returns the file’s
Files are capped at 8 MiB; larger ones are rejected. Only
path, content_base64, size_bytes, and modified_at.
session_id is the browser session id from the session’s RunnerSessionEvent, not the agent session id. See list files for how to obtain it.~/Downloads is reachable.
Path parameters
string
required
The browser session id.
Request body
string
required
File to read. Absolute, or relative to the browser’s home (
~/Downloads/report.csv).Response
string
The file’s resolved path.
string
The file’s bytes, base64-encoded.
integer
Size of the file in bytes.
string
ISO 8601 modification time.
Examples
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$BROWSER_SESSION_ID/files/read_file \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path": "~/Downloads/invoice-2026-09.pdf"}' \
| jq -r .content_base64 | base64 -d > invoice-2026-09.pdf
import base64
from hai_agents import Client
client = Client()
file = client.session_files.read_file(browser_session_id, path="~/Downloads/invoice-2026-09.pdf")
with open("invoice-2026-09.pdf", "wb") as out:
out.write(base64.b64decode(file.content_base64))
import { writeFileSync } from "node:fs";
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const file = await client.sessionFiles.readFile({
sessionId: browserSessionId,
path: "~/Downloads/invoice-2026-09.pdf",
});
writeFileSync("invoice-2026-09.pdf", Buffer.from(file.contentBase64, "base64"));
Response
{
"path": "/home/hai/Downloads/invoice-2026-09.pdf",
"content_base64": "JVBERi0xLjcKJc...",
"size_bytes": 48213,
"modified_at": "2026-09-15T09:41:12Z"
}
Was this page helpful?