Create Server with Application API

Create a new server.

Usage

<?php
    $pterodactyl->createServer(array $data);
?>

Parameters

Parameter Description Rules
data The data to create server

data

Parameter Description Rules
external_id External id sometimes|nullable|string|between:1,191|unique:servers
name Name required|string|min:1|max:255
user Server owner's user id required|integer|exists:users,id
description Description sometimes|string
egg Egg id required|exists:eggs,id
pack Pack id sometimes|nullable|numeric|min:0
docker_image Docker image sometimes|string|max:255
startup Startup command required|string
limits Limits required|array
limits.memory Memory limit required|numeric|min:0
limits.swap Swap limit required|numeric|min:-1
limits.disk Disk limit required|numeric|min:0
limits.io IO limit required|numeric|between:10,1000
limits.cpu CPU limit required|numeric|min:0
feature_limits Feature limits required|array
feature_limits.databases Database limit present|nullable|integer|min:0
feature_limits.allocations Allocation limit present|nullable|integer|min:0
environment Environment variables of the egg present|array
allocation Allocation ids sometimes|array
allocation.default Default allocation id sometimes|bail|unique:servers|exists:allocations,id
allocation.additional Additional allocation ids sometimes|array
allocation.additional.* Additional allocation id exists:allocations,id
deploy Deploy information sometimes|required|array
deploy.locations Deploy locations array
deploy.locations.* Deploy location integer|min:1
deploy.dedicated_ip Use dedicated ip or not required_with:deploy,boolean
deploy.port_range Port ranges array
deploy.port_range.* Port range string
start_on_completion Start server after finished installation or not sometimes|boolean
skip_scripts Skip egg scripts or not sometimes|boolean
oom_disabled Disable oom killer or not sometimes|boolean

Returns

Returns a server instance.

{
    "id": 14,
    "externalId": 11,
    "uuid": "76c59598-22df-4490-92bc-f6fb4a80e0c7",
    "identifier": "76c59598",
    "node": 1,
    "name": "server1",
    "description": "",
    "suspended": false,
    "pack": null,
    "createdAt": "2019-01-23T04:38:09+00:00",
    "updatedAt": "2019-08-05T09:36:13+00:00",
    "limits": {
        "memory": 128,
        "swap": 0,
        "disk": 256,
        "io": 500,
        "cpu": 0
    },
    "allocations": [{
        "id": 55,
        "nodeId": null,
        "ip": "123.123.123.123",
        "ipAlias": null,
        "port": 50053,
        "serverId": null,
        "createdAt": null,
        "updatedAt": null,
        "object": "allocation",
        "alias": "node-1.pterodactyl.panel",
        "assigned": true
    }],
    "object": "server",
    "featureLimits": {
        "databases": 0,
        "allocations": 0
    },
    "user": 1,
    "allocation": 55,
    "nest": 8,
    "egg": 20,
    "container": {
        "startup_command": ".\/Jcmp-Server",
        "image": "hcgcloud\/pterodactyl-jc2mp:latest",
        "installed": false,
        "environment": {
            "SERVER_AUTOUPDATE": "0",
            "STARTUP": ".\/Jcmp-Server",
            "P_SERVER_LOCATION": "test",
            "P_SERVER_UUID": "76c59598-22df-4490-92bc-f6fb4a80e0c7"
        }
    },
    "relationships": {
        "allocations": {
            "object": "list",
            "data": [{
                "object": "allocation",
                "attributes": {
                    "id": 55,
                    "ip": "123.123.123.123",
                    "alias": "node-1.pterodactyl.panel",
                    "port": 50053,
                    "assigned": true
                }
            }]
        }
    }
}

Example

<?php
    $nest_id = 1;
    $egg_id = 5;
    $location_id = 1;
    $egg = $pterodactyl->egg($nest_id, $egg_id); //get docker_image and startup directly from egg
    $server = $pterodactyl->createServer([
        "external_id" => '11',
        "name" => $name,
        "user" => 1,
        "egg" => $egg_id,
        "docker_image" => $egg->dockerImage,
        "skip_scripts" => false,
        "environment" => [
            "SERVER_AUTOUPDATE" => '1'
        ],
        "limits" => [
            "memory" => 256,
            "swap" => 0,
            "disk" => 1024,
            "io" => 500,
            "cpu" => 100
        ],
        "feature_limits" => [
            "databases" => 1,
            "allocations" => 2
        ],
        "startup" => $egg->startup,
        "description" => "",
        "deploy" => [
            "locations" => [$location_id],
            "dedicated_ip" => false,
            "port_range" => []
        ],
        "start_on_completion" => true
    ]);
    print_r($server);
?>