# Host names

> The host names your realm answers on, each with a TLS certificate obtained and renewed for you.

A realm is reached by its host names: `foobar.cvyuh.com`, and others beside it, such as one per site. A request's host
name decides which realm answers it, so each host name belongs to one realm at a time. You list a realm's host names
when you create it and can change the list at any time; each one gets a TLS certificate, renewed for you.

## Before you begin

- **Privilege:** `DELEGATE` over the realm's **parent**. Host names are set from the realm above: for a realm beneath
  yours, that's you; for `foobar` itself, it's whoever administers the realm above it, or Cvyūh.
- **Where:** the API.
- **First:** the realm's `id` and `rev`, from `GET https://foobar.cvyuh.com/api/v0/am/global/realms/v1`, and your
  session in `$CVYUH_SESSION` ([Call the API](/develop/api/#get-a-session)).

## How it works

A realm's host names are one list, changed as a whole: send the new list, and names that are new are claimed while
names left out are freed for other realms. A realm created with no host names gets one of its own under `cvyuh.com`.

Certificates follow the list. A name one label beneath `cvyuh.com`, such as `foobar-eu.cvyuh.com`, is covered at
once; a deeper one gets a certificate of its own. The realm answers HTTPS on a name once its certificate is ready,
usually within minutes. A name just freed keeps its certificate for an hour, in case it's claimed again.

Each host name is also its own [issuer](/platform/realms/realm-base-url/) unless you set a base URL, so tokens name the
host name the app signed in on.

## Set it up

Send the whole list:

```sh
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/global/realms/v1/<realm id> \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "Content-Type: application/json" \
  -H 'If-Match: "<rev>"' \
  -d '{ "hostnames": ["foobar-engineering.cvyuh.com", "foobar-engineering-eu.cvyuh.com"] }'
```

The realm answers `200` with its `hostnames`, and which it `claimed` and `freed`. Leave out `If-Match`, or send
`If-Match: *`, to change the list whatever its current revision.

## What happens when it fails

| Answer | Cause | What to do |
|---|---|---|
| `400`, "a realm holds at most 3 hostnames" | The list is longer than the realm's limit | Send fewer, or ask Cvyūh to raise the limit |
| `409`, "the hostname … is already in use by another realm" | Another realm holds the name | Choose another name, or free it from the other realm first |
| `400` | A reserved name, such as `mtls`, or a request that changes `status` and `hostnames` together | Choose another name; send each change on its own |

A user who opens a host name you've just freed reaches no realm. Tell users and apps before you take a name away.

## Limits and defaults

| What | Default | Can it change |
|---|---|---|
| Host names per realm | 3, not counting `mtls.` aliases | Cvyūh raises it on request |
| Host names a realm gets when you give none | 1, under `cvyuh.com` | Give your own list |
| Time for a new name's certificate | Usually minutes; a name one label beneath `cvyuh.com` at once | No |
| Certificate kept after a name is freed | 1 hour | No |
| Domains certificates are obtained for | `cvyuh.com` only | Your own domains are planned |

## Troubleshooting

- **The browser shows a certificate error on a new name.** Its certificate isn't ready yet. Wait a few minutes and
  try again; a name one label beneath `cvyuh.com` avoids the wait.
- **Apps refuse tokens after you added a host name.** Each host name is its own issuer. Set a
  [base URL](/platform/realms/realm-base-url/) so every host name signs under one issuer.
- **A name on your own domain doesn't work.** Only names under `cvyuh.com` get a certificate. A CNAME from your own
  domain to a realm's host name doesn't work either, since the certificate doesn't cover your name. See
  [What's next for realms](/platform/realms/whats-next/#your-own-domains).

## Audit record

A change to a realm's host names is an `UPDATED` record on the realm's audit trail, naming who made it and the list
before. No API returns these records yet; ask Cvyūh support for them.

## Good to know

- **Certificate-bound clients get an `mtls.` alias.** While the realm's `oauth2Settings.mtls` is on, each of its host
  names gets an `mtls.` alias beside it, where clients present a certificate. It's claimed and freed with its host
  name, and doesn't count toward the limit. See
  [Certificate-bound tokens](/workforce-identity/applications/client-security/certificate-bound-tokens/).
- **Passkeys belong to a domain.** By default a realm's passkeys are bound to its first host name (its
  `webauthnSettings.rpId`). Settle the realm's host names before users register passkeys: moving users to another
  domain, such as your own later, means registering their passkeys again.

## Coming next

- **[Your own domains](/platform/realms/whats-next/#your-own-domains).** Certificates for host names on your own
  domain, obtained and renewed the same way.

## Related

- [Realm base URL](/platform/realms/realm-base-url/): one issuer, whichever host name an app arrives on.
- [Realms and sub-realms](/platform/realms/sub-realms/): where a realm's host names are first set.
- [Sign in at either site](/platform/guides/sign-in-at-either-site/): a host name at each site.
