OpenMetal
Guides

Expose an HTTP endpoint

Create a time limited public route to a process in a sandbox.

Start a service inside a ready sandbox, then create a leased HTTP endpoint for its port.

Portable leased endpoints are currently available through Blaxel and Daytona. Other providers return capability_unsupported.

const endpoint = await metal.endpoints.create(sandbox.id, {
  port: 8080,
  protocol: "http",
  lease_seconds: 3600,
});

let active;
while (!active) {
  const page = await metal.endpoints.list(sandbox.id, { limit: 50 });
  const current = page.endpoints.find((item) => item.id === endpoint.id);

  if (current?.state === "failed") {
    throw new Error(current.error?.message ?? "Endpoint provisioning failed");
  }

  if (current?.state === "active") active = current;
  else await new Promise((resolve) => setTimeout(resolve, 1000));
}

console.log(active.url);

Endpoint creation returns a provisioning resource immediately. Poll the list until it becomes active with a URL or failed.

The SDK does not expose a single-endpoint read method, so use endpoints.list() while waiting. Only HTTP is supported. Ports range from 1 through 65,535 and leases range from 60 through 86,400 seconds before provider restrictions.

Revoke early

await metal.endpoints.revoke(sandbox.id, endpoint.id);

Leases expire automatically, but explicit revocation should be part of cleanup for temporary previews.

On this page