CreateInstances

1. API Description

This API is used to create one or more virtual machine instances with a specified configuration.

Prerequisites

Note

  • After an instance is created successfully, it will start up automatically, and the instance status will become "RUNNING".

  • If you create a subscription instance, the amount required will be pre-deducted. If the balance is insufficient, the request will fail. If you create a pay-as-you-go instance, please ensure your account balance is sufficient before calling this API.

  • Vouchers can be used for fee deduction in instance creation. See Vouchers for more details.

  • This API is an async API. An instance ID list is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the instance will be PENDING or DEPLOYING during the creation. You can use DescribeInstances to query the status of the instance. If the status (instanceStatus) changes from PENDING or DEPLOYING to Running, it means that the instance has been created successfully; if no instance has been queried, it means the instance has been created failed. Any operations on the instances are not allowed while creating.

  • A maximum of 100 instances can be created in one request.

2. Input Parameters

The following request parameter list only provides API request parameters.

3. Output Parameters

4. Code Example

Create a pay-as-you-go instance with the simplest parameters Assuming to create a pay-as-you-go instance in Seoul A with the model of 1c2g, 1 Mbps flat rate bandwidth billing method, random system-generated password, and no images installed.

POST / HTTP/1.1
Host: console.zenlayer.com/api/v2/vm
Content-Type: application/json
X-ZC-Action: CreateInstances
<Common Request Params>

Request:
{
    "zoneId":"SEL-A",
    "instanceType":"c.1c2g",
    "imageId":"img-yKK4q6XybymPgfx7ynUUqC3N8",
    "instanceChargeType":"POSTPAID",
    "internetChargeType":"ByBandwidth"
}

Response:
{
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "response": {
        "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
        "instanceIdSet": ["instanceId1"],
        "orderNumber" : "the id of order number",
        "instances":[{"instanceId":"instanceId1","diskIdSet":[]}]
    }
}

5. Developer Resources

Zenlayer Cloud API 2.0 integrates SDKs to make it easier for you to call APIs. More programming languages will be supported.

6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.​

Last updated