Upload Session File
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/files \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"file": "<string>"
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/files"
payload = {
"filename": "<string>",
"file": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({filename: '<string>', file: '<string>'})
};
fetch('https://api.example.com/browser/sessions/{id}/files', 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://api.example.com/browser/sessions/{id}/files",
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([
'filename' => '<string>',
'file' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/browser/sessions/{id}/files"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"file\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/browser/sessions/{id}/files")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"file\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"<string>\",\n \"file\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"filename": "<string>",
"size": 123,
"uploadedAt": "<string>"
}Session Files
Upload Session File
Upload a file to the session’s uploads directory. Reference it by filename in a later uploadFile task action.
POST
/
browser
/
sessions
/
{id}
/
files
Upload Session File
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/files \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"file": "<string>"
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/files"
payload = {
"filename": "<string>",
"file": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({filename: '<string>', file: '<string>'})
};
fetch('https://api.example.com/browser/sessions/{id}/files', 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://api.example.com/browser/sessions/{id}/files",
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([
'filename' => '<string>',
'file' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/browser/sessions/{id}/files"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"file\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/browser/sessions/{id}/files")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"file\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"<string>\",\n \"file\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"filename": "<string>",
"size": 123,
"uploadedAt": "<string>"
}Overview
Uploads a file to the session’s uploads directory. Files land in a private per-session staging area and can be referenced byfilename in a subsequent uploadFile task action (for example, to attach a resume to a job application flow). Content is transported as base64 in JSON; maximum decoded size is 50 MiB.
Path Parameters
string
required
Browser session ID (UUID).
Body
string
required
File name (up to 255 characters). Must not contain path separators (
/, \) and cannot be . or ...string
required
Base64-encoded file content. Decoded size must be 50 MiB or less.
Example Request
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/files" \
-H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filename": "resume.pdf",
"file": "SGVsbG8gV29ybGQ="
}'
import { readFile } from "node:fs/promises";
const file = (await readFile("./resume.pdf")).toString("base64");
const response = await fetch(
"https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/files",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SCRAPENGINE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ filename: "resume.pdf", file }),
},
);
Response
Success Response (201)
string
Filename stored in the session’s uploads directory.
integer
Size in bytes of the stored file.
string
ISO 8601 timestamp of when the upload was persisted.
{
"filename": "resume.pdf",
"size": 20813,
"uploadedAt": "2026-04-24T09:12:44Z"
}
Error Responses
| Status | Description |
|---|---|
400 | Invalid body — missing filename/file, filename contains path separators, or file is not valid base64. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found or not owned by the caller. |
413 | Decoded file exceeds the 50 MiB maximum. |
Was this page helpful?
⌘I