Volumes

Create a Volume

Creates a new Volume attached to a Server. If you want to create a Volume that is not attached to a Server, you need to provide the location key instead of server. This can be either the ID or the name of the Location this Volume will be created in. Note that a Volume can be attached to a Server only in the same Location as the Volume itself.

Specifying the Server during Volume creation will automatically attach the Volume to that Server after it has been initialized. In that case, the next_actions key in the response is an array which contains a single attach_volume action.

The minimum Volume size is 10GB and the maximum size is 10TB (10240GB).

A volume’s name can consist of alphanumeric characters, dashes, underscores, and dots, but has to start and end with an alphanumeric character. The total length is limited to 64 characters. Volume names must be unique per Project.

Operation specific errors

StatusCodeDescription
422no_space_left_in_locationThere is no volume space left in the given location
post/volumes

Request

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

Request body

sizeinteger required

Size of the Volume in GB.

namestring required

Name of the volume.

labelsobject

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

automountboolean

Auto-mount Volume after attach. server must be provided.

formatstring

Format Volume after creation. One of: xfs, ext4.

locationstring

Location to create the Volume in (can be omitted if Server is specified).

serverinteger

Server to which to attach the Volume once it's created (Volume will be created in the same Location as the server).

Example request

{
  "size": 42,
  "name": "databases-storage",
  "labels": {
    "environment": "prod",
    "example.com/my": "label",
    "just-a-key": ""
  },
  "format": "xfs",
  "location": "nbg1"
}

Response

Request succeeded.

Example response

{
  "volume": {
    "id": 42,
    "created": "2016-01-30T23:55:00Z",
    "name": "my-resource",
    "server": 12,
    "location": {
      "id": 42,
      "name": "fsn1",
      "description": "Falkenstein DC Park 1",
      "country": "DE",
      "city": "Falkenstein",
      "latitude": 50.47612,
      "longitude": 12.370071,
      "network_zone": "eu-central"
    },
    "size": 42,
    "linux_device": "/dev/disk/by-id/scsi-0HC_Volume_4711",
    "labels": {
      "environment": "prod",
      "example.com/my": "label",
      "just-a-key": ""
    },
    "status": "available",
    "format": "xfs"
  },
  "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"
      }
    }
  ]
}

Changes

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