Updated on 2025-08-20 GMT+08:00

Creating an ECS

Function

This API is used to create one or more ECSs.

The V1.1 API supports all functions provided by the V1 API. For details, see Creating an ECS (Pay-per-Use). Additionally, the V1.1 API supports the creation of yearly/monthly ECSs.

This API is an asynchronous API. After the creation request is successfully delivered, a job ID is returned. This does not mean that the creation is complete. You need to call the API by referring to Querying Job Execution Status to query the job status. The SUCCESS status indicates that the creation is successful.

This API allows you to set the X-Client-Token request header in the HTTP request header to ensure the request idempotence. For details, see Idempotent Requests.

Huawei Cloud no longer provides Windows images. This API cannot be used to create ECSs using Windows images, including public Windows images, private Windows images, shared Windows images, and KooGallery Windows images.

Logging in to an ECS can be authenticated using either a key pair or password. For security purposes, you are advised to use key pair authentication.
  • Key pair

    A key pair is used for ECS login authentication.

    Method of calling APIs: Use the key_name field to specify the key file used for logging in to the ECS. For details, see Table 2.

  • Password

    If you choose the initial password for authentication in an ECS, you can log in to the ECS using the username and its initial password. The initial password of user root is used for authentication in Linux, while that of user Administrator is used for authentication in Windows.

    Method of calling APIs: Use the adminPass field to specify the initial login password of the administrator account. For details about how to use the adminPass field, see Table 2. If an encrypted password is required for logging in to a Linux ECS that is created using an image with Cloud-Init installed, you can use the user_data field to inject the password. For details, see Table 2.

    If the user_data field is specified for a Linux ECS that is created using an image with Cloud-Init installed, the adminPass field becomes invalid.

  • Image password

    If you use a Linux private image to create an ECS, you can use the image password for login authentication.

    Method of calling APIs: If the image password is used, the key_name and adminPass fields do not need to be specified.

Constraints

  • When creating a yearly/monthly ECS, you can pay for it automatically or manually.
    • If isAutoPay in the request is set to true, automatic payments are used. The system automatically pays for order using the supported payment methods.
      • Discounts and cash coupons can be used in the following sequence:

        Discounts (only one at a time) > Cash coupons (only one at a time) > Account balance (first cash balance and then available credit) or monthly settlement

      • If the preceding payment methods cannot be used to accomplish the payment, the system automatically generates an unpaid order. You need to manually select a payment method on the console and pay for the order.

      For details, see Automatic Payments.

    • If isAutoPay in the request is set to false, manual payments are used. The system generates an unpaid order. You need to manually select a payment method on the console and pay for the order.
  • When you create a pay-per-use ECS, the system automatically uses available cash coupons.
  • If you want to unsubscribe from yearly/monthly resources, see Unsubscribing from Yearly/Monthly Resources.

URI

  • URI format

    POST /v1.1/{project_id}/cloudservers

  • Parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID.

    For details about how to obtain the ID, see Obtaining a Project ID.

Request

Table 1 Request parameters

Parameter

Mandatory

Type

Description

server

Yes

Object

Definition

Specifies the ECS information. For details, see Table 2.

Constraints

N/A

Range

N/A

Default Value

N/A

dry_run

No

Boolean

Definition

Specifies whether to check the request. If this parameter is set to true, no instance is created.

Constraints

N/A

Range

  • true: Check the request. Check items include the mandatory parameters and request format.
    • If the check fails, the system returns an error.
    • If the check is successful, the system returns status code 202.
  • false: Do not check the request.

Default Value

false

Table 2 Parameters for creating an ECS

Parameter

Mandatory

Type

Description

imageRef

Yes

String

Definition

Specifies the ID of the system image used for creating ECSs. The ID is in the format of a Universally Unique Identifier (UUID).

You can obtain the image ID from the console or by following the instructions provided in "Querying Images" in Image Management Service API Reference.

Constraints

N/A

Range

N/A

Default Value

N/A

flavorRef

Yes

String

Definition

Specifies the flavor ID of the ECS to be created.

For details about the flavors that have been released, see x86 ECS Specifications in Elastic Cloud Server Service Overview.

Constraints

N/A

Range

N/A

Default Value

N/A

name

Yes

String

Definition

Specifies the ECS name.

For details, see How Can I Set Sequential ECS Names When Creating Multiple ECSs?

Constraints

  • If more than one ECS is to be created (the count value is greater than 1), the system automatically adds a hyphen followed by a four-digit incremental number, such as -0000, to the end of each ECS name. If you specify a number, the name of the first new ECS will start from the specified number. In this case, the ECS name contains 1 to 59 characters.
  • ECS hostnames comply with RFC 952 and RFC 1123 naming rules. It is recommended that you configure hostnames using digits (0 to 9), lowercase letters (a to z), and hyphens (-). Underscores (_) are converted into hyphens (-) by default.

Range

The parameter value consists of 1 to 128 characters, including letters, digits, underscores (_), hyphens (-), and periods (.).

Default Value

N/A

user_data

No

String

Definition

Specifies the user data to be injected to the ECS during the creation. Text and text files can be injected.

Examples

Before base64 encoding:

  • Linux
    #!/bin/bash
    echo user_test > /home/user.txt
  • Windows
    rem cmd
    echo 111 > c:\aaa.txt

After base64 encoding:

  • Linux
    IyEvYmluL2Jhc2gKZWNobyB1c2VyX3Rlc3QgPiAvaG9tZS91c2VyLnR4dA==
  • Windows
    cmVtIGNtZAplY2hvIDExMSA+IGM6XGFhYS50eHQ=

For more information about the user data to be injected, see Injecting User Data in Elastic Cloud Server User Guide.

Constraints

  • The content of user_data must be encoded with base64.
  • The maximum size of the content to be injected (before encoding) is 32 KB.

Range

N/A

Default Value

N/A

adminPass

No

String

Definition

Specifies the initial login password of the administrator account for logging in to an ECS using password authentication. The Linux administrator is root, and the Windows administrator is Administrator.

Constraints
  • Cannot contain the username or the username in reverse.
  • The Windows ECS password cannot contain the username, the username in reverse, or more than two consecutive characters in the username.

Range

  • The password must contain 8 to 26 characters.
  • Contains at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (!@$%^-_=+[{}]:,./?).

Default Value

N/A

key_name

No

String

Definition

Specifies the name of the SSH key used for logging in to the ECS.

Keys can be created using the key creation API. For details, see Creating and Importing an SSH Key Pair. Existing keys can be obtained using the SSH key query API. For details, see Querying the SSH Key Pair List.

Constraints

N/A

Range

N/A

Default Value

N/A

vpcid

Yes

String

Definition

Specifies the ID of the VPC to which the ECS belongs. The value is in the format of the UUID.

You can obtain the VPC ID from the management console or by following the instructions provided in Querying VPCs in Virtual Private Cloud API Reference.

Constraints

N/A

Range

N/A

Default Value

N/A

nics

Yes

Array of objects

Definition

Specifies the NIC information of the ECS. For details, see Table 3.

Constraints

  • The network of the primary NIC must belong to the VPC specified by vpcid. When you create NICs, the first NIC specified is the primary NIC.
  • A maximum of 12 NICs can be attached to an ECS by default.
  • The maximum number of NICs varies depending on ECS specifications. For details, see ECS Specifications.

Range

N/A

Default Value

N/A

publicip

No

Object

Definition

Specifies the EIP bound to the ECS, which can be configured in one of the following ways:

  • Do not use: In such a case, this parameter is unavailable.
  • Automatically assign an EIP. You need to specify the EIP.
  • Use existing one. You need to specify an existing EIP.

For details, see publicip Field Description.

Constraints

N/A

Range

N/A

Default Value

N/A

count

No

Integer

Definition

Specifies the number of ECSs to be created.

Constraints

  • If this parameter is not specified, the default value is 1.
  • If chargingMode in the extendparam parameter is set to postPaid, the ECS is billed in pay-per-use payments, and a tenant can create a maximum of 500 ECSs.
  • If chargingMode in the extendparam parameter is set to prePaid, the ECS is billed on a yearly/monthly basis, and a tenant can create 1 to 100 ECSs. A maximum of 400 resources can be purchased at a time. For example, a purchased ECS includes mandatory resources, such as one cloud server and one system disk, and other optional resources, such as data disks, EIP, and bandwidth. All of these are included in 400 resources. The system will report an error when the number of resources exceeds 400.

Range

N/A

Default Value

N/A

isAutoRename

No

Boolean

Definition

Specifies whether the same name is allowed during batch creation.

Constraints

This parameter is valid when the count value is greater than 1.

Range

  • true: indicates that the same name is allowed.
  • false: indicates that suffixes are automatically added to each name.

Default Value

false

root_volume

Yes

Object

Definition

Specifies ECS system disk configurations.

The system disk and data disk created during the creation of a yearly/monthly ECS are also in yearly/monthly payments, and the subscription duration of the disks is the same as that of the ECS.

For details, see Table 5.

Constraints

N/A

Range

N/A

Default Value

N/A

data_volumes

No

Array of objects

Definition

Specifies ECS data disk configurations. Each data structure represents a data disk to be created.

Constraints

An ECS can be attached with a maximum of 59 data disks (certain flavors support only 23 data disks).

For details, see Table 6.

Range

N/A

Default Value

N/A

security_groups

No

Array of objects

Definition

Specifies the security groups of the ECS.

Constraints

If this parameter is left blank, the default security group is associated with the ECS.

For details, see security_groups Field Description.

Range

N/A

Default Value

N/A

availability_zone

No

String

Definition

Specifies the name of the AZ where the ECS is located.

You can obtain the value of this parameter by referring to Querying AZs (Discarded) or Regions and Endpoints.

Constraints

  • If this parameter is not specified, the system automatically selects an AZ.
  • If the ECS is created on a DeH, the ECS must be in the same AZ as the DeH.

Range

N/A

Default Value

N/A

batch_create_in_multi_az

No

Boolean

Definition

Specifies whether ECSs can be randomly deployed in multiple AZs.

Constraints

This parameter is valid when availability_zone is left blank.

Range

  • true: The batch-created ECSs are deployed in multiple AZs.
  • false: The batch-created ECSs are deployed in a single AZ.

Default Value

false

extendparam

No

Object

Definition

Provides the supplementary information about the ECS to be created.

For details, see Table 9.

Constraints

N/A

Range

N/A

Default Value

N/A

metadata

No

Map<String,String>

Definition

Specifies the metadata of the ECS to be created.

You can use metadata to customize key-value pairs. For details about reserved key-value pairs, see Table 11.

Constraints

If the metadata contains sensitive data, take appropriate measures to protect the sensitive data, for example, controlling access permissions and encrypting the data.

Range

  • A maximum of 10 key-value pairs can be injected.
  • A metadata key consists of 1 to 255 characters and can only contain uppercase letters, lowercase letters, spaces, digits, hyphens (-), underscores (_), colons (:), and periods (.).
  • A metadata value consists of a maximum of 255 characters.

Default Value

N/A

os:scheduler_hints

No

Object

Definition

Specifies ECS scheduling information, for example, setting an ECS group.

For details, see Table 12.

Constraints

N/A

Range

N/A

Default Value

N/A

tags

No

Array of strings

Definition

Specifies ECS tags. A tag is in the format of "key.value".

Constraints

  • Each ECS supports a maximum of 10 tags during the creation.
  • The server_tags field provides the same functions as tags, but supports more keys and values, so the server_tags field is recommended.

Range

  • A tag key contains a maximum of 36 characters, and a tag value contains a maximum of 43 characters.
  • A tag key can contain only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-).
  • A tag value can contain only uppercase letters, lowercase letters, digits, underscores (_), hyphens (-), and periods (.).

Default Value

N/A

server_tags

No

Array of objects

Definition

Specifies ECS tags. For details, see server_tags Field Description.

Constraints

  • Each ECS supports a maximum of 10 tags during the creation.
  • The server_tags field provides the same functions as tags, but supports more keys and values, so the server_tags field is recommended.

Range

N/A

Default Value

N/A

description

No

String

Definition

Specifies the ECS description.

Constraints

Angle brackets (<>) are not allowed.

Range

A maximum of 85 characters are allowed.

Default Value

Empty string

auto_terminate_time

No

String

Definition

Specifies the scheduled deletion time.

Constraints

  • Scheduled deletion is available only for pay-per-use ECSs.
  • If the value of second (ss) is not 00, the system automatically sets to the current value of minute (mm).
  • The scheduled deletion time must be at least half an hour later than the current time.
  • The scheduled deletion time cannot be three years later than the current time.

Range

The value is in the format of "yyyy-MM-ddTHH:mm:ssZ" in UTC+0 and complies with ISO8601.

Example: 2020-09-25T12:05:00Z

Default Value

N/A

cpu_options

No

Object

Definition

Specifies the CPU options.

For details, see Table 7.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 nics field description

Parameter

Mandatory

Type

Description

port_id

No

String

Definition

Specifies the NIC ID in UUID format. If this parameter is not left blank, the specified NIC is attached.

You can obtain the NIC ID using the VPC API for querying ports.

Constraints
  • The NIC must be in DOWN state.
  • If the primary NIC is a network interface, the VPC ID of the NIC must be the same as the obtained VPC ID.
  • Either port_id or subnet_id must be specified.
  • If both port_id and subnet_id are specified, port_id is used preferentially.
  • If port_id is specified, a network interface is used. In such a case, security_groups and ip_address do not take effect.

Range

N/A

Default Value

N/A

subnet_id

No

String

Definition

Specifies the subnet of the ECS.

Constraints

The value must be the ID of the subnet created in the VPC specified by vpcid and in the format of the UUID.

You can obtain the parameter value by calling a VPC API for Querying Subnets.

Range

N/A

Default Value

N/A

ip_address

No

String

Definition

Specifies the IP address of the NIC used by the ECS. The value is an IPv4 address.

Constraints
  • If this parameter is left blank or set to "", an unused IP address in the subnet is automatically assigned as the IP address of the NIC.
  • If this parameter is specified, its value must be an unused IP address in the network segment of the subnet.

Range

N/A

Default Value

N/A

ipv6_enable

No

Boolean

Definition

Specifies whether to support IPv6 addresses.

Constraints

N/A

Range

  • true: The NIC supports IPv6.
  • false: The NIC does not support IPv6.

Default Value

false

ipv6_bandwidth

No

Object

Definition

Specifies the bound shared bandwidth. For details, see ipv6_bandwidth Field Description.

Constraints

N/A

Range

N/A

Default Value

N/A

allowed_address_pairs

No

Array of allow_address_pair objects

Definition

Specifies the allowed IP or MAC address pairs. For details, see Table 4 (extended attribute).

Constraints

  • The IP address cannot be 0.0.0.0/0.
  • Configure an independent security group for the port if a large CIDR block (subnet mask less than 24) is configured for parameter allowed_address_pairs.
  • If the value of allowed_address_pairs is 1.1.1.1/0, the source/destination check is disabled.
  • If a virtual IP address is bound to an ECS:
    • Leave the value of mac_address blank or set it to the MAC address of the NIC bound to the ECS.
    • Set allowed_address_pairs of the ECS NIC to 1.1.1.1/0.

Range

N/A

Default Value

N/A

Table 4 allow_address_pairs field description

Parameter

Mandatory

Type

Description

ip_address

No

String

Definition

Specifies the IP address.

Constraints

  • The IP address cannot be 0.0.0.0/0.
  • Configure an independent security group for the port if a large CIDR block (subnet mask less than 24) is configured for parameter allowed_address_pairs.

Range

N/A

Default Value

N/A

mac_address

No

String

Definition

Specifies the MAC address.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 5 root_volume field description

Parameter

Mandatory

Type

Description

volumetype

Yes

String

Definition

Specifies the disk type of an ECS system disk.

For details about disk types, see Disk Types and Performance.

Constraints

  • The disk type must match that provided by the system.
  • If the specified disk type is not available in the AZ specified by availability_zone, the disk creation will fail.

Range

The value can be SATA, SAS, GPSSD, SSD, ESSD, GPSSD2, and ESSD2.
  • SATA: common I/O disks (sold out)
  • SAS: high I/O disks
  • GPSSD: general purpose SSDs
  • SSD: ultra-I/O disks
  • ESSD: extreme SSDs
  • GPSSD2: general purpose SSD V2
  • ESSD2: extreme SSD V2

Default Value

N/A

size

No

Integer

Definition

Specifies the system disk size, in GiB.

Constraints

  • The system disk size must be greater than or equal to the minimum system disk size supported by the image (min_disk attribute of the image).
  • If this parameter is not specified or is set to 0, the default system disk size is the minimum value of the system disk in the image (min_disk attribute of the image).
NOTE:

To obtain the minimum system disk size (min_disk) of an image, click the image on the management console for its details. Alternatively, call the native OpenStack API for querying details about an image. For details, see "Querying Image Details (Native OpenStack)" in Image Management Service API Reference.

Range

1 to 1024

Default Value

N/A

extendparam

No

Object

Definition

Provides the disk information.

For details, see extendparam Field Description for Creating Disks.

Constraints

N/A

Range

N/A

Default Value

N/A

cluster_type

No

String

Definition

Specifies the storage type of an ECS system disk.

Constraints

This parameter must be used together with cluster_id and cluster_id must be specified.

Range

DSS (dedicated storage type)

Default Value

N/A

cluster_id

No

String

Definition

Specifies the ID of the storage pool used by an ECS system disk.

Constraints

N/A

Range

N/A

Default Value

N/A

hw:passthrough

No

Boolean

Definition

Specifies the device type of the EVS disks to be created.

Constraints

N/A

Range
  • If this parameter is set to false, VBD disks are created.
  • If this parameter is set to true, SCSI disks are created.

Default Value

If this parameter is not specified or set to a non-Boolean character, VBD disks are created by default.

metadata

No

Object

Definition

Specifies the metadata of the created EVS disk. For details, see metadata Field Description for Creating Disks.

Constraints

This parameter is used only when an encrypted disk is created.

Range

The length of key and value under metadata can contain no more than 255 bytes.

Default Value

N/A

iops

No

Integer

Definition

Specifies the IOPS configured for an EVS disk.

For details about IOPS of GPSSD2 and ESSD2 EVS disks, see Disk Types and Performance.

Constraints

  • This parameter is mandatory only when volumetype is set to GPSSD2 or ESSD2.
  • Only pay-per-use billing is supported.

Range

N/A

Default Value

N/A

throughput

No

Integer

Definition

Specifies the throughput of an EVS disk. The unit is MiB/s.

For details about the throughput range of GPSSD2 EVS disks, see Disk Types and Performance.

Constraints

  • This parameter is mandatory when volumetype is set to GPSSD2. It cannot be specified when volumetype is set to other values.
  • Only pay-per-use billing is supported.

Range

N/A

Default Value

N/A

Table 6 data_volumes field description

Parameter

Mandatory

Type

Description

volumetype

Yes

String

Definition

Specifies the disk type of an ECS data disk.

For details about disk types, see Disk Types and Performance.

Constraints

  • The disk type must match that provided by the system.
  • If the specified disk type is not available in the AZ specified by availability_zone, the disk creation will fail.

Range

The value can be SATA, SAS, GPSSD, SSD, ESSD, GPSSD2, and ESSD2.
  • SATA: common I/O disks (sold out)
  • SAS: high I/O disks
  • GPSSD: general purpose SSDs
  • SSD: ultra-I/O disks
  • ESSD: extreme SSDs
  • GPSSD2: general purpose SSD V2
  • ESSD2: extreme SSD V2

Default Value

N/A

size

Yes

Integer

Definition

Specifies the data disk size, in GiB.

Constraints

When you use a data disk image to create a data disk, ensure that the value of this parameter is greater than or equal to the size of the source data disk that is used to create the data disk image.

Range

10 to 32768

Default Value

N/A

shareable

No

Boolean

Definition

Specifies whether the disk is shared.

Constraints

This parameter has been discarded. Use multiattach.

Range

  • true: indicates that the created disk is a shared disk.
  • false: indicates that the created disk is a common EVS disk.

Default Value

false

multiattach

No

Boolean

Definition

Specifies the shared disk information.

Constraints

The shareable parameter is discarded. If both shareable and multiattach must be used, ensure that the values of the two parameters are the same. If this parameter is not specified, common EVS disks are created by default.

Range

  • true: indicates that the created disk is a shared disk.
  • false: indicates that the created disk is a common EVS disk.

Default Value

false

hw:passthrough

No

Boolean

Definition

Specifies the device type of the EVS disks to be created.

Constraints

N/A

Range
  • If this parameter is set to false, VBD disks are created.
  • If this parameter is set to true, SCSI disks are created.
  • If this parameter is not specified or set to a non-Boolean character, VBD disks are created by default.

Default Value

N/A

extendparam

No

Object

Definition

Provides the disk information.

For details, see Table 7.

Constraints

N/A

Range

N/A

Default Value

N/A

cluster_type

No

String

Definition

Specifies the storage type of an ECS data disk.

Constraints

This parameter must be used together with cluster_id and cluster_id must be specified.

Range

DSS (dedicated storage type)

Default Value

N/A

cluster_id

No

String

Definition

Specifies the ID of the storage pool used by an ECS data disk.

Constraints

N/A

Range

N/A

Default Value

N/A

data_image_id

No

String

Definition

Specifies ID of the data image. The value is in UUID format.

Constraints

If data disks are created using a data disk image, this parameter is mandatory and it does not support metadata.

Range

N/A

Default Value

N/A

metadata

No

Object

Definition

Specifies the metadata of the created EVS disk.

For details, see metadata Field Description for Creating Disks.

Constraints

  • The length of key and value under metadata can contain no more than 255 bytes.
  • This parameter is used only when an encrypted disk is created.
  • If data disks are created using a data disk image, this parameter cannot be used.

Range

N/A

Default Value

N/A

delete_on_termination

No

Boolean

Definition

Specifies the policy of releasing data disks when the ECS is deleted.

Constraints

This parameter is supported only by pay-per-use and spot ECSs.

Range

  • true: The data disk is released when the ECS is deleted.
  • false: The data disk is not released when the ECS is deleted.

Default Value

false

iops

No

Integer

Definition

Specifies the IOPS configured for an EVS disk.

For details about IOPS of GPSSD2 and ESSD2 EVS disks, see Disk Types and Performance.

Constraints

  • This parameter is mandatory only when volumetype is set to GPSSD2 or ESSD2.
  • Only pay-per-use billing is supported.

Range

N/A

Default Value

N/A

throughput

No

Integer

Definition

Specifies the throughput of an EVS disk. The unit is MiB/s.

For details about the throughput range of GPSSD2 EVS disks, see Disk Types and Performance.

Constraints

  • This parameter is mandatory when volumetype is set to GPSSD2. It cannot be specified when volumetype is set to other values.
  • Only pay-per-use billing is supported.

Range

N/A

Default Value

N/A

Table 7 cpu_options field description

Parameter

Mandatory

Type

Description

hw:cpu_threads

No

Integer

Definition

Specifies whether to enable CPU hyper-threading.

Constraints

This parameter can be set to 1 (disabling hyper-threading) only when all of the following conditions are met:

  • The ECS is being created or resized.
  • The extra_specs parameter of the target flavor contains:
    • hw:cpu_policy, whose value is set to dedicated
    • hw:cpu_threads, whose value is set to 2

Range

  • 1: Disable hyper-threading.
  • 2: Enable hyper-threading.

Default Value

N/A

Table 8 cpu_options field description

Parameter

Mandatory

Type

Description

hw:cpu_threads

No

Integer

Definition

Specifies whether to enable CPU hyper-threading.

Constraints

This parameter can be set to 1 (disabling hyper-threading) only when all of the following conditions are met:

  • The ECS is being created or resized.
  • The extra_specs parameter of the target flavor contains:
    • hw:cpu_policy, whose value is set to dedicated
    • hw:cpu_threads, whose value is set to 2

Range

  • 1: Disable hyper-threading.
  • 2: Enable hyper-threading.

Default Value

N/A

Response

Table 9 Response parameters

Parameter

Type

Description

job_id

String

Definition

Specifies the returned task ID after delivering the task. You can query the task progress using this ID. For details about how to query the task execution status based on job_id, see Job Status Management.

Range

N/A

order_id

String

Definition

Specifies the order ID. This parameter is returned for the creation of a yearly/monthly ECS.

Range

N/A

serverIds

Array of strings

Definition

Specifies ECS IDs.

NOTE:

You can query ECS details by ECS ID. If the system returns a 404 error, the ECS is being created, or creating the ECS failed.

Range

N/A

For details about abnormal responses, see Responses (Task).

Example Request

  • Create a yearly/monthly ECS running CentOS 7.6 64bit, with 1 vCPU, 1 GB of memory, and 1 Mbit/s of bandwidth bound. Use the key pair for login authentication.
    POST https://{endpoint}/v1.1/{project_id}/cloudservers
    
    {
        "server": {
            "availability_zone":"az1-dc1",
            "name": "newserver", 
            "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09", 
            "root_volume": {
                "volumetype": "SSD"
            }, 
            "data_volumes": [
                {
                    "volumetype": "SSD", 
                    "size": 100
                }, 
                {
                    "volumetype": "SSD", 
                    "size": 100,
                    "multiattach": true,
                    "hw:passthrough": true
                }
            ], 
            "flavorRef": "s2.small.1", 
            "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68", 
            "security_groups": [
                {
                    "id": "6242ef48-4d35-49c8-8711-a6e54902e44a"
                }
            ], 
            "nics": [
                {
                    "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08"
                }
            ], 
            "publicip": {
                "eip": {
                    "iptype": "5_sbgp",
                    "bandwidth": {
                        "size": 1, 
                        "sharetype": "PER"
                    }
                }
            }, 
            "key_name": "id_rsa", 
            "count": 1, 
            "metadata": {
                "op_svc_userid": "f79791beca3c48159ac2553fff22e166"
            },
            "extendparam": { 
                "chargingMode": "prePaid",
                "periodType": "month",
                "periodNum": 1,
                "isAutoRenew": "true",
                "isAutoPay": "true",
                "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb"
            },
            "os:scheduler_hints": {
              "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc"
            }
            
        }
    }
  • Create a yearly/monthly ECS running CentOS 7.6 64bit, with 1 vCPU, 1 GB of memory, and 1 Mbit/s of bandwidth bound. Use the password for login authentication. For security purposes, store the password in ciphertext in configuration files or environment variables.
    POST https://{endpoint}/v1.1/{project_id}/cloudservers
    
    {
        "server": {
            "availability_zone":"az1-dc1",
            "name": "newserver",
            "adminPass": "$ADMIN_PASS",   
            "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09",
            "root_volume": {
                "volumetype": "SSD"
            },
            "data_volumes": [
                {
                    "volumetype": "SSD",
                    "size": 100
                },
                {
                    "volumetype": "SSD",
                    "size": 100,
                    "multiattach": true,
                    "hw:passthrough": true
                }
            ],
            "flavorRef": "s2.small.1",
            "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68",
            "security_groups": [
                {
                    "id": "6242ef48-4d35-49c8-8711-a6e54902e44a"
                }
            ],
            "nics": [
                {
                    "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08"
                }
            ],
            "publicip": {
                "eip": {
                    "iptype": "5_sbgp",
                    "bandwidth": {
                        "size": 1,
                        "sharetype": "PER"
                    }
                }
            },
            "key_name": "",
            "count": 1,
            "metadata": {},
            "extendparam": {
                "chargingMode": "prePaid",
                "periodType": "month",
                "periodNum": 1,
                "isAutoRenew": "true",
                "isAutoPay": "true",
                "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb"
            },
            "os:scheduler_hints": {
                "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc"
            }
        }
    }
  • Create a yearly/monthly ECS running CentOS 7.6 64bit, with 1 vCPU, 1 GB of memory, and 1 Mbit/s of pay-per-use EIP (billed by traffic) bound. Use the key pair for login authentication.
    POST https://{endpoint}/v1.1/{project_id}/cloudservers
    
    {
        "server": {
            "availability_zone":"az1-dc1",
            "name": "newserver", 
            "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09", 
            "root_volume": {
                "volumetype": "SSD"
            }, 
            "data_volumes": [
                {
                    "volumetype": "SSD", 
                    "size": 100
                }, 
                {
                    "volumetype": "SSD", 
                    "size": 100,
                    "multiattach": true,
                    "hw:passthrough": true
                }
            ], 
            "flavorRef": "s2.small.1", 
            "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68", 
            "security_groups": [
                {
                    "id": "6242ef48-4d35-49c8-8711-a6e54902e44a"
                }
            ], 
            "nics": [
                {
                    "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08"
                }
            ], 
            "publicip": {
                "eip": {
                    "iptype": "5_sbgp",
                    "bandwidth": {
                        "size": 1, 
                        "sharetype": "PER",
                        "chargemode": "traffic"
                    },
                    "extendparam": {
                        "chargingMode": "postPaid"
                    }
                }
            }, 
            "key_name": "id_rsa", 
            "count": 1, 
            "metadata": {
                "op_svc_userid": "f79791beca3c48159ac2553fff22e166"
            },
            "extendparam": { 
                "chargingMode": "prePaid",
                "periodType": "month",
                "periodNum": 1,
                "isAutoRenew": "true",
                "isAutoPay": "true",
                "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb"
            },
            "os:scheduler_hints": {
              "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc"
            }
        }
    }
  • Create a yearly/monthly ECS running CentOS 7.6 64bit, with 1 vCPU, 1 GB of memory, and shared bandwidth bound. Use the key pair for login authentication.
    POST https://{endpoint}/v1.1/{project_id}/cloudservers
    
    {
        "server": {
            "availability_zone":"az1-dc1",
            "name": "newserver", 
            "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09", 
            "root_volume": {
                "volumetype": "SSD"
            }, 
            "data_volumes": [
                {
                    "volumetype": "SSD", 
                    "size": 100
                }, 
                {
                    "volumetype": "SSD", 
                    "size": 100,
                    "multiattach": true,
                    "hw:passthrough": true
                }
            ], 
            "flavorRef": "s2.small.1", 
            "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68", 
            "security_groups": [
                {
                    "id": "6242ef48-4d35-49c8-8711-a6e54902e44a"
                }
            ], 
            "nics": [
                {
                    "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08"
                }
            ], 
            "publicip": {
                "eip": {
                    "iptype": "5_sbgp",
                    "bandwidth": {
                        "id": "a0d4b26f-699d-49a0-bcc8-6f707a925abf",
                        "sharetype": "WHOLE"
                    }
                }
            }, 
            "key_name": "id_rsa", 
            "count": 1, 
            "metadata": {
                "op_svc_userid": "f79791beca3c48159ac2553fff22e166",
                "agency_name": "test"
            },
            "extendparam": { 
                "chargingMode": "prePaid",
                "periodType": "month",
                "periodNum": 1,
                "isAutoRenew": "true",
                "isAutoPay": "true",
                "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb"
            },
            "os:scheduler_hints": {
              "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc"
            }
        }
    }
  • Send a pre-verification request to check whether mandatory parameters are configured in the request and whether the request format is correct.
    POST https://{endpoint}/v1.1/{project_id}/cloudservers
    
    {
        "dry_run": true,
        "server": {
            "availability_zone":"az1-dc1", 
            "name": "server", 
            "imageRef": "ff49b1f1-3e3e-4913-89c6-a026041661e8", 
            "root_volume": {
                "volumetype": "SSD"
            }, 
            "data_volumes": [
                {                 
                    "volumetype": "SSD",                  
                    "size": 100             
                 },              
                {                 
                    "volumetype": "SSD",                  
                    "size": 100,                 
                    "multiattach": true,                 
                    "hw:passthrough": true             
                 }
            ], 
            "flavorRef": "s2.large.2", 
            "vpcid": "0dae26c9-9a70-4392-93f3-87d53115d171", 
            "security_groups": [
                {
                    "id": "507ca48f-814c-4293-8706-300564d54620"
                }
            ], 
            "nics": [
                {
                    "subnet_id": "157ee789-03ea-45b1-a698-76c92660dd83"
                }
            ],
            "key_name": "sshkey-123"
        }
    }

Example Response

{
    "job_id": "ff808082739334d80173943ec9b42130",
    "order_id": "CS2007281506xxxxx",
    "serverIds": [
        "fe0528f0-5b1c-4c8c-9adf-e5d5047b8c17",
        "679854ae-a50d-40c9-8132-b19bf3a306a1"
    ] 
}

Or

{
    "error": {
        "code": "Ecs.0005", 
        "message": "request body is illegal."
    }
}

Or

{
    "error": {
        "message": "privateIp [%s] is not in this subnet [%s]",
        "code": "Ecs.0005",
        "details": [
            {
                "code": "Ecs.0039"
            }
        ]
    }
}

Error Codes

See Error Codes.