# Domains

<a id="get-api-v1-accounts-username-addon-domains"></a>
#### `GET /api/v1/accounts/{username}/addon-domains`

*List addon domains*

Returns every addon domain attached to the account.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_AddonDomainResponse__` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": [
    {
      "created_at": "...",
      "document_root": "...",
      "domain": "...",
      "ssl_active": "...",
      "username": "..."
    }
  ],
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/addon-domains
```

---

<a id="post-api-v1-accounts-username-addon-domains"></a>
#### `POST /api/v1/accounts/{username}/addon-domains`

*Create addon domain*

Attach a new domain to the account: provisions a vhost, DNS zone, Apache/Nginx config and Pure-FTPd entries. Enforces the plan's `max_domains` cap. Refused 403 `ACCOUNT_SUSPENDED` while the account is suspended.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `auto_ssl` | boolean | no | default `False` |
| `document_root` | string | no | — |
| `domain` | string | yes | — |
| `setup_dns` | boolean | no | default `True` |

**Request body example:**

```json
{
  "auto_ssl": false,
  "document_root": "string",
  "domain": "example.com",
  "setup_dns": true
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_AddonDomainResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "created_at": "",
    "document_root": "string",
    "domain": "example.com",
    "ssl_active": false,
    "username": ""
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/addon-domains
```

---

<a id="delete-api-v1-accounts-username-addon-domains-domain"></a>
#### `DELETE /api/v1/accounts/{username}/addon-domains/{domain}`

*Delete addon domain*

Remove the addon domain with its vhost, DNS zone, certificate files, the subdomains under it and the parked domains pointing at it.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `domain` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `MessageResponse` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "message": "string",
  "status": "success"
}
```

**cURL example:**

```bash
curl -X DELETE \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/addon-domains/{domain}
```

---

<a id="get-api-v1-accounts-username-domains"></a>
#### `GET /api/v1/accounts/{username}/domains`

*List every domain on an account*

Returns primary, addon, subdomain and parked domains in a unified shape.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_DomainResponse__` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": [
    {
      "created_at": "...",
      "document_root": "...",
      "domain": "...",
      "ssl_active": "...",
      "type": "...",
      "username": "..."
    }
  ],
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/domains
```

---

<a id="get-api-v1-accounts-username-parked-domains"></a>
#### `GET /api/v1/accounts/{username}/parked-domains`

*List parked domains*

Returns every parked (alias) domain — points DNS+HTTP at the primary domain.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_ParkedDomainResponse__` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": [
    {
      "created_at": "...",
      "domain": "...",
      "target_domain": "...",
      "username": "..."
    }
  ],
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/parked-domains
```

---

<a id="post-api-v1-accounts-username-parked-domains"></a>
#### `POST /api/v1/accounts/{username}/parked-domains`

*Create parked domain*

Add an alias domain that resolves to the primary domain. Enforces the plan's `max_parked_domains` cap. Refused 403 `ACCOUNT_SUSPENDED` while the account is suspended.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `domain` | string | yes | — |
| `target_domain` | string | no | — |

**Request body example:**

```json
{
  "domain": "example.com",
  "target_domain": "string"
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_ParkedDomainResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "created_at": "",
    "domain": "example.com",
    "target_domain": "example.com",
    "username": ""
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/parked-domains
```

---

<a id="delete-api-v1-accounts-username-parked-domains-domain"></a>
#### `DELETE /api/v1/accounts/{username}/parked-domains/{domain}`

*Delete parked domain*

Remove the alias domain and its DNS zone.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `domain` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `MessageResponse` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "message": "string",
  "status": "success"
}
```

**cURL example:**

```bash
curl -X DELETE \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/parked-domains/{domain}
```

---

<a id="get-api-v1-accounts-username-redirects"></a>
#### `GET /api/v1/accounts/{username}/redirects`

*List URL redirects*

Returns every HTTP redirect rule configured for the account's domains.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_RedirectResponse__` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": [
    {
      "created_at": "...",
      "destination_url": "...",
      "domain": "...",
      "id": "...",
      "source_path": "...",
      "type": "...",
      "username": "..."
    }
  ],
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/redirects
```

---

<a id="post-api-v1-accounts-username-redirects"></a>
#### `POST /api/v1/accounts/{username}/redirects`

*Create URL redirect*

Add a 301/302 redirect rule (source path on owned domain → target URL).

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `destination_url` | string | yes | minLength=1; maxLength=2048 |
| `domain` | string | yes | — |
| `source_path` | string | yes | minLength=1; maxLength=2048 |
| `type` | string | no | default `301`; enum: `301`, `302` |

**Request body example:**

```json
{
  "destination_url": "string",
  "domain": "example.com",
  "source_path": "string",
  "type": "301"
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_RedirectResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "created_at": "",
    "destination_url": "string",
    "domain": "example.com",
    "id": "string",
    "source_path": "string",
    "type": "string",
    "username": ""
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/redirects
```

---

<a id="delete-api-v1-accounts-username-redirects-redirect-id"></a>
#### `DELETE /api/v1/accounts/{username}/redirects/{redirect_id}`

*Delete URL redirect*

Remove a redirect rule by id.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `redirect_id` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `MessageResponse` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "message": "string",
  "status": "success"
}
```

**cURL example:**

```bash
curl -X DELETE \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/redirects/{redirect_id}
```

---

<a id="put-api-v1-accounts-username-redirects-redirect-id"></a>
#### `PUT /api/v1/accounts/{username}/redirects/{redirect_id}`

*Update URL redirect*

Modify the source path, destination or type of an existing redirect rule.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `redirect_id` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `destination_url` | string | no | — |
| `source_path` | string | no | — |
| `type` | string | no | — |

**Request body example:**

```json
{
  "destination_url": "string",
  "source_path": "string",
  "type": "301"
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_RedirectResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "created_at": "",
    "destination_url": "string",
    "domain": "example.com",
    "id": "string",
    "source_path": "string",
    "type": "string",
    "username": ""
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X PUT \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/redirects/{redirect_id}
```

---

<a id="get-api-v1-accounts-username-subdomains"></a>
#### `GET /api/v1/accounts/{username}/subdomains`

*List subdomains*

Returns every subdomain under the account's owned domains.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_SubdomainResponse__` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": [
    {
      "created_at": "...",
      "document_root": "...",
      "full_domain": "...",
      "parent_domain": "...",
      "php_version": "...",
      "subdomain": "...",
      "username": "..."
    }
  ],
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X GET \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/subdomains
```

---

<a id="post-api-v1-accounts-username-subdomains"></a>
#### `POST /api/v1/accounts/{username}/subdomains`

*Create subdomain*

Provision a subdomain pointing at a folder under the account's docroot. Enforces `max_subdomains`. Refused 403 `ACCOUNT_SUSPENDED` while the account is suspended.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `document_root` | string | no | — |
| `parent_domain` | string | yes | — |
| `php_version` | string | no | — |
| `subdomain` | string | yes | — |

**Request body example:**

```json
{
  "document_root": "string",
  "parent_domain": "example.com",
  "php_version": "string",
  "subdomain": "example.com"
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_SubdomainResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "created_at": "",
    "document_root": "string",
    "full_domain": "example.com",
    "parent_domain": "example.com",
    "php_version": "",
    "subdomain": "example.com",
    "username": ""
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X POST \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/subdomains
```

---

<a id="delete-api-v1-accounts-username-subdomains-subdomain"></a>
#### `DELETE /api/v1/accounts/{username}/subdomains/{subdomain}`

*Delete subdomain*

Remove the subdomain's DNS record and vhost; the subdomain's own folder under the account home is renamed <folder>-removed-<timestamp> (nothing is deleted).

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `subdomain` | string | yes | — |

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `MessageResponse` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "message": "string",
  "status": "success"
}
```

**cURL example:**

```bash
curl -X DELETE \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  https://your-server:2000/api/v1/accounts/{username}/subdomains/{subdomain}
```

---

<a id="put-api-v1-accounts-username-subdomains-subdomain"></a>
#### `PUT /api/v1/accounts/{username}/subdomains/{subdomain}`

*Update subdomain*

Rename a subdomain or change its document root or PHP version.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `username` | string | yes | — |
| `subdomain` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `document_root` | string | no | — |
| `php_version` | string | no | — |
| `subdomain` | string | no | — |

**Request body example:**

```json
{
  "document_root": "string",
  "php_version": "string",
  "subdomain": "string"
}
```

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_SubdomainResponse_` | Successful Response |
| `422` | `HTTPValidationError` | Validation Error |

**Response example (200):**

```json
{
  "data": {
    "created_at": "",
    "document_root": "string",
    "full_domain": "example.com",
    "parent_domain": "example.com",
    "php_version": "",
    "subdomain": "example.com",
    "username": ""
  },
  "message": "",
  "status": "success",
  "warnings": [
    "string"
  ]
}
```

**cURL example:**

```bash
curl -X PUT \
  -H "X-WHost-Key: $WHOST_API_KEY" \
  -H "X-WHost-Timestamp: $(date +%s)" \
  -H "X-WHost-Nonce: $(openssl rand -hex 16)" \
  -H "X-WHost-Signature: $(compute_hmac)" \
  -H "Content-Type: application/json" \
  -d @body.json \
  https://your-server:2000/api/v1/accounts/{username}/subdomains/{subdomain}
```

---
