# PUT /botmail/domains/{name}

First published 22 Oct 2026 (release 0.2.15) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the mail group.

Enable BotMail for a domain or change its BotMail hostname

- Who may call it: administrator, reseller, customer
- Token scope, any of: mail, all
- Answers: 200 OK

The domain's mail must be hosted on this server, and the customer's package must allow BotMail. The label sets the hostname in the form LABEL.DOMAIN. UrbeStack trims surrounding whitespace and converts the label to lowercase. It accepts up to 32 letters, digits, and hyphens, with a letter or digit at each end. An invalid or reserved label returns 400. If label is omitted or empty, UrbeStack tries mcp, then mcp2 through mcp20. Choose another label if a site, domain alias, or DNS record already uses the hostname.

If the domain is already ready at the requested hostname, the API returns 200 with the domain. When it queues setup, it returns 202 with the domain and job. A queued or running setup job for the domain must finish before you can submit another. Changing the hostname disables the previous hostname immediately.

The job publishes DNS records if the zone is hosted on or distributed from this server. It checks once whether the hostname resolves to this server. If the check fails, the job stops and reports which A or AAAA records to add or update. After correcting the records, submit PUT /botmail/domains/{name} again. Retries are manual.

UrbeStack uses the domain's wildcard certificate if it covers the hostname. Otherwise it obtains a dedicated certificate using HTTP-01. Apache serves the hostname over HTTPS on port 443. Once the domain is ready, you can create bot keys for its mailboxes. Bots connect only through that hostname.

## As a command

- [urbestack-botmail-domain-on](https://urbestack.com/docs/commands/urbestack-botmail-domain-on.md): Turns on BotMail for a domain whose mail is hosted on this server or changes its BotMail hostname.

## Parameters

- `name` (path, DomainName, required)

## Request body

JSON, the type [BotDomainOn](https://urbestack.com/docs/api/types/BotDomainOn.md).

- `label` (string): First label of the BotMail hostname, using letters, digits, and hyphens. If omitted, UrbeStack uses mcp when available or the first free label in the numbered sequence beginning with mcp2.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X PUT "$API/botmail/domains/example.com" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "my laptop"
  }'
```

Response, 200 OK:

```
{
  "domain": {
    "cert_error": "text",
    "cert_not_after": "text",
    "error": "Domain 'example.com' already exists",
    "host": "text",
    "job": {
      "id": 1,
      "status": "active"
    },
    "keys": 1,
    "label": "my laptop",
    "mailboxes": 1,
    "name": "alice",
    "records": [
      {
        "name": "alice",
        "type": "A",
        "value": 8443
      }
    ],
    "state": "off",
    "suggested": "text",
    "user": "alice",
    "wildcard": true
  },
  "job": {
    "created_at": "2026-09-09T10:15:00Z",
    "created_by": 1,
    "created_by_name": "text",
    "dismissed_at": "text",
    "finished_at": "2026-09-09T10:15:04Z",
    "id": 1,
    "lane": "short",
    "log": "",
    "params": {},
    "progress": 100,
    "result": {},
    "started_at": "2026-09-09T10:15:01Z",
    "status": "queued",
    "type": "rebuild",
    "usual_seconds": 1
  }
}
```

## Errors

- 400: --name is required
- 400: <value> is kept for the domain's own use; pick another name, like mcp
- 400: A name is letters, digits and hyphens, up to 32, like mcp
- 400: A new job is queued or running
- 400: Domain name required
- 400: Domain name too long
- 400: Invalid IPv4 address
- 400: Invalid IPv6 address
- 400: Invalid domain name
- 400: Invalid port
- 400: Invalid setting key
- 400: Job parameters must be an object
- 400: Unknown job type
- 401: Authentication required
- 403: The package <p.name> does not include <SWITCH_WHAT>{<switch>}
- 404: Setting '<key>' not found
- 409: <why>; pick another name
- 409: BotMail is being turned on for <name> already
