HomeComputeInstancesAPI/CLI
Changing the commercial type of an Instance
Update content

Changing the commercial type of an Instance with the API

Reviewed on 29 June 2023Published on 26 May 2021

It is possible to change the commercial type of an Instance by using the API.

To migrate an Instance via the API, the Instance ID, and a valid API key are required.

Security & Identity (IAM):

You may need certain IAM permissions to carry out some actions described on this page. This means:

  • you are the Owner of the Scaleway Organization in which the actions will be carried out, or
  • you are an IAM user of the Organization, with a policy granting you the necessary permission sets
Requirements:
  • You have an account and are logged into the Scaleway console
  • You have created an Instance
  • The Instance must be stopped for the migration to be possible
  • The Instance cannot be in a placement group
  1. Stop the Instance. Replace {zone} with the Availability Zone of your Instance. This value can be fr-par-1 for Instances located in Paris, for example. Replace {server_id} with the ID of your Instance.

    Request:

    curl -X PATCH -H "X-Auth-Token: $SCW_SECRET_KEY" -H "Content-Type: application/json" -d '{"action" : "poweroff"}' "https://api.scaleway.com/instance/v1/zones/{zone}/servers/{server_id}/action"

    Return:

    {
    "task":{
    "id":"cd1cf3da-6dee-4c96-bc86-f4fe848f36d4",
    "description":"server_poweroff",
    "status":"pending",
    "href_from":"/servers/85bde2188-1657-11ee-be56-0242ac120002/action",
    "href_result":"/servers/85bde2188-1657-11ee-be56-0242ac120002",
    "started_at":"2023-06-29T08:20:36.927830+00:00",
    "terminated_at":null
    }
    }
  2. Update the commercial_type of your Instance.

    Request:

    curl -X PATCH -H "X-Auth-Token: $SCW_SECRET_KEY" -H "Content-Type: application/json" -d '{"commercial_type" : "<NEW_INSTANCE_TYPE>"}' "https://api.scaleway.com/instance/v1/zones/{zone}/servers/{server_id}"
    Important:

    Local storage constraints must be respected. For example, downgrading a DEV1-L Instance with 80GB of local SSD storage to a DEV1-S Instance is not possible because the DEV1-S offer only supports a maximum of 20GB. However, if the DEV1-L Instance is only using block storage (b_ssd) without relying on local SSD storage, the downgrade can be performed without any issues.

    Return:

    {
    "server":{
    "id":"85bde2188-1657-11ee-be56-0242ac120002",
    "name":"scw-agitated-banach",
    "arch":"x86_64",
    "commercial_type":"PLAY2-MICRO", # New commercial type of the Instance
    "boot_type":"local",
    "organization":"a6a05c73-fa53-46a4-9ea1-e53b4f625527",
    "project":"a6a05c73-fa53-46a4-9ea1-e53b4f625527",
    "hostname":"scw-agitated-banach",
    "image":{
    "id":"ce453858-557c-4f1c-a7a9-70026e67d054",
    "name":"Ubuntu 22.04 Jammy Jellyfish",
    "organization":"4ce7eb1c-1659-11ee-be56-0242ac120002",
    "project":"4ce7eb1c-1659-11ee-be56-0242ac120002",
    "root_volume":{
    "id":"30e9c843-1cdb-4bd4-96f7-cac26051eeaf",
    "name":"Ubuntu 22.04 Jammy Jellyfish",
    "volume_type":"unified",
    "size":10000000000
    },
    [...]
  3. Power on the Instance.

    Request:

    curl -X POST -H "X-Auth-Token: $SCW_SECRET_KEY" -H "Content-Type: application/json" -d '{"action" : "poweron"}' "https://api.scaleway.com/instance/v1/{zone}/servers/{server_id}/action"

    Return:

    {
    "task":{
    "id":"aca94c37-86b0-4c9a-8df0-3bc13cd568ac",
    "description":"server_batch_poweron",
    "status":"pending",
    "href_from":"/servers/85bde2188-1657-11ee-be56-0242ac120002/action",
    "href_result":"/servers/85bde2188-1657-11ee-be56-0242ac120002",
    "started_at":"2023-06-29T08:27:49.409220+00:00",
    "terminated_at":null
    }
    }

    For more information on using the API, refer to the complete API documentation.