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

> ## Agent Instructions
> Internal links on these pages omit the .md extension. Append .md to a docs page URL, or send an Accept: text/markdown header, to get that page as markdown.

# Code and sandbox

> Read and change an app's source code, run commands in its sandbox, and manage its backend functions with the Base44 Apps API

<Note>
  The Apps API is in beta. Its endpoints and responses may change.
</Note>

These endpoints read and change an app's code. You can save files the way the code editor in the Base44 online app editor does, or work directly in the app's live sandbox.

## Saving files or using the sandbox

Pick the route by how you want the change applied.

* **Saving files** with [Save an app file](/api-reference/save-an-app-file) works like saving in the code editor. Base44 writes the file and applies what its path implies. A backend function is redeployed, and an entity or agent schema is validated. [Save several app files](/api-reference/save-several-app-files) saves up to 50 files in one call and never deploys.
* **The sandbox** endpoints run against the app's live sandbox, the same filesystem the app editor edits, so a change shows up in the editor immediately. Use them to run shell commands and to read, write, edit, and search files.

## Reading code

[List app code files](/api-reference/list-app-code-files) returns the paths in the app's source, the same list the code editor's file tree shows. [Get an app code file](/api-reference/get-an-app-code-file) returns one file's text. Both read from the app's live sandbox, so they include changes that haven't been published yet. If no sandbox is running, the call starts one, and the first call after a quiet period takes noticeably longer.

## Endpoints

### Saving files

* [Save an app file](/api-reference/save-an-app-file): Save one file the way the code editor does.
* [Save several app files](/api-reference/save-several-app-files): Save up to 50 files in one call, without deploying.

### Sandbox

* [Run a sandbox command](/api-reference/run-a-sandbox-command): Run a shell command in the app's sandbox and get its output.
* [Read app files](/api-reference/read-app-files): Read one or more files, or a range of lines.
* [Write an app file](/api-reference/write-an-app-file): Create a file or replace one.
* [Edit an app file](/api-reference/edit-an-app-file): Apply exact-string edits to a file and get the diff.
* [Search app files](/api-reference/search-app-files): Search the app's files for a pattern.
* [List app files](/api-reference/list-app-files): List the files and directories in the sandbox.
* [Create a sandbox checkpoint](/api-reference/create-a-sandbox-checkpoint): Save the app's current state so you can return to it.

### Source code

* [List app code files](/api-reference/list-app-code-files): List the paths of the files in the app's source.
* [Get an app code file](/api-reference/get-an-app-code-file): Read the text of one source file.
* [Set main branch protection](/api-reference/set-main-branch-protection): Turn protection of the main branch on or off.

### Backend functions

* [Redeploy a backend function](/api-reference/redeploy-a-backend-function): Deploy code you send as one of the app's backend functions.
* [Get backend function logs](/api-reference/get-backend-function-logs): Read recent log lines from a backend function.

To list or delete the app's backend functions, see [List backend functions](/api-reference/list-backend-functions) and [Delete a backend function](/api-reference/delete-a-backend-function).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.