# Create a hosting account

`POST /api/v1/hosting-accounts`

Records an account on a server's control panel. Accounts are usually added by a sync (`POST /servers/{server}/hosting-accounts/sync`), which reads them from the panel.

## Body Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| server_id | integer | yes | The server the account is on. Example: `12`. |
| control_panel | string | yes | The hosting control panel a server runs: `none`, `plesk` or `cpanel`. The server's agent reports the panel it detects on every heartbeat. One of: `plesk`, `cpanel`. Example: `plesk`. |
| external_id | string | yes | The panel's own id for the account (Plesk's subscription number). Example: `42`. |
| domain_name | string | yes | The account's main domain. Example: `example.com`. |
| type | string | yes | The panel's kind of account: Plesk `subscription` or `domain`, cPanel `account` or `reseller`. Example: `subscription`. |
| document_root | string | no | The folder the site is served from. Nullable. Example: `/var/www/vhosts/example.com/httpdocs`. |
| mail_paths | string[] | no | The account's mail folders on the server. Nullable. Example: `["/var/qmail/mailnames/example.com/info"]`. |
| is_active | boolean | no | False for an account the panel no longer reports. Example: `true`. |
| synced_at | string · date-time | no | When the agent last reported the account. A sync sets it. Nullable. Example: `2026-11-20T01:30:04+00:00`. |

## Response

### 201

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| data | object | yes |  |
| data.id | integer | yes |  |
| data.server_id | integer | yes |  |
| data.control_panel | string | yes | One of: `none`, `plesk`, `cpanel`. |
| data.external_id | string | yes | The panel's own id for the account (Plesk's subscription number). |
| data.external_guid | string | yes | Plesk's permanent id for the subscription; null when the panel has none or the agent did not report one. Nullable. |
| data.domain_name | string | yes |  |
| data.type | string | yes | The panel's kind of account. Plesk: `subscription` or `domain`. cPanel: `account` or `reseller`. |
| data.type_label | string | yes |  |
| data.document_root | string | yes | The folder the site is served from. Nullable. |
| data.vhost_path | string | yes | The account's folder on the server. Nullable. |
| data.system_user | string | yes | The server user the account runs as. Nullable. |
| data.databases | object[] | yes | The account's databases as the agent last reported them. `type` is `mysql` or `postgresql`; `local` is true when the database runs on the server itself. Nullable. |
| data.databases.name | string | yes |  |
| data.databases.type | string | yes |  |
| data.databases.local | boolean | yes |  |
| data.mail_paths | string[] | yes | The account's mail folders on the server, one per mailbox. Nullable. |
| data.status | string | yes | The panel's state for the account: `active` or `suspended` (cPanel also reports `locked`). |
| data.is_active | boolean | yes | False for an account the panel no longer reports. |
| data.synced_at | string · date-time | yes | When the agent last reported this account. Nullable. |
| data.created_at | string · date-time | yes | Nullable. |
| data.updated_at | string · date-time | yes | Nullable. |

### 401

The request carries no valid token: the `Authorization: Bearer` header is missing, or its token is unknown, revoked or past its expiry date. Send a current personal access token.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | Always `Unauthenticated.`. |

### 403

The token may not do this. The `message` says why: `This token lacks the required ability.` (a `read` token), `Your role does not permit this action.` (its owner is not an Admin or Operator in the client), `This account is disabled.`, `This token is not bound to a client you belong to.`, or `Client suspended`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

### 422

The body or the query is invalid. `message` names the first problem and `errors` lists every problem by field.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | The first problem, and how many more there are. |
| errors | object | yes | Every problem, by field. |

### 429

More than 120 requests a minute for this user. Wait the seconds in `Retry-After`, then retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| message | string | yes | What went wrong. |

## Request example

```bash
curl -X POST 'https://app.clokeep.com/api/v1/hosting-accounts' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "server_id": 12,
    "control_panel": "plesk",
    "external_id": "42",
    "domain_name": "example.com",
    "type": "subscription",
    "document_root": "/var/www/vhosts/example.com/httpdocs",
    "mail_paths": [
      "/var/qmail/mailnames/example.com/info"
    ],
    "is_active": true,
    "synced_at": "2026-11-20T01:30:04+00:00"
  }'
```

## Response example (201)

```json
{
  "data": {
    "id": 17,
    "server_id": 12,
    "control_panel": "plesk",
    "external_id": "42",
    "external_guid": "6f1c2a9e-8b3d-4e57-a1c4-9d0e5b7f3a28",
    "domain_name": "example.com",
    "type": "subscription",
    "type_label": "Subscription",
    "document_root": "/var/www/vhosts/example.com/httpdocs",
    "vhost_path": "/var/www/vhosts/example.com",
    "system_user": "example",
    "databases": [
      {
        "name": "shop_wp",
        "type": "mysql",
        "local": true
      }
    ],
    "mail_paths": [
      "/var/qmail/mailnames/example.com/info"
    ],
    "status": "active",
    "is_active": true,
    "synced_at": "2026-11-20T01:30:04+00:00",
    "created_at": "2026-11-01T09:14:22+00:00",
    "updated_at": "2026-11-20T01:30:04+00:00"
  }
}
```

## Response example (401)

```json
{
  "message": "Unauthenticated."
}
```

## Response example (403)

```json
{
  "message": "This token lacks the required ability."
}
```

## Response example (422)

```json
{
  "message": "The server id field is required.",
  "errors": {
    "server_id": [
      "The server id field is required."
    ]
  }
}
```

## Response example (429)

```json
{
  "message": "Too Many Attempts."
}
```
