# POST /domains

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the domains group.

Add a hosted domain

- Who may call it: administrator, reseller, customer
- Token scope, any of: domains, all
- Answers: 201 Created

UrbeStack creates the document root, Apache virtual host and PHP-FPM pool, and updates DNS and mail configuration. The response contains the new domain in domain. The user field selects the owner and defaults to the signed-in user's account. The name must be unique among domains and aliases on this server.

To add a subdomain, set parent to a standalone domain owned by the same customer. The new name must be below the parent's name in DNS. Subdomains count toward the customer's package limit for domains and are deleted with their parent.

If you specify php_version, such as 8.4, select an installed version that is available for new domains. Wait for any PHP installation to finish before selecting a version. The Apache virtual host template defaults to default. Supplying a nonempty template as a reseller or customer returns 403.

Only administrators can use reserved names, the server's own names, names above or below the server's own names, or names in the server's own DNS zones. The same restriction applies to names above or below another account's domain or alias and names that overlap another server's zone in the DNS distribution network. If this server holds the name's zone for a DNS client, an administrator's request takes over the zone for the new domain and blocks further updates from that client.

When mail.unpointed_domains is set to refuse, the name must already point to this server unless the request specifies a parent or comes from an administrator.

## As a command

- [urbestack-domain-add](https://urbestack.com/docs/commands/urbestack-domain-add.md): Adds a hosted domain to a customer account.

## Request body

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

- `name` (DomainName, required): A domain name is case-insensitive and stored in lowercase.
- `parent` (DomainName): A domain name is case-insensitive and stored in lowercase.
- `php_version` (string, matching ^[5-9]\.[0-9]$)
- `template` (string, matching ^[a-z][a-z0-9-]{0,31}$): Name of the virtual host template used to render the site's configuration. The name must match ^[a-z][a-z0-9-]{0,31}$ and refer to an available template in UrbeStack's apache-vhost-<name>.tmpl files or the administrator's overrides. Only administrators can set this field. Requests from anyone else that supply it return 403.
- `user` (Username): A username consists of lowercase letters, digits and underscores. For the user role, it also serves as the system account name.

## 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 POST "$API/domains" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "example.com",
    "parent": "example.com",
    "php_version": "8.4",
    "template": "default",
    "user": "alice"
  }'
```

Response, 201 Created:

```
{
  "domain": {
    "bandwidth_cut": true,
    "created_at": "2026-09-09T10:15:00Z",
    "directory_listing": true,
    "docroot": "/home/alice/files/web/example.com/public_html",
    "error_pages": true,
    "id": 1,
    "move_state": "text",
    "name": "example.com",
    "package": "basic",
    "parent": "example.com",
    "php_effective": {},
    "php_settings": {},
    "php_version": "8.4",
    "ssl": {},
    "stats_enabled": true,
    "status": "active",
    "template": "default",
    "user": "alice",
    "user_id": 2,
    "wildcard": true,
    "www_alias": true,
    "www_redirect": "none"
  }
}
```

## Errors

- 400: <_> is set per domain, on the PHP page's Domains tab, never as a server default
- 400: A subdomain belongs to the same user as its parent
- 400: A subdomain cannot have a subdomain as its parent
- 400: Domain name required
- 400: Domain name too long
- 400: Domains belong to users with role 'user'
- 400: Invalid IPv4 address
- 400: Invalid IPv6 address
- 400: Invalid PHP version, expected e.g. 8.2
- 400: Invalid domain name
- 400: Invalid port
- 400: Invalid setting key
- 400: Invalid status
- 400: Invalid template name
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: PHP settings must be an object of setting: value
- 400: Subdomain '<name>' does not sit under '<parent.name>'
- 400: Unknown PHP version '<version>'
- 400: Username '<value>' is reserved
- 401: Authentication required
- 403: The virtual host template is set by an administrator
- 404: Parent domain '<parent>' not found
- 404: Setting '<key>' not found
- 404: User '<owner>' not found
- 409: '<name>' is already an alias here
- 409: Domain '<name>' already exists
- 409: The package <p.name> allows <limit> 
