# Website Builder

Use the ClawkAI website domain API when you have built a website and need to publish it on a public ClawkAI domain.

## What It Does

- Reserves a unique `*-ai.clawkai.com` subdomain.
- Points DNS at the agent host public IP.
- Stores the allocated domain for the authenticated agent.

## Endpoint

```text
POST https://api.clawkai.com/v1/websites/configure-domain
```

## Auth

```text
Authorization: Bearer <gateway_token>
Content-Type: application/json
```

## Gateway Token Location

Use the token location for your runtime:

- OpenClaw: the gateway token is usually stored at `/opt/openclaw/gateway_token`. Some setups may also have it at `~/.openclaw/gateway_token`.
- Hermes: the gateway token is stored in `/root/.hermes/.env` as `API_SERVER_KEY`. The same value is also written as `OPENAI_API_KEY`.

Examples:

```bash
# OpenClaw
GATEWAY_TOKEN="$(cat /opt/openclaw/gateway_token)"

# Hermes
GATEWAY_TOKEN="$(grep -m1 '^API_SERVER_KEY=' /root/.hermes/.env | cut -d= -f2-)"
```

## Request

Send one of these fields:

- `subdomain`
- `slug`
- `name`
- `domain`

```json
{
  "subdomain": "my-site"
}
```

## Example

```bash
curl -sS -X POST "https://api.clawkai.com/v1/websites/configure-domain" \
  -H "Authorization: Bearer ${GATEWAY_TOKEN}" \
  -H "Content-Type: application/json" \
  --data '{"subdomain":"my-site"}'
```

## Response

```json
{
  "ok": true,
  "subdomain": "my-site-ai",
  "domain": "my-site-ai.clawkai.com",
  "status": "active"
}
```

## Agent Flow

1. Build and run the website on the agent runtime.
2. Check what is already running before changing ports or web server config.
3. Call the domain API with the gateway token.
4. Configure the runtime web server or reverse proxy so the returned hostname serves the website.
5. Share the returned `domain` URL with the user.

## Notes

- The API configures DNS only. Your runtime still needs to serve the website for the returned hostname.
- Before starting a site or editing Nginx/reverse proxy config, inspect existing listeners and site configs so you do not break other hosted sites.
- If using Nginx, add a dedicated `server_name` block for the returned domain instead of replacing unrelated configs.
- The requested subdomain is normalized and the API appends `-ai`.
- Example: `my-site` becomes `my-site-ai.clawkai.com`.
- If the requested name is already taken, the API may append a short random suffix.
