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

# Share A Preview URL

> Expose a machine port through a signed temporary preview URL.

Start a service inside a machine and call `machine.get_url(port)` to get the
exact signed preview URL to share. Keep the machine and the server process
running while someone is using the URL.

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
from nullspace import Machine

with Machine.create(template="base") as machine:
    server = machine.commands.run(
        "cd /workspace && python3 -m http.server 8080",
        shell=True,
        background=True,
    )
    try:
        print(machine.get_url(8080))
        input("Open the URL, then press Enter to stop the server and destroy the machine...")
    finally:
        server.kill()
```

Hosted preview URLs are edge-owned. The exact host and path are deployment
specific; use the returned URL directly:

```text theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
https://preview.your-nullspace-domain/.../?edge_token=...
```

Single-host OSS owned-domain installs use API-compatible wildcard preview
hostnames because `apps/edge` is not part of that appliance profile.

## HTTP and WebSocket URLs

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
http_url = machine.get_url(8080)
websocket_url = machine.get_websocket_url(8080)
print(http_url)
print(websocket_url)
```

Use the exact signed URL returned by the SDK. If the deployment returns an
`edge_token` query parameter, do not strip or rewrite it. After opening a
signed HTTP preview URL in a browser, normal page navigation can continue
through the scoped preview continuation cookie. WebSocket clients should use the
returned `websocket_url`; HTTP continuation cookies do not authorize WebSocket
upgrades.

Use a [custom preview proxy](../networking/custom-preview-proxy) when you need
your own domain, app session checks, or proxy middleware.

Concept: [Create](../concepts/create). API reference:
[getHost](../api-reference), [createMachine](../api-reference), and
[execCommand](../api-reference).
