---
title: "Connect a custom domain"
description: "Owner only. Asks for hostname, a subdomain you control such as app.example.com (no apex, no wildcard; an internationalized name in its punycode form), on the computer."
canonical: "https://www.cool.computer/docs/api-reference/domains/connect-a-custom-domain"
---
# Connect a custom domain

> Owner only. Asks for hostname, a subdomain you control such as app.example.com (no apex, no wildcard; an internationalized name in its punycode form), on the computer.

```http
PUT https://api.cool.computer/api/computers/{id}/domain
```

Owner only. Asks for hostname, a subdomain you control such as app.example.com (no apex, no wildcard; an internationalized name in its punycode form), on the computer. Publish the two records of the answer at your DNS provider: the TXT record proves you control the hostname, the CNAME sends its traffic to Cool Computers. Asking again for the computer's hostname answers it as it is; another hostname replaces one still waiting for its TXT record. A computer has one domain, an account at most 10, and at most 3 waiting for their TXT record.

## Authorization

- A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.

## Parameters

- `id` (path, string, at least 1 characters, required): The computer's name, such as agent-atlas, or its id (cmp_…). Every caller may use either, the computer's own runtime token included.

## Request body

Required.

- `application/json` (object)
  - `hostname` (string, 1 to 253 characters, required): A subdomain you control, such as app.example.com.

## Responses

- `200`: The computer's custom domain and the records to publish.
  - `application/json` (object)
    - `hostname` (string, required): The hostname, lowercase, in its punycode form.
    - `state` ("challenge" or "issuing" or "serving" or "active" or "removing", required)
    - `detail` (string): What the domain waits for, or why it was removed.
    - `records` (array of object, required): The DNS records to publish: TXT _cool-challenge.\<hostname> with the challenge value, and the CNAME of the hostname.
      - `type` ("TXT" or "CNAME", required)
      - `name` (string, required)
      - `value` (string, required)
    - `challenge_expires_at` (string, date-time): While the state is challenge: when the request is dropped if the TXT record has not appeared.
- `400`: Bad Request. `invalid_hostname`: the hostname is not a subdomain anyone can connect; detail says why.
- `401`: Unauthorized.
- `409`: Conflict. `domain_connected`: the computer has another domain that is claimed; remove it first. `hostname_in_use`: the hostname is connected to a computer. `domain_limit`: the account has 10 domains. `too_many_unverified_domains`: 3 domains wait for their TXT record.
- `429`: Too Many Requests. If the problem code is api_request_rate_exceeded, wait for Retry-After seconds; other problem codes describe a separate limit.
- `500`: Internal Server Error.
- `503`: Service Unavailable. `artifacts_unavailable` means publishing, and with it custom domains, is not configured on this server.
- `default`: A machine-readable API error with a stable code and recovery instruction.

An error is an `application/problem+json` document with a stable `code`; [API errors](/docs/api-reference/errors) says how to handle one.

## Example

```sh
curl -X PUT "https://api.cool.computer/api/computers/$PARAM_ID/domain" \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  --data '{"hostname":"app.example.com"}'
```
