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

# Public Hostnames

> Publish a service behind a tunnel at a hostname the user owns, through a CNAME to Telnyx.

> [!WARNING]
>
> **Preview.** Not available yet.

A public hostname publishes one service behind a tunnel on the internet, at a hostname the user owns. The service keeps no public IP address and no inbound port.

```bash Workstation theme={null}
telnyx-edge tunnel hostname add chicago-dc api.example.com http://localhost:8080
```

`http://localhost:8080` is the address that the tunnel process dials on its own host. The API takes the same fields and returns the CNAME target:

```json POST /v2/tunnel_hostnames theme={null}
{
  "tunnel_id": "abb096ba-61ae-4f9c-9269-98d8ed94f6aa",
  "hostname": "api.example.com",
  "service": "http://localhost:8080"
}
```

```json Output theme={null}
{
  "data": {
    "record_type": "tunnel_hostname",
    "id": "c970d16c-…",
    "dns_target": "c970d16c.telnyxcompute.com",
    "status": "pending_dns"
  }
}
```

## Point the Hostname at Telnyx

At the DNS provider for `example.com`, the hostname gets a CNAME to its `dns_target`:

```text DNS theme={null}
api.example.com  CNAME  c970d16c.telnyxcompute.com
```

Telnyx activates the hostname once that CNAME resolves, and serves it on port 443. The CNAME only brings traffic to Telnyx. The `tunnel_hostname` record is what authorizes it, so a hostname that arrives without a record is rejected at the edge, whatever target its CNAME names.

| Situation | Client Gets |
| - | - |
| Record, CNAME, and a connected process | The service. |
| CNAME, and no record for the hostname | Rejected at the edge. HTTPS fails in the TLS handshake with `unrecognized_name`, and HTTP gets `421 Misdirected Request`. |
| Record, and no CNAME | Nothing reaches Telnyx. The record stays `pending_dns`. |
| Record and CNAME, and no connected process | `503`. The record shows `inactive`. |
