Updated on 2025-07-25 GMT+08:00

Creating an Instance

Function

This API is used to create an instance with more custom parameters, such as an IP address.

The following scheduling policies are supported:

1. Scheduling to selected servers

2. Random scheduling to idle servers

VPC and AI parameter plane networks can be configured.

This API is an asynchronous API. The instance creation and startup are not completed immediately. You can call the ShowInstanceStatus API to check whether the instance statuses are running. If they are, the instances have been created.

Constraint: The value of manage_state for the instances must be ready.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/instances

Table 1 URI parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

The project ID.

Constraints

N/A

Range

The project ID of the account

Default Value

N/A

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

Requests for calling an API can be authenticated using a token. If token-based authentication is used, this parameter is mandatory and must be set to a user token.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Definition

The hostname of an instance.

Constraints

N/A

Range

The value can contain 1 to 63 characters, including letters (case-sensitive), digits, underscores (_), hyphens (-), and periods (.).

Default Value

N/A

image_id

Yes

String

Definition

Image ID.

Constraints

N/A

Range

N/A

Default Value

N/A

vpc_id

Yes

String

Definition

ID of the VPC which the network interface to be created belongs to. You can query the ID using the VPC API: https://support.huaweicloud.com/intl/en-us/api-vpc/vpc_api01_0003.html

Constraints

N/A

Range

VPC ID

Default Value

N/A

network_interfaces

Yes

Array of NetworkInterface objects

Definition

Network interface information about an iMetal server.

Constraints

An iMetal server can contain a maximum of two network interfaces, and the first one serves as the primary network interface. If multiple network interfaces are specified, ensure that all network interfaces belong to the same VPC.

password

Yes

String

Definition

Default login password for the instance administrator. For Linux, the administrator is root. For Windows, the administrator is Administrator.

Constraints

N/A

Range

The value can contain 8 to 26 characters.

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

The password cannot contain the username or the username spelled backwards.

Default Value

N/A

metadata

No

Table 5 object

-

description

No

String

Definition

Description of an iMetal instance.

Constraints

N/A

Range

Maximum length: 255 characters

Default Value

Empty string

placement

No

placement object

Definition

Placement of the instance, which specifies the server policy. If placement is not specified, idle servers are selected based on min_count and max_count.

Constraints

N/A

Table 4 NetworkInterface

Parameter

Mandatory

Type

Description

subnet_id

Yes

String

Definition

subnet id

Constraints

N/A

Range

N/A

Default Value

N/A

ipv4_address

No

String

Definition

Private IPv4 address of an elastic network interface.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 5 metadata

Parameter

Mandatory

Type

Description

{Custom key}

No

Map<String,String>

Definition

Metadata for creating an iMetal instance. You can use metadata to customize key-value pairs.

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

Constraints

N/A

Range

A maximum of 10 key-value pairs can be injected.

A metadata key consists of 1 to 255 characters and contains only uppercase letters, lowercase letters, spaces, digits, hyphens (-), underscores (_), colons (:), and decimal points (.).

A metadata value consists of a maximum of 255 characters.

Default Value

N/A

Table 6 placement

Parameter

Mandatory

Type

Description

server_id

No

String

Definition

ID of the specified server.

Constraints

N/A

Range

ID of an idle server

Default Value

N/A

Response Parameters

Status code: 202

Table 7 Response body parameter

Parameter

Type

Description

instance_id

String

Instance ID.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

Constraints

N/A

Range

N/A

Default Value

N/A

error_msg

String

Definition

Error message.

Constraints

N/A

Range

N/A

Default Value

N/A

Status code: 401

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

Constraints

N/A

Range

N/A

Default Value

N/A

error_msg

String

Definition

Error message.

Constraints

N/A

Range

N/A

Default Value

N/A

Status code: 429

Table 10 Response body parameter

Parameter

Type

Description

-

String

-

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

Constraints

N/A

Range

N/A

Default Value

N/A

error_msg

String

Definition

Error message.

Constraints

N/A

Range

N/A

Default Value

N/A

Example Requests

Request for creating an instance

POST https://{endpoint}/v1/{project_id}/instances

Example Responses

Status code: 202

Instance created.

{
  "instance_id" : "0198170e-4ca7-7ee4-89a7-fa631843920b"
}

Status Codes

Status Code

Description

202

Instances created.

400

Invalid request parameter.

401

The request is not authenticated.

429

The request is overloaded.

500

Internal server error.

Error Codes

For details, see Error Codes.