# Hosting Plans

<a id="get-api-v1-plans"></a>
#### `GET /api/v1/plans`

*List hosting plans*

Returns every plan defined on the server. Pass `owner=<username>` to filter to reseller-owned plans.

**Query parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `owner` | string | no | Filter by owner username (reseller plans) |

**Responses:**

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

**Response example (200):**

```json
{
  "data": [
    {
      "account_count": "...",
      "created_at": "...",
      "description": "...",
      "id": "...",
      "name": "...",
      "owner_username": "...",
      "package": "...",
      "sort_order": "...",
      "updated_at": "...",
      "visible": "..."
    }
  ],
  "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/plans
```

---

<a id="post-api-v1-plans"></a>
#### `POST /api/v1/plans`

*Create hosting plan*

Define a new plan template with package limits, resource caps and (optionally) reseller ownership.

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `description` | string | no | default ``; maxLength=500 |
| `name` | string | yes | minLength=1; maxLength=100 |
| `owner_username` | string | no | — |
| `package` | PackageLimits | no | — |
| `sort_order` | integer | no | default `0`; minimum=0.0 |
| `visible` | boolean | no | default `True` |

**Request body example:**

```json
{
  "description": "",
  "name": "string",
  "owner_username": "string",
  "package": {
    "bandwidth_mb": 10240,
    "disk_mb": 1024,
    "email_hourly_limit": 100,
    "max_databases": 1,
    "max_domains": 1,
    "max_email_accounts": 5,
    "max_ftp_accounts": 5,
    "max_node_apps": 0,
    "max_parked_domains": 1,
    "max_python_apps": 0,
    "max_subdomains": 5,
    "node_max_memory_mb": 0,
    "node_workers_limit": 4,
    "python_workers_limit": 4,
    "resource": {
      "cpu_limit": "...",
      "io_read_mbps": "...",
      "io_write_mbps": "...",
      "iops_read": "...",
      "iops_write": "...",
      "memory_mb": "...",
      "nproc": "..."
    }
  },
  "sort_order": 0,
  "visible": true
}
```

**Responses:**

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

**Response example (200):**

```json
{
  "data": {
    "account_count": 0,
    "created_at": "...",
    "description": "",
    "id": "string",
    "name": "string",
    "owner_username": "...",
    "package": "...",
    "sort_order": 0,
    "updated_at": "...",
    "visible": true
  },
  "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/plans
```

---

<a id="delete-api-v1-plans-plan-id"></a>
#### `DELETE /api/v1/plans/{plan_id}`

*Delete hosting plan*

Remove a plan template. Refuses to delete plans currently assigned to active accounts.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `plan_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/plans/{plan_id}
```

---

<a id="get-api-v1-plans-plan-id"></a>
#### `GET /api/v1/plans/{plan_id}`

*Get hosting plan*

Fetch a plan's full record by id.

**Path parameters:**

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

**Responses:**

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

**Response example (200):**

```json
{
  "data": {
    "account_count": 0,
    "created_at": "...",
    "description": "",
    "id": "string",
    "name": "string",
    "owner_username": "...",
    "package": "...",
    "sort_order": 0,
    "updated_at": "...",
    "visible": true
  },
  "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/plans/{plan_id}
```

---

<a id="put-api-v1-plans-plan-id"></a>
#### `PUT /api/v1/plans/{plan_id}`

*Update hosting plan*

Patch a plan's metadata, package limits or resource caps. Existing accounts on the plan are not retro-updated.

**Path parameters:**

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

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `description` | string | no | — |
| `name` | string | no | — |
| `package` | PackageLimits | no | — |
| `sort_order` | integer | no | — |
| `visible` | boolean | no | — |

**Request body example:**

```json
{
  "description": "string",
  "name": "string",
  "package": {
    "bandwidth_mb": 10240,
    "disk_mb": 1024,
    "email_hourly_limit": 100,
    "max_databases": 1,
    "max_domains": 1,
    "max_email_accounts": 5,
    "max_ftp_accounts": 5,
    "max_node_apps": 0,
    "max_parked_domains": 1,
    "max_python_apps": 0,
    "max_subdomains": 5,
    "node_max_memory_mb": 0,
    "node_workers_limit": 4,
    "python_workers_limit": 4,
    "resource": "..."
  },
  "sort_order": 0,
  "visible": false
}
```

**Responses:**

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

**Response example (200):**

```json
{
  "data": {
    "account_count": 0,
    "created_at": "...",
    "description": "",
    "id": "string",
    "name": "string",
    "owner_username": "...",
    "package": "...",
    "sort_order": 0,
    "updated_at": "...",
    "visible": true
  },
  "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/plans/{plan_id}
```

---
