Skip to content

Public URL

Every sandbox can expose an HTTP service through an AgentBox URL. Start the service on a port, pass that port to getHost or get_host, and add the https:// scheme.

mjs
import { Sandbox } from "@abox-dev/sdk";

const sandbox = await Sandbox.create();

try {
  await sandbox.commands.run("python3 -m http.server 3000", {
    background: true,
  });
  await sandbox.commands.run(
    "until curl -fsS http://127.0.0.1:3000/ >/dev/null; do sleep 0.1; done",
  );

  const url = `https://${sandbox.getHost(3000)}`;
  const response = await fetch(url);

  console.log(url);
  console.log(response.status);
} finally {
  await sandbox.kill();
}

getHost and get_host return a hostname, not a complete URL. AgentBox terminates HTTPS before forwarding the request to the selected port in the sandbox, so the service itself can listen over plain HTTP.

Use a different port for each service you want to expose. A URL is reachable only while its sandbox is running. To require a token for incoming requests, see Restrict public access.