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

# In-sandbox CLI and local API

> What tilde sandbox connect does inside every sandbox, and how processes call blueprint tools through its local API and the tilde CLI.

Every sandbox runs `tilde sandbox connect`, part of the regular `tilde` CLI. It connects the VM to Tilde, runs the agent's sandbox operations, and gives processes in the VM access to the blueprint's tools. In Tilde Cloud and Tilde Enterprise, it also wires the VM for [GitHub egress](https://trytilde.ai/docs/sandboxes/github-egress.md).

## `tilde sandbox connect`

Tilde starts this process when it launches or wakes a sandbox. You do not run it yourself, and your template needs no start command. On E2B, it logs to `~/.tilde/sandbox.log`.

The process:

* Dials out to the gateway, so the VM needs no inbound ports.
* Writes the blueprint's [environment variables](https://trytilde.ai/docs/sandboxes/setup.md#environment-variables) to `~/.tilde/sandbox.env`, which every shell sources. It refreshes them each time it connects.
* In Cloud and Enterprise, sets the [egress variables](https://trytilde.ai/docs/sandboxes/github-egress.md#what-the-sandbox-sees) and points git at the gateway. It writes `/etc/gitconfig` for this, so it must run as root or be able to write that file.
* Runs the agent's sandbox operations, such as commands and file edits.
* Serves the [local API](#local-api) for the blueprint's tools.

Commands start, and relative paths resolve, in the process's working directory.

## Local API

The process serves a JSON API on `127.0.0.1:4790`, inside the VM only. Each call goes through the gateway to the tool's source.

```bash theme={"system"}
# Is the process connected to Tilde?
curl -s http://127.0.0.1:4790/v1/health

# List the blueprint's tools.
curl -s http://127.0.0.1:4790/v1/tools

# Call one. The body is the tool's input, and the response is its output.
curl -s -X POST http://127.0.0.1:4790/v1/tools/creds.git_credentials \
  -H 'content-type: application/json' \
  -H "x-tilde-sandbox-operation: ${TILDE_SANDBOX_OPERATION:-}" \
  -d '{"protocol": "https", "host": "github.com", "path": "acme/api.git"}'
```

The path is `/v1/tools/<slug>.<tool>`. On failure, the response body is `{"error": "<message>"}`. Bypass any HTTP proxy for this address.

Forward `TILDE_SANDBOX_OPERATION` as shown, so the call's span nests under the `sandbox.exec` that ran it in the agent's trace. A call made outside any command, for example from a background process, appears as its own span.

> [!NOTE]
>
> The API refuses requests from web pages. A browser open inside the sandbox cannot call your tools, even through DNS rebinding.

## CLI commands

The same calls are available from the CLI, for scripts that would rather not use HTTP.

```bash theme={"system"}
# List the blueprint's tools. Add --json for the raw response.
tilde sandbox tools

# Call one. The second argument is the input as JSON, or pipe it on stdin.
tilde sandbox call creds.git_credentials '{"protocol": "https", "host": "github.com", "path": "acme/api.git"}'
```

`tilde sandbox call` prints the tool's output JSON, and forwards `TILDE_SANDBOX_OPERATION` itself. When the call fails, it prints the error to stderr and exits with status `1`.

### `tilde sandbox credential` CLOUDENTERPRISE

Git's credential helper for the gateway's [egress](https://trytilde.ai/docs/sandboxes/github-egress.md) route. `tilde sandbox connect` configures git to use it for the gateway's URL only, so you never run it yourself. It answers git with the sandbox's egress token, and answers nothing for any other host.

## Limits

* A tool call from the VM can send at most 64 KiB of input, and receive at most 1 MiB of output.
* A tool call can take as long as the tool needs. From CLI 5.2.0, `tilde sandbox call` receives a heartbeat every few seconds while the tool runs, so a proxy's idle timeout does not cut long calls. Use a [Tilde sandbox image](https://trytilde.ai/docs/sandboxes/setup.md#tilde-sandbox-images) of 5.2.0 or later, or install that CLI in your own.
* For command limits, see [Sandbox tools](https://trytilde.ai/docs/sandboxes/overview.md#sandbox-tools).


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