# Attach Custom Domain to Hosted Site Slug

> Attach Custom Domain to Hosted Site Slug is a paid API for AI agents from host.withzero.ai, paid per call via MPP, metered — billed by usage, status unknown (last checked 2026-10-01).

Binds a caller-owned custom domain (purchased via domain-buy) to a hosted site slug, registering it as a Cloudflare Worker Custom Domain with auto-provisioned SSL.

## Facts

- Endpoint: POST https://host.withzero.ai/sites/:slug/domains?utm_source=zero.xyz
- Price: metered — billed by usage
- Payment: MPP
- Status: unknown
- Last checked: 2026-10-01
- Activations on Zero: 0
- Provider: host.withzero.ai
- Website: https://host.withzero.ai
- Canonical page: https://www.zero.xyz/c/host-withzero-ai-attach-custom-domain-to-hosted-site-slug-1c8723dd
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_zLI7LUYNzL-uGD3ZyXyk4

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability host-withzero-ai-attach-custom-domain-to-hosted-site-slug-1c8723dd -d '<json body>'
```

Example prompt: Attach the domain myportfolio.com to my withzero hosted site at slug 'my-portfolio' — I already bought the domain through domain-buy.

## When to prefer this

Use this endpoint when you have already uploaded a static site to host.withzero.ai and want to serve it under your own branded domain that was purchased through the domain-buy service. This is the right call when you need Cloudflare-backed SSL auto-provisioning and want sub-paths on your custom domain to serve your single-file hosted site. Choose this over a generic DNS configuration when you are already within the withzero.ai hosting ecosystem.

## Known failure modes

- Caller does not own the slug — authorization error
- Caller does not own the domain in domain-buy — ownership verification failure
- Domain format is invalid or doesn't match the required pattern — 400 validation error
- Domain is already attached to another slug — conflict error
- Cloudflare registration fails — upstream error from Cloudflare Worker Custom Domain API
- Domain length exceeds 253 characters — schema validation error

## How this service works

Attach a custom domain (bought via domain-buy) to this slug. The caller must own both the slug and the domain. Calls Cloudflare to register the hostname as a Worker Custom Domain on the sites worker (SSL is auto-provisioned). Sub-paths on the custom domain serve the slug's index.html — single-file hosting model.

## Output

Returns a JSON object confirming the custom domain has been registered as a Cloudflare Worker Custom Domain on the site's worker. SSL is automatically provisioned by Cloudflare. Sub-paths on the custom domain will serve the slug's index.html.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "domain"
 ],
 "properties": {
  "domain": {
   "type": "string",
   "pattern": "^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\\.[a-zA-Z]{2,})+$",
   "maxLength": 253,
   "minLength": 3,
   "description": "Fully-qualified domain to bind to this slug. Must be owned by caller via domain-buy."
  }
 },
 "additionalProperties": false
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/host-withzero-ai-attach-custom-domain-to-hosted-site-slug-1c8723dd/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from host.withzero.ai](https://www.zero.xyz/host/host.withzero.ai/llms.txt)
