# Mail Hosts endpoints (Admin API)

> 6 FeatherPanel Admin API endpoints from admin/mail-hosts.php: methods, paths, auth, permissions, rate limits, parameters and responses.

Source: https://featherpanel.com/docs/api/reference/admin/mail-hosts/

Defined in [`backend/app/routes/admin/mail-hosts.php`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/admin/mail-hosts.php). Authentication used here: **Admin**. Read [Authentication](https://featherpanel.com/docs/api/authentication/) for how to send credentials and [Rate limits and errors](https://featherpanel.com/docs/api/rate-limits-and-errors/) for the response envelope.

Paths, methods, permissions and rate limits come from the route file. Summaries, parameters and response codes come from the OpenAPI annotations on the controllers; endpoints without annotations show only what the route file declares.

## Endpoints

### GET `/api/admin/mail-hosts`

- Auth: Admin
- Permission: `admin.webspaces.view`
- Route name: `admin-mail-hosts`
- Controller: [`MailHostsController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/MailHostsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/admin/mail-hosts.php#L26)

**List mail hosts**

```bash
curl -X GET "$PANEL_URL/api/admin/mail-hosts" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

### GET `/api/admin/mail-hosts/{id}`

- Auth: Admin
- Permission: `admin.webspaces.view`
- Route name: `admin-mail-hosts-show`
- Controller: [`MailHostsController::show`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/MailHostsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/admin/mail-hosts.php#L36)

**Show mail host**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | \- | yes |  |

```bash
curl -X GET "$PANEL_URL/api/admin/mail-hosts/$ID" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

### POST `/api/admin/mail-hosts/ensure-node/{webNodeId}`

- Auth: Admin
- Permission: `admin.webspaces.edit`
- Route name: `admin-mail-hosts-ensure-node`
- Controller: [`MailHostsController::ensureNode`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/MailHostsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/admin/mail-hosts.php#L51)

**Ensure node mail host exists**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `webNodeId` | path | \- | yes |  |

```bash
curl -X POST "$PANEL_URL/api/admin/mail-hosts/ensure-node/$WEB_NODE_ID" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

### PUT `/api/admin/mail-hosts`

- Auth: Admin
- Permission: `admin.webspaces.create`
- Route name: `admin-mail-hosts-create`
- Controller: [`MailHostsController::create`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/MailHostsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/admin/mail-hosts.php#L67)

**Create mail host**

```bash
curl -X PUT "$PANEL_URL/api/admin/mail-hosts" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Plugin events: [`featherpanel:admin:mail_hosts:host:created`](https://featherpanel.com/docs/plugins/events/mail-hosts/#mail-host-created)

### PATCH `/api/admin/mail-hosts/{id}`

- Auth: Admin
- Permission: `admin.webspaces.edit`
- Route name: `admin-mail-hosts-update`
- Controller: [`MailHostsController::update`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/MailHostsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/admin/mail-hosts.php#L78)

**Update mail host**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | \- | yes |  |

```bash
curl -X PATCH "$PANEL_URL/api/admin/mail-hosts/$ID" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Plugin events: [`featherpanel:admin:mail_hosts:host:updated`](https://featherpanel.com/docs/plugins/events/mail-hosts/#mail-host-updated)

### DELETE `/api/admin/mail-hosts/{id}`

- Auth: Admin
- Permission: `admin.webspaces.delete`
- Route name: `admin-mail-hosts-delete`
- Controller: [`MailHostsController::delete`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/MailHostsController.php)
- [route source](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/routes/admin/mail-hosts.php#L94)

**Delete mail host**

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | \- | yes |  |

```bash
curl -X DELETE "$PANEL_URL/api/admin/mail-hosts/$ID" \
  -H "Authorization: Bearer $FEATHERPANEL_API_KEY" \
  -H "Accept: application/json"
```

Plugin events: [`featherpanel:admin:mail_hosts:host:deleted`](https://featherpanel.com/docs/plugins/events/mail-hosts/#mail-host-deleted)
