# Create server

Creates a new server in your account. To be able to do this properly you will need 3 key values: `plan`, `region` and `credential`.

These values are available here: [Get server providers](https://developers.ploi.io/user/get-server-provider)

You will also need to have server providers added to your account to be able to retrieve these. Setup new server providers in your account here: [Server providers](https://ploi.io/profile/server-providers)

### Required scopes

`Create servers`

---

## Create a server

Creates a new server with the specified configuration.

### Required attributes

- **plan** (`string`): 
    The plan ID to install the server with.
  - **region** (`string`): 
    The region where to install the server with.
  - **credential** (`integer`): 
    The server provider from your account - [Get server providers](https://developers.ploi.io/user/get-server-provider)
  - **type** (`string`): 
    Type of the server to install, must be either: `server`, `load-balancer`, `database-server` or `redis-server`
  - **database_type** (`string`): 
    The type of database to install, must be one of: `none`, `mysql`, `mysql84`, `mysql9`,
    `mariadb`, `mariadb114`, `postgresql`, `postgresql14`, `postgresql15`, `postgresql16`,
    `postgresql17`, `postgresql18`.

    `mysql84` installs MySQL 8.4 LTS and `mysql9` installs MySQL 9.7 LTS. On Ubuntu 26.04 only
    `mysql84` is available, because that release ships MySQL 8.4 in its own archive.

    The bare `mysql`, `mariadb` and `postgresql` values follow the version we currently
    recommend for that engine, so what they install changes over time. Pick a versioned value
    if you need a specific release.

    Releases that have reached end of life are no longer accepted for new servers: MySQL 8.0,
    MariaDB 11.2 and PostgreSQL 13 and older. Existing servers running them keep working.
  - **webserver_type** (`string`): 
    The type of webserver to install, must be either: `nginx` or `nginx-docker`
  - **php_version** (`string`): 
    The PHP version installed, only applicable on the `server` type. Must be any of these values: `none`, `5.6`, `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, `8.5`
  ### Optional attributes

- **name** (`string`): 
    The server name, cannot contain any special characters and is alpha-numeric, if left empty a random name will be used.
  - **os_type** (`string`): 
    The OS version, defaults to `ubuntu-26-04-lts`. Available options: `ubuntu-24-04-lts`, `ubuntu-26-04-lts`, `debian-12`, `debian-13`
  - **description** (`string`): 
    Allows you to send in an additional description for your server as note.
  - **tags** (`array`): 
    Tags to group the server by, for example `["production", "client-a"]`. Maximum: 50 tags of 100 characters each, no duplicates.
  - **install_monitoring** (`boolean`): 
    Allows you to install Ploi monitoring as well, requires Pro plan or higher.
  - **ip_type** (`string`): 
    The IP version the server gets provisioned with, defaults to `ipv4`. Must be any of these values: `ipv4`, `ipv6`, `ipv4-ipv6` (IPv4 as main address, IPv6 added) or `ipv6-ipv4` (IPv6 as main address, IPv4 added). Supported on DigitalOcean, Hetzner, Vultr, UpCloud, Linode, AWS, Hostinger and Katapult. Other providers ignore this and always provision IPv4. Note that some providers hand out an IPv4 address even when you pick `ipv6`, and that IPv4 may come with additional costs.
  - **webhook_url** (`url`): 
    This URL gets triggered by Ploi when installation has completed, you can use this for your own system, this will only send 1 signal, there is no retry schedule.
  ```bash
curl -X POST "https://ploi.io/api/servers" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "name": "awesome-server",
    "plan": "1xCPU-1GB",
    "region": "nl-ams1",
    "credential": 1,
    "type": "server",
    "database_type": "mysql",
    "webserver_type": "nginx",
    "ip_type": "ipv4-ipv6"
  }'
```

```php
$ploi = new Ploi\Ploi($apiToken);

$ploi->servers()->create([
    'name' => 'awesome-server',
    'plan' => '1xCPU-1GB',
    'region' => 'nl-ams1',
    'credential' => 1,
    'type' => 'server',
    'database_type' => 'mysql',
    'webserver_type' => 'nginx',
    'ip_type' => 'ipv4-ipv6',
]);
```

```json
{
  "data": {
    "id": 2,
    "status": "created",
    "type": "server",
    "name": "awesome-server",
    "ip_address": "12.34.56.78",
    "php_version": "8.4",
    "mysql_version": "8.0",
    "sites_count": 0,
    "monitoring": false,
    "status_id": 0,
    "created_at": "2019-01-01 09:00:00"
  }
}
```

  ---

## Webhook URL data

When you provide a `webhook_url`, Ploi will send a POST request to that URL when the server installation has completed.

```json
{
  "message": "Server installation has completed",
  "server": {
"id": 1,
"name": "calm-breeze"
  }
}
```
