## POST /api/v2/shared-hosting/{accountId}/database-access-hosts

**Allow a database access host**

Allow one more host to connect to the account's MySQL databases over TCP. The list is account-wide. Every database user may then connect from that host with its own password. `host` is an IP address (`203.0.113.7`), an IP range with `%` as the wildcard (`203.0.113.%`), a hostname or `%` for every host. `localhost` is refused because the local socket is always allowed. Use `127.0.0.1` for an app on the hosting that connects over TCP. `%` leaves the databases protected by their passwords alone. Prefer one address. Adding a host that is already listed answers `201` again. The account must be active and on cPanel. Connect to `access.serverHostname` from [`GET /api/v2/shared-hosting/{accountId}/account-details`](/endpoints/webhosting-services/get-v2-shared-hosting-accountid-account-details/), not to your domain. The domain may point somewhere else.

### Related Endpoints

- `GET /api/v2/shared-hosting/{accountId}/database-access-hosts`: List database access hosts
- `DELETE /api/v2/shared-hosting/{accountId}/database-access-hosts/{host}`: Remove a database access host
- `GET /api/v2/shared-hosting/{accountId}`: Get a web hosting account

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scopes: `write:hosting`, `console:services`
- `Content-Type`: application/json

### Parameters

- `accountId` (path, string, required): The web hosting account ID (`acct_…`). Example: `acct_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `host` (string, required): An IP address, an IP range with `%` as the wildcard, a hostname or `%` for every host. Case-insensitive. Never `localhost`. Example: `203.0.113.7`

### Request Examples

#### Allow an office IP address

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/database-access-hosts" \
  -H "Authorization: Bearer $HOSTUP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "host": "203.0.113.7"
  }'
```

```json
{
  "host": "203.0.113.7"
}
```

#### Allow an app on the hosting that connects over TCP

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/database-access-hosts" \
  -H "Authorization: Bearer $HOSTUP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "host": "127.0.0.1"
  }'
```

```json
{
  "host": "127.0.0.1"
}
```

### Response Schema

- `host` (string, required): The host as stored: trimmed and in lower case. Example: `203.0.113.7`
- `note` (string, required, nullable): Always `null` here. Notes are set in the control panel. Example: `null`

### Responses

#### 201 - Host allowed.
```json
{
  "host": "203.0.113.7",
  "note": null
}
```

#### 400 - The host is missing, malformed or `localhost`.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "host must be an IP address (203.0.113.7), an IP range with % as the wildcard (203.0.113.%), a hostname, or % for every host.",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/database-access-hosts",
  "code": "invalid_request",
  "errors": [
    {
      "pointer": "/body/host",
      "detail": "host must be an IP address (203.0.113.7), an IP range with % as the wildcard (203.0.113.%), a hostname, or % for every host.",
      "code": "invalid_request"
    }
  ]
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - `forbidden`. With `requiredScopes` in the body, the key lacks a scope. The key needs all the scopes in that list, although `detail` asks for one of them. Without `requiredScopes`, the hosting account is not active. Check `serviceStatus` on [`GET /api/v2/shared-hosting/{accountId}`](/endpoints/webhosting-services/get-v2-shared-hosting-accountid/).
```json
{
  "type": "https://developer.hostup.se/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "This endpoint requires an API key with one of these scopes: `write:hosting` or `console:services`. Broader service keys also work. Update your key's permissions in the dashboard.",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/database-access-hosts",
  "code": "forbidden",
  "requiredScopes": [
    "write:hosting",
    "console:services"
  ]
}
```

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 409 - `account_not_eligible_cpanel`: the account is on Hostup's previous hosting platform. Support moves it to cPanel at no charge.
```json
{
  "type": "https://developer.hostup.se/errors/account_not_eligible_cpanel",
  "title": "Control panel action unavailable",
  "status": 409,
  "detail": "Database access hosts are only available for cPanel servers. This account uses HostUp's previous hosting platform. Contact support and we will migrate the existing account to cPanel at no extra charge; no new hosting plan is needed.",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/database-access-hosts",
  "code": "account_not_eligible_cpanel"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Rate limit exceeded. Please try again later.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 502 - Upstream failure. A dependent provider request failed; the Problem Details `code` is `upstream_failed`. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/upstream_failed",
  "title": "Upstream failure",
  "status": 502,
  "detail": "An upstream provider request failed. Retry later or contact support if the issue persists.",
  "code": "upstream_failed",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```
