Servers

Create a Server

Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation.

Operation specific errors

StatusCodeDescription
412primary_ip_version_mismatchThe specified Primary IP has the wrong IP Version
422placement_errorAn error during the placement occurred
422primary_ip_assignedThe specified Primary IP is already assigned to a server
422primary_ip_datacenter_mismatchThe specified Primary IP is in a different location
post/servers

Request

  • Base URL: https://api.hetzner.cloud/v1
  • URL: https://api.hetzner.cloud/v1/servers
  • Auth: HTTP bearer

Request body

namestring required

Name of the Server to create (must be unique per Project and a valid hostname as per RFC 1123).

locationstring

ID or name of the Location to create the Server in.

server_typestring required

ID or name of the Server type this Server should be created with.

start_after_createboolean

This automatically triggers a Power on a Server-Server Action after the creation is finished and is returned in the next_actions response object.

imagestring required

ID or name of the Image the Server is created from.

placement_groupinteger

ID of the Placement Group the Server should be in.

ssh_keysstring[]

SSH key IDs (integer) or names (string) which should be injected into the Server at creation time.

volumesinteger[]

Volume IDs which should be attached to the Server at the creation time. Volumes must be in the same Location.

networksinteger[]

Network IDs which should be attached to the Server private network interface at the creation time.

user_datastring

Cloud-Init user data to use during Server creation. This field is limited to 32KiB.

labelsobject

User-defined labels (key/value pairs) for the Resource. For more information, see "Labels".

automountboolean

Auto-mount Volumes after attach.

Example request

{
  "name": "my-server",
  "location": "nbg1",
  "server_type": "cpx22",
  "start_after_create": true,
  "image": "ubuntu-24.04",
  "placement_group": 1,
  "ssh_keys": [
    "my-ssh-key"
  ],
  "volumes": [
    123
  ],
  "networks": [
    456
  ],
  "firewalls": [
    {
      "firewall": 38
    }
  ],
  "user_data": "#cloud-config\nruncmd:\n- [touch, /root/cloud-init-worked]\n",
  "labels": {
    "environment": "prod",
    "example.com/my": "label",
    "just-a-key": ""
  }
}

Response

Request succeeded.

root_passwordstring nullable required

Root password when no SSH keys have been specified.

Example response

{
  "server": {
    "id": 42,
    "name": "my-resource",
    "created": "2016-01-30T23:55:00Z",
    "public_net": {
      "ipv4": {
        "id": 42,
        "ip": "1.2.3.4",
        "dns_ptr": "server01.example.com"
      },
      "ipv6": {
        "id": 42,
        "ip": "2001:db8::/64",
        "dns_ptr": [
          {
            "ip": "2001:db8::1",
            "dns_ptr": "server.example.com"
          }
        ]
      },
      "floating_ips": [
        478
      ],
      "firewalls": [
        {
          "id": 42,
          "status": "applied"
        }
      ]
    },
    "private_net": [
      {
        "network": 4711,
        "ip": "10.0.0.2",
        "alias_ips": [
          "10.0.0.3",
          "10.0.0.4"
        ],
        "mac_address": "86:00:ff:2a:7d:e1"
      }
    ],
    "server_type": {
      "id": 1,
      "name": "cpx22",
      "description": "CPX22",
      "cores": 2,
      "memory": 4,
      "disk": 80,
      "prices": [
        {
          "location": "fsn1",
          "price_hourly": {
            "net": "1.0000",
            "gross": "1.1900"
          },
          "price_monthly": {
            "net": "1.0000",
            "gross": "1.1900"
          },
          "included_traffic": 654321,
          "price_per_tb_traffic": {
            "net": "1.0000",
            "gross": "1.1900"
          }
        }
      ],
      "cpu_type": "shared",
      "category": "Shared vCPU",
      "architecture": "x86",
      "deprecation": {
        "unavailable_after": "2023-09-01T00:00:00Z",
        "announced": "2023-06-01T00:00:00Z"
      },
      "locations": [
        {
          "id": 42,
          "name": "fsn1",
          "deprecation": {
            "unavailable_after": "2023-09-01T00:00:00Z",
            "announced": "2023-06-01T00:00:00Z"
          },
          "available": true
        }
      ]
    },
    "location": {
      "id": 42,
      "name": "fsn1",
      "description": "Falkenstein DC Park 1",
      "country": "DE",
      "city": "Falkenstein",
      "latitude": 50.47612,
      "longitude": 12.370071,
      "network_zone": "eu-central"
    },
    "image": {
      "id": 42,
      "type": "snapshot",
      "status": "available",
      "name": "ubuntu-24.04",
      "description": "Ubuntu 24.04 Standard 64 bit",
      "image_size": 2.3,
      "disk_size": 10,
      "created": "2016-01-30T23:55:00Z",
      "created_from": {
        "id": 1,
        "name": "Server"
      },
      "os_flavor": "ubuntu",
      "os_version": "24.04",
      "deprecated": "2018-02-28T00:00:00Z",
      "deprecation": {
        "unavailable_after": "2023-09-01T00:00:00Z",
        "announced": "2023-06-01T00:00:00Z"
      },
      "labels": {
        "environment": "prod",
        "example.com/my": "label",
        "just-a-key": ""
      },
      "architecture": "x86"
    },
    "iso": {
      "id": 42,
      "name": "FreeBSD-11.0-RELEASE-amd64-dvd1",
      "description": "FreeBSD 11.0 x64",
      "deprecation": {
        "unavailable_after": "2023-09-01T00:00:00Z",
        "announced": "2023-06-01T00:00:00Z"
      },
      "architecture": "x86"
    },
    "backup_window": "22-02",
    "outgoing_traffic": 123456,
    "ingoing_traffic": 123456,
    "included_traffic": 654321,
    "labels": {
      "environment": "prod",
      "example.com/my": "label",
      "just-a-key": ""
    },
    "primary_disk_size": 50,
    "placement_group": {
      "id": 42,
      "name": "my-resource",
      "labels": {
        "environment": "prod",
        "example.com/my": "label",
        "just-a-key": ""
      },
      "type": "spread",
      "created": "2016-01-30T23:55:00Z",
      "servers": [
        42
      ]
    }
  },
  "action": {
    "id": 42,
    "command": "start_resource",
    "started": "2016-01-30T23:55:00Z",
    "finished": "2016-01-30T23:55:00Z",
    "progress": 100,
    "resources": [
      {
        "id": 42,
        "type": "server"
      }
    ],
    "error": {
      "code": "action_failed",
      "message": "Action failed"
    }
  },
  "next_actions": [
    {
      "id": 42,
      "command": "start_resource",
      "started": "2016-01-30T23:55:00Z",
      "finished": "2016-01-30T23:55:00Z",
      "progress": 100,
      "resources": [
        {
          "id": 42,
          "type": "server"
        }
      ],
      "error": {
        "code": "action_failed",
        "message": "Action failed"
      }
    }
  ],
  "root_password": "YItygq1v3GYjjMomLaKc"
}

Changes

No recorded changes to this operation across all 1 revision of this API.