# Client — Databases

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

*List databases (client)*

Return all databases owned by the authenticated client account.

**Responses:**

| Status | Schema | Description |
|--------|--------|-------------|
| `200` | `ApiSuccess_list_dict_str__Any___` | Successful Response |

**Response example (200):**

```json
{
  "data": [
    {}
  ],
  "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/client/databases
```

---

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

*Create database (client)*

Create a database for the authenticated client account. Plan limit enforced.

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `charset` | string | no | default `utf8mb4` |
| `collation` | string | no | default `utf8mb4_unicode_ci` |
| `name` | string | yes | minLength=1; maxLength=47; pattern=`^[a-z][a-z0-9_]{0,46}$` |

**Request body example:**

```json
{
  "charset": "utf8mb4",
  "collation": "utf8mb4_unicode_ci",
  "name": "string"
}
```

**Responses:**

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

**Response example (200):**

```json
{
  "data": {},
  "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/client/databases
```

---

<a id="get-api-v1-client-databases-phpmyadmin-url"></a>
#### `GET /api/v1/client/databases/phpmyadmin-url`

*Get phpMyAdmin SSO URL (client)*

Mint an ephemeral phpMyAdmin SSO token bound to a tenant-scoped MariaDB user (5-minute TTL, scoped to the client's own databases).

**Query parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `db` | string | no | — |

**Responses:**

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

**Response example (200):**

```json
{
  "data": {},
  "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/client/databases/phpmyadmin-url
```

---

<a id="delete-api-v1-client-databases-db-name"></a>
#### `DELETE /api/v1/client/databases/{db_name}`

*Delete database (client)*

Delete a database owned by the authenticated client account.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `db_name` | 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/client/databases/{db_name}
```

---

<a id="get-api-v1-client-databases-db-name-remote-hosts"></a>
#### `GET /api/v1/client/databases/{db_name}/remote-hosts`

*List database remote hosts (client)*

Return all allowed remote hosts for a database owned by the authenticated client account.

**Path parameters:**

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

**Responses:**

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

**Response example (200):**

```json
{
  "data": [
    {}
  ],
  "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/client/databases/{db_name}/remote-hosts
```

---

<a id="post-api-v1-client-databases-db-name-remote-hosts"></a>
#### `POST /api/v1/client/databases/{db_name}/remote-hosts`

*Add database remote host (client)*

Add an allowed remote host to a database owned by the authenticated client account.

**Path parameters:**

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

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `host` | string | yes | — |
| `note` | string | no | default `` |

**Request body example:**

```json
{
  "host": "string",
  "note": ""
}
```

**Responses:**

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

**Response example (200):**

```json
{
  "data": {},
  "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/client/databases/{db_name}/remote-hosts
```

---

<a id="delete-api-v1-client-databases-db-name-remote-hosts-host"></a>
#### `DELETE /api/v1/client/databases/{db_name}/remote-hosts/{host}`

*Remove database remote host (client)*

Remove an allowed remote host from a database owned by the authenticated client account.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `db_name` | string | yes | — |
| `host` | 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/client/databases/{db_name}/remote-hosts/{host}
```

---

<a id="post-api-v1-client-databases-db-name-users"></a>
#### `POST /api/v1/client/databases/{db_name}/users`

*Create database user (client)*

Create a MariaDB user with privileges on the given database, owned by the authenticated client account.

**Path parameters:**

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

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `host` | string | no | default `localhost` |
| `password` | string | yes | — |
| `privileges` | array<string> | no | — |
| `username` | string | yes | minLength=1; maxLength=15; pattern=`^[a-z][a-z0-9_]{0,14}$` |

**Request body example:**

```json
{
  "host": "localhost",
  "password": "REPLACE_ME",
  "privileges": [
    "string"
  ],
  "username": "alice"
}
```

**Responses:**

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

**Response example (200):**

```json
{
  "data": {},
  "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/client/databases/{db_name}/users
```

---

<a id="delete-api-v1-client-databases-db-name-users-db-user"></a>
#### `DELETE /api/v1/client/databases/{db_name}/users/{db_user}`

*Delete database user (client)*

Delete a database user owned by the authenticated client account.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `db_name` | string | yes | — |
| `db_user` | 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/client/databases/{db_name}/users/{db_user}
```

---

<a id="put-api-v1-client-databases-db-name-users-db-user"></a>
#### `PUT /api/v1/client/databases/{db_name}/users/{db_user}`

*Update database user (client)*

Update a database user (e.g. change password) owned by the authenticated client account.

**Path parameters:**

| Name | Type | Required | Notes |
|------|------|----------|-------|
| `db_name` | string | yes | — |
| `db_user` | string | yes | — |

**Body fields:**

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `password` | string | no | — |

**Request body example:**

```json
{
  "password": "string"
}
```

**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 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/client/databases/{db_name}/users/{db_user}
```

---
