All Products
Search
Document Center

ENS:CreateInstance

Last Updated:Aug 18, 2026

Creates a subscription instance. This operation can be replaced by RunInstances. No new features will be added to CreateInstance.

Operation description

  • Per-user call frequency: 10 calls per second.

  • Because instance creation is an asynchronous operation, increase the request timeout as needed. When the API returns Code=0, this only indicates that the request was successful, not that the instance was created successfully. An instance ID is returned upon a successful request. You can then query the instance by its ID to check whether the instance is created.

  • InvalidUserData.NotInWhiteList restriction: Only accounts that are added to the relevant whitelist with purchase permissions can create instances. Otherwise, an error is returned.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ens:CreateInstance

create

*Instance

acs:ens:*:{#accountId}:instance/*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceType

string

Yes

The instance type.

For details about instance types, see Limits.

ens.se1.tiny

EnsRegionId

string

Yes

The region ID.

cn-hangzhou

Password

string

No

The password of the instance.

The password must be 8 to 30 characters in length and must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. The following special characters are supported: ()`~!@#$%^&*-_+=|{}[]:;'<>,.?/

yourPassword:1

Period

string

Yes

The subscription duration. Valid values: 1 to 9 and 12. Unit: months.

12

ImageId

string

No

The ID of the image that is used to start the instance.

yourImage ID

SystemDisk.Size

string

No

The size of the system cloud disk. Unit: GiB. The value must be a multiple of 10 and cannot be smaller than the image size. For the valid range, refer to the SystemDiskMinSize and SystemDiskMaxSize values returned by DescribeAvailableResourceInfo. 20 GiB and 40 GiB are common configurations and do not indicate that only these two values are supported.

40

Quantity

string

Yes

The number of instances.

1

DataDisk.1.Size

string

No

The size of the first data cloud disk. Unit: GiB. The size must be at least 20 GiB and a multiple of 10.

50

InternetChargeType

string

No

This parameter is required when you create an instance for the first time. If you already have instance resources, the existing billing method is used by default. Valid values:

  • BandwidthByDay: daily peak bandwidth.

  • 95BandwidthByMonth: monthly 95th percentile bandwidth.

95BandwidthByMonth

AutoRenewPeriod

string

No

The auto-renewal period. This parameter is required when AutoRenew is set to True. Valid values: 1 to 12. Unit: months.

12

AutoRenew

string

No

Specifies whether to enable auto-renewal. Valid values: True | False (default).

True

IpType

string

No

The IP type. Valid values:

  • ipv4 (default): IPv4.

  • ipv6: IPv6.

  • ipv4Andipv6: IPv4 and IPv6.

Valid values:

  • ipv4 :

    IPv4

  • ipv6 :

    IPv6

  • ipv4Andipv6 :

    IPv4 and IPv6

ipv4

KeyPairName

string

No

The name of the key pair. Only a single name is supported.

TestKeyPairName

UserData

string

No

The custom data. The data must start with #!. The maximum length is 256 characters and the maximum size is 16 KB. Only custom data scripts are supported. InstanceMetaData rendering is not supported.

You can pass in custom data that is Base64-encoded. When you call the API to initiate a request, the custom data you specify is not encrypted. Do not pass in confidential information such as passwords and private keys in plaintext. If you need to pass in passwords or private keys, encrypt the content first and then Base64-encode it before passing it in. Decrypt the content in the same way inside the instance.

For more information, see Data format.

#!/bin/sh echo "Hello World. The time is now $(date -R)!" | tee /home/output.txt

VSwitchId

string

No

The vSwitch ID.

YourVSwitchId

PrivateIpAddress

string

No

The private IP address. If you specify a private IP address, you must also specify the VSwitchId parameter. The vSwitch must be created in advance. Otherwise, an error is returned.

10.10.10.10

PaymentType

string

No

The payment method. Currently, this is a fixed value of Subscription (subscription instance). Modification is not supported.

Valid values:

  • Subscription :

    Subscription.

Subscription

InstanceName

string

No

The name of the instance. Naming conventions:

  • The name must be 2 to 128 characters in length and can contain letters and Chinese characters.

  • The name must start with an uppercase letter, a lowercase letter, or a Chinese character. It cannot start with http:// or https://.

  • The name can contain digits, colons (:), underscores (_), periods (.), or hyphens (-).

If this parameter is not specified, the default value is the InstanceId of the instance.

test:Instance_Name.1-2

HostName

string

No

The hostname of the instance. General naming conventions: Periods (.) and hyphens (-) cannot be used as the first or last character and cannot be used consecutively.

Specific naming conventions:

  • Windows instances: The hostname must be 2 to 15 characters in length. Periods (.) are not supported. The hostname cannot consist entirely of digits. Uppercase letters, lowercase letters, digits, and hyphens (-) are allowed.

  • Other instances (such as Linux): The hostname must be 2 to 64 characters in length. Multiple periods (.) are supported. Each segment separated by a period can contain uppercase letters, lowercase letters, digits, and hyphens (-).

test-HostName

UniqueSuffix

boolean

No

Specifies whether to add sequential suffixes to HostName and InstanceName. The sequential suffixes start from 001 and cannot exceed 999.

Example: LocalHost001, LocalHost002, MyInstance001, and MyInstance002.

Default value: false.

false

PublicIpIdentification

boolean

No

Specifies whether a public IP address can be assigned to the specified instance. Valid values:

  • true (default): A public IP address can be assigned.

  • false: A public IP address cannot be assigned.

true

PasswordInherit

boolean

No

Specifies whether to use the preset password of the image. Valid values:

  • true: The preset password of the image is used. The Password parameter must be empty, and you must make sure that the image has a preset password.

  • false: The preset password of the image is not used.

false

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

4A431388-2D4B-46F4-A96B-D4E6BD0688C1

InstanceIds

object

InstanceId

array

The list of instance IDs.

string

The list of instance IDs.

[i-7ecpqvkicnchxccozrp****,i-6ecpqvkicnchxccozrp****]

Code

integer

The return code. A value of 0 indicates success.

Note

If you call this API operation by using an SDK, the return type is Integer. If you call this API operation by using a common method or HTTP, the return type is String.

0

Examples

Success response

JSON format

{
  "RequestId": "4A431388-2D4B-46F4-A96B-D4E6BD0688C1",
  "InstanceIds": {
    "InstanceId": [
      "[i-7ecpqvkicnchxccozrp****,i-6ecpqvkicnchxccozrp****]"
    ]
  },
  "Code": 0
}

Error codes

HTTP status code

Error code

Error message

Description

400 StockNotEnough The specified instance type has insufficient resource.
400 InvalidUserData.NotInWhiteList The specified user is not authroized to perform this operation.
400 MissingParameter The input parameter that is mandatory for processing this request is not supplied.
400 InstanceIdNotFound The input parameter instancdId that is not found. The specified instance ID does not exist.
400 NoPermission Permission denied.
400 CallInterface Call Interface Happen Error. An error occurred when you call the operation.
400 InvalidParameter The input parameter is Invalid.
400 InvalidParameter.%s The specified field %s invalid. Please check it again.
400 InvalidDiskSize.ValueNotSupported The specified disk capacity is invalid. Specify another capacity and try again.
400 InvalidParameter.Bandwidth The specified parameter InternetChargeType is not valid.
400 InvalidParameter.Image The specified image does not support.
400 InvalidParameter.InstanceType The specified parameter InstanceType is not valid.
400 InvalidAccountStatus.NotEnoughBalance Your account does not have enough balance.
400 unsupported_Ipv6Feature This ensregion does not support creating instance of the IPv6 type. Select another type.
400 Forbidden.CreateInstance The user is not in the Goods whitelist of creating instance interface.
400 ENS_OperationUnsupported_KeyPairName The KeyPairNameis not available or image not support ssh key.
400 ENS_DependencyViolation_WindowsInstance The instance creating is window, only user password to login.
400 ENS_PASSWORDORKEYPAIRNAME_MODULE_NOT_CHOOSEN The required module pwd or keyPairName is not inputed
400 InvalidPrivateIpAddress Specified private IP address is not in the CIDR block of virtual switch.
400 InvalidVSwitchId.NotFound Specified virtual switch does not exist. The specified virtual switch ID does not exist.
400 InvalidPrivateIpAddress.Duplicated Specified private IP address is duplicated.
400 InvalidPasswordParam.Mismatch The input password should be null when passwordInherit is true.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.