Attach your own domain #

View this page as Markdown

On this page

Prompt:

Put our app on app.example.com.

Also works:

  • "Serve the app from our own domain instead of the ai.host address."
  • "Why does app.example.com still say pending?"

Any application can attach a custom domain. Your AI assistant declares the domain and gives you the CNAME and TXT records to add at your DNS provider. It then checks when the domain is serving.

A custom domain has a monthly rate. The daily billing run charges one day’s share for each UTC day it finds the domain serving, starting with the first run after it has served. Detaching the domain stops new charges from the next run. Charges already made stay on the account.

Read the current rate on the pricing page, or call read_rate_card.

What your AI does #

  • Reads the custom-domain skill (read_context, id skill:custom-domain) and follows it.
  • Asks you for the exact hostname, such as app.example.com. Before you write any record, it tells you how many of your users' passkeys will stop working once the domain goes live.
  • After you agree to attach the domain, adds the custom_domain entry to the manifest's services and submits the whole manifest with submit_manifest. The submission needs no browser approval.
  • Hands you the CNAME record from the submit_manifest response and the TXT record from read_status, exactly as the platform gives them.
  • Changes nothing at your DNS provider itself, unless you have connected the provider to your AI assistant and ask it to.
  • Checks read_status until the domain reads serving, then confirms the domain.
  • Before it removes (detaches) the domain, tells you that removing it stops your users' passkeys on the domain from working, and asks you first.

What you need #

  • A domain you control, and the login to the DNS provider that holds its records.
  • An application deployed to production (Deploy from your computer).

Before your AI starts #

For your AI: Check the following before starting.

  • A connected, signed-in AI assistant (Connect your AI assistant).
  • The application's identifier from list_applications.
  • The application's current manifest, from your project or export_account.

To recover the recorded copy, call export_account through your signed-in connection. Find the application by its id in export.applications and use its manifest (export.applications[].manifest). A submission replaces the whole document.

Steps #

1. Choose the name #

Each application can attach one hostname, and only to its production environment. The development hostname does not change.

The hostname must be lowercase and have at least three labels, the parts between the dots, such as app.example.com. A bare domain cannot be attached: example.com is refused manifest_invalid because it has only two labels; example.co.uk passes that check but is refused custom_domain_invalid with reason apex. Attach www or another name under it instead. You also cannot attach a wildcard such as *.example.com, a public suffix, or a name another application already holds.

If your DNS provider offers web forwarding, you can configure a redirect from example.com to https://www.example.com after attaching www.example.com. That redirect is configured at your provider; it does not attach the bare domain to Turn Zero.

You cannot attach a hostname under ai.host or turnzero.ai. This includes the edge hostname the platform gives you for your CNAME record. A name that is not lowercase, has fewer than three labels, or is a wildcard is refused manifest_invalid.

2. Declare the domain in the manifest #

Your AI assistant adds this entry to services and submits the whole manifest:

{ "kind": "custom_domain", "domain": "app.example.com" }

The response's custom_domain includes domain, state, and since, the time the domain entered that state. Its records list always includes the CNAME record for your DNS provider. It points your hostname to the platform's edge name, such as edge.ai.host. The list includes a TXT record once the hosting provider supplies its value. passkeys_to_strand counts the passkeys that will stop working when the domain goes live (What changes for your users).

The platform then sets the domain up in the background. Nothing changes for the application's visitors until the domain is live, its state serving (step 5).

A name step 1 rules out, such as example.co.uk or a name another application holds, is refused 400 custom_domain_invalid, with the reason. This refusal leaves the manifest unchanged. A manifest declares only one domain. A second custom_domain entry is refused manifest_invalid, naming the entry's path. To change the name, follow step 7.

3. Write the CNAME record #

Your AI assistant hands you the record exactly as the response gives it: its name, the type CNAME, and its value. Add it at your DNS provider, among your domain's records (its zone). The platform adds no record there and never asks for your provider's login.

Until the domain's state reads serving (step 5), keep every link and address your application hands out on the managed hostname. That is the ai.host address the platform gave your application.

4. Write the TXT record #

The platform reads the TXT record once its hosting provider supplies it. The TXT record proves you control the name. Add it at your DNS provider, as you added the CNAME record.

Once the provider supplies the TXT value, read_status shows both records under custom_domain.records. custom_domain also shows the passkey count, state, and the time the domain entered that state. Your AI assistant copies the TXT record from there and never makes one up. It hands you the record's name, the type TXT, and its value.

If that name already holds a TXT value at your provider, replace it with the new value or add the new value beside it.

While the platform is busy with other domains, the domain's reason reads queued, and no TXT record shows yet. After queued clears, check read_status for the record. If it is still missing, report the current state and reason with submit_feedback (Feedback).

5. Wait until the domain is live #

Your AI assistant checks read_status about once a minute. The domain's state moves through these:

State What it means
records_pending The platform is waiting for your CNAME record to be visible on the public internet.
validating The CNAME record was found; the hosting provider still has to approve the domain using the TXT record.
issuing The platform is setting up the domain's HTTPS certificate and edge servers. This state includes a 15-minute wait after the hosting provider reports deployment complete, before the domain first goes live.
serving The domain is set to serve production. Your users now sign in on it.
detaching The domain is being removed, after you removed the entry (step 7).
failed Something stopped the attach, and the domain's reason says what.

DNS changes take time to spread, so records_pending can last from minutes to an hour or more, depending on your provider. Both records are needed: validating confirms the CNAME was found, not that the TXT record has passed validation.

A failed state shows one of these reasons:

Reason Cause What to do
records_missing The hosting provider's domain validation timed out, so the platform requests a new TXT value. Check both DNS records and submit the manifest again. The domain goes back to records_pending. Read the refreshed TXT value with read_status and add it as in step 4; see the retry steps below.
caa_blocks_issuer A CAA record at your DNS provider, which limits who may issue certificates for your domain, does not allow the platform's certificate issuer. Ask the person who manages your domain's DNS to review its certificate policy and agree to any change. After they update the record, submit the manifest again.
capacity The platform's hosting provider is at its limit for domains. Nothing on your side fixes this. Ask the platform operator, then submit the manifest again.
provider_refused The platform's hosting provider refused the domain or could not finish setting it up. Its reason reaches the platform's own log, not read_status. Check that the records read_status shows are in place at your DNS provider, then submit the manifest again. If it fails again, ask the platform operator, who can read the provider's reason.
certificate_lapsed A domain that was live lost its certificate. The platform saw this on two hourly checks in a row. Check that both records are still in place, then submit the manifest again. Sign-in remains configured for this domain, so a certificate failure can prevent users from reaching it. Detaching the domain (step 7) moves sign-in back to the managed hostname.

To retry a failed attachment, submit the manifest again. After records_missing, read_status can still show the old TXT value until a background read gets the refreshed value from the hosting provider. Resubmitting does not clear the old value. Compare the TXT value with the one previously supplied for this attachment; a return to records_pending alone does not prove it is new. Your AI assistant reads about once a minute and gives you the changed value to add.

If the domain was never live, your users still use the managed hostname. If it had been live, sign-in remains configured for the custom domain until you detach it; a failure does not automatically move sign-in back.

Once the domain is live, two more reasons can appear beside serving:

  • chain_not_found means the CNAME record no longer points at the edge name. The domain is still live for now. Restore the record.
  • revalidation_pending means the certificate's renewal needs a fresh TXT value. Compare the value in read_status with the one you installed. The status can still show the old value. Check again until it changes, then update the record as in step 4.

6. Confirm #

When the state first reads serving, the 15-minute wait is complete. Check that the domain opens. Check the running app's hostname setting separately. If a request fails, retry once before reporting the failure.

Open https://app.example.com in a browser, or ask your AI assistant to open it with its browser tool. The page loads there, and the application's cookies are set on that hostname. The managed production hostname keeps serving the application, but a sign-in started there does not complete (What changes for your users). The development hostname is unchanged.

From now on, hand out links on your domain. After recording serving for the first time, the platform asks for a production restart. Once the new copy is running, its APP_PUBLIC_HOST setting reads your domain (A deployed app's settings). Read it from the running server's environment, with process.env.APP_PUBLIC_HOST in Node.js, and build your links from it. A local process reads its own settings, not the deployed copy's.

If the restart is refused, read the domain's reason in read_status. The production copy then keeps the managed hostname until the next deploy, promote, or restart_application.

7. Change or remove the domain #

To detach the domain, remove its entry from services and submit the manifest again. The domain moves to detaching and then stops responding.

If the domain had been live, the platform tries to refresh production's settings. A refused refresh can leave the running copy using the custom hostname in APP_PUBLIC_HOST. A later successful production deploy, promote, or restart applies the managed hostname.

To change the name, detach the old one first. Wait until read_status no longer shows the custom_domain member, then declare the new name. A new name declared while the old one is still detaching is refused custom_domain_invalid with the reason held.

Use Cloudflare's proxy #

If Cloudflare proxies your custom domain, you can let Turn Zero use each visitor's address. Follow the domain attachment steps above, then set up a dedicated secret for the proxy.

  1. Create a random value of at least 32 characters on your computer. Use store_secret to store it at the application's production scope. Keep the value out of the manifest and chat. See Keep a secret value out of chat.
  2. In the custom_domain entry, set proxied_by to "cloudflare" and set proxy_secret to the stored secret's name. Supply both members together. Use this secret only for the proxy. It cannot also be a bound setting, an upstream key, or a sign-in or push credential.
  3. In the Cloudflare zone, create a request header transform rule for this hostname. Set X-Turnzero-Proxy-Secret to the same value you stored in production. Submit the whole manifest with submit_manifest.

Turn Zero uses the visitor address Cloudflare sends when the request comes from Cloudflare's published ranges and the secret matches. The visitor's address then applies to per-address request and sign-in limits and logs that record addresses. If either check fails, Turn Zero uses the connecting address. Multiple visitors may share that proxy address and its limit. Turn Zero removes the secret header before the request reaches your application.

To rotate the secret, replace the production value first, then update the Cloudflare rule. When the router next resolves the domain, it uses the new value. While the rule and the platform's value differ, visitors can share the proxy address.

What changes for your users #

Your users' passkeys work only on the hostname they were registered on. When the domain first goes live, the production sign-in moves to the domain. So every passkey registered on the managed hostname stops working. The count is passkeys_to_strand in step 2's response, and read_status keeps it current until the domain is live. If you can, attach the domain before your users register passkeys.

Once the domain is live, your users sign in on the domain. A sign-in started on the managed hostname does not complete, whatever sign-in method it uses, and the person signs in again on the domain. The managed hostname's sign-in page offers no passkey and says that passkeys work on the domain. Through records_pending, validating, and issuing, nothing changes for your users.

A user whose passkey stopped working signs in on the domain with an emailed code or another method. They are then offered a new passkey there. Detaching the domain reverses the move: the old passkeys work again, and the ones registered on the domain stop working.

passkeys_stranded counts the passkeys that stopped working after you attached or detached the domain. While the domain is attached after it has served, read_status gives the count stranded by the attach. The submission that detaches the domain gives the count stranded by the detach under the same name. Renaming the application while the domain is attached stops the old passkeys working for good (Rename the application).

A native app that signs in through your application must list the domain. On iOS, add webcredentials:app.example.com to the app's associated domains. The platform serves the association files on the domain, as it does on the managed hostname. An Android app's declared signing fingerprints stay accepted on the domain (Sign in from a native app).

A sign-in client can have a redirect address that is an https address on the domain, such as https://app.example.com/callback. You can declare that client with configure_app_sign_in once you have attached the domain, before it is live. It can also go in the manifest's production clients list while the same manifest declares the domain (Sign in from a native app). A submission that removes the domain but keeps that address is refused, and nothing is recorded. Sign-in accepts that redirect from the time the domain first goes live until you detach it.

A client declared with configure_app_sign_in keeps the address after the detach, but sign-in refuses it from then on. After the detach, a configure_app_sign_in call that repeats the address is refused invalid_redirect_uri. So remove the address from the client's redirect_uris.

Expected result #

read_status shows the production environment's custom_domain member with the state serving, both records, and passkeys_stranded, the number of passkeys that stopped working when the domain went live. https://app.example.com shows the application. The managed production hostname still shows its pages, with sign-in on the domain. After the platform's restart, APP_PUBLIC_HOST in the production copy reads your domain. The development hostname works as before.

Refusals #

See the refusals reference for other platform errors.

Refusal Status Cause Remedy
custom_domain_invalid 400 The hostname is refused for the reason given: apex, reserved, public_suffix, or held. Choose a different hostname and submit again. For a bare domain, choose a subdomain. If the hostname is already held, choose another hostname you control. If your own earlier domain holds the name, detach it first and wait until read_status no longer shows it.
custom_domain_capacity 409 The platform's domains are at their limit, given in bound. Nothing is written. Nothing on your side raises the limit. Ask the platform operator, then submit again. Removing the entry lets the submission through without the domain.
custom_domains_not_yet_served 400 The platform is not serving custom domains. Remove the custom_domain entry and submit the manifest again. The platform operator turns the feature on.