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

# Domains and routes

> An account holds domains bought through Uniac, with the DNS records it sets on them. A project's routes serve one of its services' HTTP at hostnames under a domain the account holds.

An account holds domains bought through Uniac, with the DNS records it sets
on them. A project's routes serve one of its services' HTTP at hostnames
under a domain the account holds, such as `www.example.com` under
`example.com`.

## Domains

A domain belongs to the account, not to a project, so several projects can
declare the same domain. Uniac buys it from its registrar for one year and
registers it with Uniac as the registrant and WHOIS privacy on. The account
**holds** the domain once it is registered.

| Field | Required | Meaning |
| - | - | - |
| `name` | Yes | The domain: one label under a [sold top-level domain](#top-level-domains), such as `example.com`. A label is lowercase letters, digits and hyphens, neither starting nor ending with a hyphen, at most 63 characters. A hostname under the domain, such as `www.example.com`, is served by a [route](#routes). |

### Top-level domains

Uniac sells a top-level domain when its registrar sells it for one year with
WHOIS privacy, asks for no registrant eligibility or other registry fields,
needs no nameserver check before registration, takes ASCII names, and costs
at most \$100 a year, first year and renewal, card fee included. The set is
read from the registrar each day, with a standard name's one-year price and
yearly renewal price under each. A top-level domain the registrar starts
selling is sold within a day; one that stops meeting these terms is no
longer sold to new purchases, and a domain already held under it stays held
and renews.

A top-level domain is named without its dot, in ASCII; an internationalized
one by its punycode, such as `xn--q9jyb4c`. It may have more than one
label, such as `co.com`, and a name falls under the longest sold one it ends
in. A name the registry sells at a premium price costs more than the
standard price, and Uniac does not sell it.

### Offers

An offer says whether a name can be bought now, and at what price. It is
computed on each read. Reading one name's offer checks it at the registrar
then; reading a label's offers lists the label under every sold top-level
domain, in name order, answered from the registries' zones, which each
registry refreshes twice a day.

| Offer phase | Meaning |
| - | - |
| `available` | One name's live check found it for sale at a standard price, with the name's own one-year and renewal prices. |
| `unconfirmed` | Listed: the name is absent from its registry's zone, so it is probably for sale at the top-level domain's standard price. Its own offer confirms it. |
| `unavailable` | The name cannot be bought, and it has no prices: it is registered, or a Uniac account holds or is buying it (`taken`); the registry sells it at a premium price (`premium`); or a trademark is registered for it (`trademark_claim`). |
| none | Listed, and not known: the registrar has no zone data for the top-level domain. It carries the standard price, and its own offer checks it. |

A name the account itself holds or is buying reads `taken`. A zone answer is
shared across accounts for an hour and a live answer for five minutes. A
purchase reads the name itself when it is requested and again when it is
approved.

Reads are counted in registrar lookups. One name's offer costs one, or two
under a top-level domain in a trademark claims period, and a label's list
costs one for every 500 sold top-level domains. An answer shared from an
earlier read, by any account, costs none. An account has 100 lookups an
hour; a read beyond them, or beyond the platform's own hourly lookups, is
refused until one frees.

### Purchase

Requesting a domain the account does not have starts its purchase. The
platform reads the name's availability and its one-year price at the
registrar, and, under a top-level domain in a trademark claims period,
whether a trademark is registered for it. The price is the registrar's price
plus the card fee, and the yearly renewal price is set the same way: it is
the registrar's renewal price today, followed until 60 days before the
expiry and then held until that renewal completes. The purchase then waits
for a person to approve or decline it, at that price, in the dashboard. On
approval, the availability and the trademark are read again, so a name taken
or claimed meanwhile ends `unavailable` before any charge; then the
account's card is charged, and the domain is registered once the charge is
paid. An account has at most 10 purchases `requested` or
`awaiting_approval` at once; a decision, either way, frees a place.

A purchase is decided only in the dashboard, by a person signed in to it.
The dashboard's bell lists the pending approvals, and its **Approvals** page,
[`https://uniac.ai/approvals`](https://uniac.ai/approvals), lists them with
**Approve** and **Decline**. Each states the name, the one-year price and the
yearly renewal price, as in `Buy example.com for one year for $11.63. It
renews each year at the registrar's renewal price, $11.63 today, while
auto-renew is on.` The **Domains** page,
[`https://uniac.ai/domains`](https://uniac.ai/domains), lists the account's
domains: it retries a failed purchase, turns an active domain's auto-renew on
or off, and opens the Approvals page for a purchase awaiting approval.

| Phase | Meaning | Next step |
| - | - | - |
| `requested` | The name's availability and price are being read at the registrar. | Wait. |
| `awaiting_approval` | The price is known, and the purchase waits for a person's decision. | Approve or decline it on the dashboard's Approvals page. |
| `awaiting_payment` | Approved; the charge is being collected. | Wait. |
| `registering` | Paid; the domain is being registered. | Wait. |
| `active` | The account holds the domain until its expiry, and records when it was registered. | Turn [auto-renew](#renewal) off or on. |
| `expired` | The registration ended without a renewal. | [Delete](#deleting-a-domain) it. |
| `unavailable` | The name cannot be bought: it is registered or another account is buying it (`taken`), the registry sells it at a premium price, which Uniac does not offer (`premium`), or a trademark is registered for it, and Uniac does not register a name under a trademark notice (`trademark_claim`). | Retry, if the name may have come free, or delete it. |
| `declined` | A person declined the purchase. | Retry to ask again, or delete it. |
| `payment_failed` | The charge was not paid: the card was declined (`card_declined`), or the account has no card (`no_payment_method`). Nothing was registered. | Fix or add the card in the dashboard, then retry; or delete it. |
| `registration_failed` | The registry refused the registration after payment (`registry_refused`). | Uniac refunds the charge. Retry starts a new purchase. |

A **retry** starts a new purchase of a domain whose purchase failed
(`unavailable`, `declined`, `payment_failed` or `registration_failed`),
which waits for a person's approval again. Deploying a composition that
declares the domain leaves a failed purchase as it stands.

### Renewal

A domain renews each year while its auto-renew is on, as it is from its
request. From 30 days before its expiry, the renewal is charged at the
renewal price held since 60 days before the expiry; a charge that is not
paid is tried again a day later, until the expiry. Once the charge is paid,
the registration is extended by one year. A renewal under way is
`charging`, `payment_failed` until its next attempt, or `renewing` once
paid.

Only an active domain's auto-renew changes. With auto-renew off, no renewal
is charged, and the domain expires at the end of its registration; a renewal
whose charge was already issued completes. Turning auto-renew off is how the
account lets a domain go.

### Deleting a domain

A domain is deleted while the account holds nothing for it and no money is
owed or in flight: `unavailable`, `declined`, `payment_failed` or
`expired`. The deletion removes it from every read, with its DNS records;
routes that name it stay, with their hostnames `refused` (`domain_not_held`),
and its invoices and decided approvals stay as history. In other phases the
deletion is refused with the reason: a purchase awaiting approval is
declined first, an active domain is let go by turning auto-renew off and
deleted once it expires, and a `registration_failed` domain stays until its
charge is refunded.

The name can then be requested again, a new purchase that waits for a
person again. Deploying a composition that still declares the domain
requests it, so a domain meant to stay gone leaves the composition too.

### DNS records

A held domain carries the DNS records the account sets on it, for email and
for proving the domain to other services. Each record has an id.

| Field | Meaning |
| - | - |
| `type` | `MX`, `TXT` or `CNAME`. |
| `host` | `@`, the domain itself, or a name whose label next to the domain starts with `_`, such as `_dmarc` or `selector1._domainkey`, other than `_acme-challenge`, which Uniac keeps for its certificates. `MX` is at `@` only, `CNAME` at a name starting with `_` only, and `TXT` at either. |
| `value` | An `MX` or `CNAME` record's hostname, or a `TXT` record's text, at most 255 characters. |
| `priority` | An `MX` record's priority, 0 to 65535. |

A record never takes a hostname a route serves. A `CNAME` shares its name
with no other record. A DKIM key longer than 255 characters, such as a
2048-bit key, is set as the `CNAME` the mail provider offers for it, such as
`selector1._domainkey` pointing to the provider's key. Each record has a TTL
of 300 seconds, and a domain has at most 20 records.

| Record phase | Meaning |
| - | - |
| `pending` | The record is being written at the registrar. |
| `ready` | The registrar reports the record. |
| `refused` | The domain is not active (`domain_not_held`). The record is written once it is, so records can be set while the purchase waits. |

A record is changed by removing it and adding the new one. Removing a record
takes it out of every read at once, and its entry at the registrar after.

## Routes

A route belongs to a project and serves the HTTP of one of its services, at
a port, for hostnames under a domain the account holds. Its name is a DNS
label, unique within the project.

| Field | Required | Meaning |
| - | - | - |
| `domain` | Yes | A domain the account holds, such as `example.com`. |
| `hostnames` | Yes | 1 to 10 hostnames under the domain, each named once, such as `www.example.com`. A hostname is neither the domain itself nor a wildcard. |
| `service` | Yes | The name of the project's service that receives the hostnames' HTTP. |
| `port` | Yes | The service's listen port, 1 to 65535. |

An account's routes name at most 25 hostnames in all.

A route is an exposure of its own: a service reached at a route's hostnames
needs no [public endpoint](https://docs.uniac.ai/resources/service.md#public-endpoints), and its
public endpoints keep their own addresses. A route can name a service the
project does not have yet: its hostnames answer 404 until the service is
deployed, and reach it from then on. A route's state describes its hostnames
and its service, not whether the application answers on the port.

### Hostnames

A route **holds** a hostname when the account holds the route's domain and
no earlier route holds the hostname. One route across the platform holds
each hostname: the earliest created route that names it. When that route
lets the hostname go, the next route that names it takes it. A route's other
hostnames are served whatever happens to one of them. The holding is decided
after each change to a route and to the account's domains, so a route
created while its domain's purchase waits holds its hostnames once the
domain is active.

Uniac sets up each held hostname at its HTTP edge, its DNS record and
certificate included. Once it is set up, the hostname reaches the service's
port at `https://<hostname>` while the project has the service.

| Hostname phase | Meaning |
| - | - |
| none | The platform has not yet decided whether the route holds the hostname. |
| `pending` | The route holds it, and the edge has not yet confirmed that it serves the hostname with its certificate: while the hostname is being set up, and whenever the edge stops confirming it. |
| `ready` | The hostname and its certificate are set up at the edge. It reaches the service at `https://<hostname>` once the project has the service, and answers 404 until then. |
| `refused` | The route does not hold it: the account does not hold the domain or the domain is not active (`domain_not_held`), or another route holds the hostname (`in_use`). |

### Route lifecycle

A route stays until it is deleted, including after its declaration leaves
the composition. An update replaces its whole configuration, and a hostname
it keeps stays served throughout. Deleting a route stops serving its
hostnames at once and removes their certificates; its domain stays with the
account. Deleting the project deletes its routes.

## YAML composition example

In [YAML composition](https://docs.uniac.ai/composition/yaml.md#domains-and-routes), a domain and a
route are resources beside the service definitions and deployment
declarations.

```yaml theme={null}
resources:
  web-code:
    type: service
    build: .
  web:
    type: deployment
    from: web-code
  shop:
    type: domain
    name: example.com
  storefront:
    type: route
    domain: example.com
    hostnames: [www.example.com, shop.example.com]
    service: web
    port: 8080
```

Deploying this composition requests `example.com` when the account does not
have it, which starts its purchase, and creates the route `storefront`. Once
a person approves the purchase and the domain is registered, the route holds
both hostnames, and each reaches `web` on port 8080 at its `https://` address
once its certificate is set up. `web` declares no public endpoint, so the
route's hostnames are its public addresses.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.