Skip to main content
PUT
/
browser
/
sessions
/
{id}
/
fs
/
file
Write File
curl --request PUT \
  --url https://api.example.com/browser/sessions/{id}/fs/file \
  --header 'Content-Type: application/json' \
  --data '
{
  "path": "<string>",
  "content": "<string>",
  "mode": 123
}
'
{
  "path": "<string>",
  "bytes": 123
}

Overview

Creates or overwrites a file in the session’s workspace with base64-encoded content. Parent directories are created automatically. Paths must be relative to the workspace root (no leading /, no .., no NUL byte, up to 4096 bytes).

Path Parameters

id
string
required
Browser session ID (UUID).

Body

path
string
required
Workspace-relative path, e.g. a/b/c.txt.
content
string
required
Base64-encoded file content.
mode
integer
default:"0644"
Unix mode (octal). Applied after write.

Example Request

curl -X PUT "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/fs/file" \
  -H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "notes/todo.txt",
    "content": "SGVsbG8gV29ybGQ=",
    "mode": 420
  }'

Response

Success Response (201)

path
string
The written workspace-relative path.
bytes
integer
Decoded byte length of the written content.
Example Response:
{
  "path": "notes/todo.txt",
  "bytes": 11
}

Error Responses

StatusDescription
400Invalid body — bad path, non-base64 content, or unknown fields.
401Unauthorized — invalid or missing API key.
404Session not found.
413Decoded content exceeds the maximum write size.