Read app files

<Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Reads one or more files from the app's sandbox.

Every sandbox-bridge endpoint runs against the app's live sandbox, the same filesystem the Base44 builder edits, so a change here is visible in the builder immediately.

Ask for up to 50 paths in one call. Set offset and limit to read a line range instead of whole files, which is what keeps a large file inside the response budget. A successful entry reports total_lines and truncated, so you can tell a partial read from a complete one.

A path that fails does not fail the request. Every per-path problem rides inside the 200 as an error on that entry: a file that doesn't exist, one that isn't UTF-8 text, a path outside the app or in a protected tree, the point where the batch exhausts its aggregate read budget, and a read the sandbox itself refused. So a mixed response is normal, and a request where every path failed is still a 200. Check each entry for error before reading content, and branch on error.code.

This is a read, so a viewer on the workspace can call it and a read-only branch is no obstacle.

This endpoint is limited to 120 requests per minute per app, shared with the other sandbox-bridge endpoints that only read.

<Note>The sandbox bridge needs a Builder plan or higher on the app's workspace, and answers 402 below that. Workspace API keys are not authorized and are rejected with a 403, and it is unavailable for agent apps. A personal API key works as-is. An OAuth access token needs the apps:read scope; the read endpoints don't require sandbox:write.</Note>

<Tip>Every error response carries a stable extra_data.code alongside the human-readable message. Branch on the code rather than on the message text or the status.</Tip>

post/api/apps/{app_id}/sandbox-bridge/read_file

Path parameters

app_idstring required

ID of the app whose sandbox to operate on.

ID of the app whose sandbox to operate on.

Request body

branch_idstring nullable

Optional Base44 branch ID. Omit to operate on main.

pathsstring[] required

One or more file paths relative to the app root.

offsetinteger nullable

1-based start line (optional).

limitinteger nullable

Max lines to return from offset (optional).

Response

One entry per requested path, each either a read or an error.

Example response

{
  "files": [
    {
      "content": "export default function Home() {\n  return <h1>Hello</h1>;\n}\n",
      "end_line": 3,
      "path": "src/pages/Home.jsx",
      "start_line": 1,
      "total_lines": 3,
      "truncated": false
    },
    {
      "error": {
        "code": "NOT_FOUND",
        "message": "File not found."
      },
      "path": "src/pages/Missing.jsx"
    }
  ]
}

Changes