# Apps

Define long-running applications in a Buddy Sandbox, start and stop them, read their logs, and expose them to the internet through an endpoint.

An **app** is a long-running process that Buddy starts and supervises inside a Sandbox - a web server, a worker, a dev server. Unlike a [one-off command](/docs/sandboxes/running-commands.md), an app is part of the Sandbox definition, so it starts again automatically every time the machine boots.

## In the UI

Apps are defined in the Sandbox settings under **App commands**: each one is the command that launches it, for example `npm start` or `nginx -g 'daemon off;'`. They run in the [app directory](/docs/sandboxes/configuration.md) unless the command changes it.

The entry expands into **Logs**, **Stop**, and **Restart**.

## From the CLI

```bash
bdy sb app add my-sandbox "npm run worker"
bdy sb app list my-sandbox
bdy sb app status my-sandbox <app>
bdy sb app start my-sandbox <app>
bdy sb app stop my-sandbox <app>
bdy sb app remove my-sandbox <app>
```

`app list` is also where you read an app's state - it prints the id, the command, and the status: `RUNNING`, `ENDED`, or `FAILED`.

An app can also be declared when the Sandbox is created:

```bash
bdy sb create --app-command "npm start" --app-dir /home/buddy/app
```

## In YAML

```yaml
  app_dir: /home/buddy/app
  apps:
  - npm start
  - npm run worker
```

Full key reference: [Sandbox YAML](/docs/yaml/yaml-sandbox.md).

## Logs

Every app has its own log stream, separate from the setup log and from command logs:

```bash
bdy sb app logs my-sandbox <app>
```

See [Logs](/docs/sandboxes/logs.md).

## Exposing an app to the internet

An app is reachable from outside only through an [endpoint](/docs/sandboxes/endpoints.md).

<Hint type="warning">

The app must listen on `0.0.0.0`, not `127.0.0.1`: a server bound to localhost works fine in the terminal but is unreachable through an endpoint.

</Hint>

## Multiple apps in one Sandbox

A Sandbox can run as many apps as its resources allow - an API, a worker, and a frontend dev server side by side, each with its own log, each with its own endpoint if it needs one.

<Hint type="info">

Apps can also be managed programmatically - over the [REST API](/docs/api/sandboxes/apps-start.md), from a pipeline with the [Manage Sandbox action](/docs/actions/sandboxes/manage-sandbox-action.md), from inside the Sandbox with `this app`, and through [MCP](/docs/ai-agents/mcp.md) by AI agents.

</Hint>


---
Original source: https://buddy.works/docs/sandboxes/apps