Starting a Server with Additional Volume via API

How to start a server with additional volume from the API

This page shows you some basics to interact with the Compute API.

Requirements

API tokens are unique identifiers associated with your Scaleway account and consist of an Access Key (--o or -organisation in the Scaleway CLI) and a Secret Key (--t or -token in the Scaleway CLI). The Secret key is required to authenticate against our API and will only be displayed when you create the token. Make sure to take a note of it and to keep it secret.

There are five steps to provision and start a server with additional volume from the API.

IMPORTANT:

The API endpoint depends on the location where you want to perform an operation. Currently the following endpoints are available:

  • PAR-1 (Paris, France): https://api.scaleway.com/instance/v1/zones/fr-par-1/
  • AMS-1 (Amsterdam, Netherlands): https://api.scaleway.com/instance/v1/zones/nl-ams-1/

In this section, we will:

  1. Retrieving the list of images available
  2. Creating a new server
  3. Creating a new volume
  4. Attaching the volume to the server
  5. Starting a server

Retrieving the list of available images

The following request returns the list of available images. In this example we only have one image which is located in the nl-ams-1 zone, named Ubuntu Bionic Beaver and has id 9444d178-2285-4842-ac35-5e86eda8da91.

Request

curl -H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" https://api.scaleway.com/instance/v1/zones/nl-ams-1/images

Response

{
  "images": [
    {
        "arch": "x86_64",
        "creation_date": "2019-03-05T13:40:50.038070+00:00",
        "default_bootscript": {
            "architecture": "x86_64",
            "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
            "default": false,
            "dtb": "",
            "id": "54ee2857-8ffb-4323-abba-964f55fea4a2",
            "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz",
            "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93",
            "organization": "11111111-1111-4111-8111-111111111111",
            "public": true,
            "title": "x86_64 mainline 4.9.93 rev1"
        },
        "extra_volumes": {},
        "from_server": null,
-->     "id": "9444d178-2285-4842-ac35-5e86eda8da91",
        "modification_date": "2019-03-05T13:40:50.038070+00:00",
--->    "name": "Ubuntu Bionic Beaver",
        "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db",
        "public": true,
        "root_volume": {
            "id": "0d7ad03a-e551-4317-b6f7-328abe6df3d7",
            "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13",
            "size": 10000000000,
            "volume_type": "l_ssd"
        },
        "state": "available"
    }
  ]
}

Creating a new server

To create a server, you have to fill out the following input:

  • The commercial type (for example: DEV1-S, GP1-S, …)
  • A server name
  • An Organization ID
  • An Image ID
  • Tags (Optional)

Request

curl https://api.scaleway.com/instance/v1/zones/nl-ams-1/servers \
-H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" \
-H "Content-Type: application/json" \
-d '{ \
"name": "<YOUR_SERVER_NAME>",
"image": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
"commercial_type": "C2M",
"tags": ["temporary", "test"],
"organization": "<YOUR_ORGANIZATION_ID>"
}'

Response

{
    "server": {
        "allowed_actions": [
            "poweron",
            "backup"
        ],
        "arch": "x86_64",
        "boot_type": "bootscript",
        "bootscript": {
            "architecture": "x86_64",
            "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
            "default": false,
            "dtb": "",
            "id": "54ee2857-8ffb-4323-abba-964f55fea4a2",
            "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz",
            "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93",
            "organization": "11111111-1111-4111-8111-111111111111",
            "public": true,
            "title": "x86_64 mainline 4.9.93 rev1"
        },
        "commercial_type": "C2M",
        "compute_cluster": null,
        "creation_date": "2019-05-14T12:35:39.661633+00:00",
        "dynamic_ip_required": true,
        "enable_ipv6": false,
        "extra_networks": [],
        "hostname": "<YOUR_SERVER_NAME>",
        "id": "7481f336-ea80-4890-8600-e0ab9d0a6bdf",
        "image": {
            "arch": "x86_64",
            "creation_date": "2019-03-05T13:40:50.038070+00:00",
            "default_bootscript": {
                "architecture": "x86_64",
                "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
                "default": false,
                "dtb": "",
                "id": "54ee2857-8ffb-4323-abba-964f55fea4a2",
                "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz",
                "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93",
                "organization": "11111111-1111-4111-8111-111111111111",
                "public": true,
                "title": "x86_64 mainline 4.9.93 rev1"
            },
            "extra_volumes": {},
            "from_server": null,
            "id": "9444d178-2285-4842-ac35-5e86eda8da91",
            "modification_date": "2019-03-05T13:40:50.038070+00:00",
            "name": "Ubuntu Bionic Beaver",
            "organization": "11111111-1111-4111-8111-111111111111",
            "public": true,
            "root_volume": {
                "id": "0d7ad03a-e551-4317-b6f7-328abe6df3d7",
                "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13",
                "size": 10000000000,
                "volume_type": "l_ssd"
            },
            "state": "available"
        },
        "ipv6": null,
        "location": null,
        "maintenances": [],
        "modification_date": "2019-05-14T12:35:40.355521+00:00",
        "name": "<YOUR_SERVER_NAME>",
        "organization": "<YOUR_ORGANIZATION_ID>",
        "private_ip": null,
        "protected": false,
        "public_ip": null,
        "security_group": {
            "id": "13e12ca4-1dfc-4460-a141-2bf63045a1c5",
            "name": "Default security group"
        },
        "state": "stopped",
        "state_detail": "",
        "tags": [
            "temporary",
            "test"
        ],
        "volumes": {
            "0": {
                "creation_date": "2019-05-14T12:35:39.661633+00:00",
                "export_uri": null,
                "id": "d1bb9e77-ddac-460d-8b43-d390c9be977d",
                "modification_date": "2019-05-14T12:35:40.162625+00:00",
                "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13",
                "organization": "<YOUR_ORGANIZATION_ID>",
                "server": {
                    "id": "7481f336-ea80-4890-8600-e0ab9d0a6bdf",
                    "name": "<YOUR_SERVER_NAME>"
                },
                "size": 50000000000,
                "state": "available",
                "volume_type": "l_ssd"
            }
        }
    }
}

The response above returns an HTTP 201 code with the server details.

Creating a new volume

To create a volume, you have to fill out the following input:

  • A volume name
  • An Organization ID
  • A size in GB
  • The volume type - Local storage

You can create and attach additional volumes to an existing server. The server must be stopped.

Let’s create a new volume of type SSD with a size of 50GB.

Request

curl https://api.scaleway.com/instance/v1/zones/nl-ams-1/volumes \
-H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_VOLUME_NAME>",
"organization": "<YOUR_ORGANIZATION_ID>",
"size": 50000000000,
"volume_type": "l_ssd"
}'

Response

{
    "volume": {
        "creation_date": "2019-05-14T12:40:29.895653+00:00",
        "export_uri": null,
        "id": "daa1a027-4c12-4175-aea7-5e59a83e83c3",
        "modification_date": "2019-05-14T12:40:29.895653+00:00",
        "name": "<YOUR_VOLUME_NAME>",
        "organization": "<YOUR_ORGANIZATION_ID",
        "server": null,
        "size": 50000000000,
        "state": "available",
        "volume_type": "l_ssd"
    }
}

The response above returns an HTTP 201 code with the volume details.

Attaching the volume to the server

To attach an additional volume to an existing server, you have to perform a PUT method requests on the server.

Request

curl https://api.scaleway.com/instance/v1/zones/nl-ams-1/servers/<YOUR_SERVER_ID> \
-H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" \
-H "Content-Type: application/json" \
-X PATCH
-d '{
"dynamic_public_ip": false,
"id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
"image": {
"id": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
"name": "Ubuntu Trusty (14.04) on SSD 2014.06.04"
},
"name": "<YOUR_SERVER_NAME>",
"organization": "<YOUR_ORGANIZATION_ID>",
"private_ip": null,
"public_ip": null,
"state": "stopped",
"state_detail": "",
"tags": [
"temporary",
"test"
],
"volumes": {
---> "0": {"id": "1a96f139-95f8-4680-aeeb-0a58229d18d5", "name": "volume 1"},
---> "1": {"id": "65e7d766-103b-4fb1-819a-fb95e3a15348", "name": "volume 2"}
}
}'

Response

{
  "server": {
    "dynamic_public_ip": false,
    "id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
    "image": {
      "id": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
      "name": "Ubuntu Trusty (14.04) on SSD 2014.06.04"
    },
    "name": "<YOUR_SERVER_NAME>",
    "organization": "<YOUR_ORGANIZATION_ID>",
    "private_ip": null,
    "public_ip": null,
    "state": "stopped",
    "state_detail": "",
    "tags": [
      "temporary",
      "test"
    ],
    "volumes": {
      "0": {
        "export_uri": null,
        "id": "1a96f139-95f8-4680-aeeb-0a58229d18d5",
        "name": "Ubuntu Trusty RootFS snapshot",
        "organization": "<YOUR_ORGANIZATION_ID>",
        "server": {
          "id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
          "name": "<YOUR_SERVER_NAME>"
        },
        "size": 20000000000,
        "volume_type": "l_ssd"
      },
      "1": {
        "export_uri": null,
        "id": "65e7d766-103b-4fb1-819a-fb95e3a15348",
        "name": "<YOUR_VOLUME_NAME>",
        "organization": "<YOUR_ORGANIZATION_ID>",
        "server": {
          "id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
          "name": "<YOUR_SERVER_NAME>"
        },
        "size": 10000000000,
        "volume_type": "l_ssd"
      }
    }
  }
}

Starting a server

To start your server, execute the following request where <YOUR_SERVER_ID> is your server id.

Request

curl -H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" https://api.scaleway.com/instance/v1/zones/nl-ams-1/servers/<YOUR_SERVER_ID>/action \
 -d '{"action":"poweron"}' -H "Content-Type: application/json"

Response

{
    "task": {
        "description": "server_batch_poweron",
        "href_from": "/servers/7481f336-ea80-4890-8600-e0ab9d0a6bdf/action",
        "href_result": "/servers/7481f336-ea80-4890-8600-e0ab9d0a6bdf",
        "id": "a6265967-b38b-49d1-b266-8afb5b36633f",
        "progress": 0,
        "started_at": "2019-05-14T13:00:00.317859+00:00",
        "status": "pending",
        "terminated_at": null
    }
}

To go even further you can access the API Documentation.

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.