Create spot instances
Updated at:2025-10-20
This API facilitates the creation of spot instances.
Request structure
Plain Text
1POST /v{version}/instance/bid HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "spec": "spec",
7 "specId": "specId",
8 "ephemeralDisks": [
9 {
10 "storageType": storageType,
11 "sizeInGB": size
12 },
13 {
14 "storageType": storageType,
15 "sizeInGB": size
16 }
17 ],
18 "adminPass": "adminPass",
19 "aspId": "aspId",
20 "instanceType": instanceType,
21 "cpuCount": cpuCoreCount,
22 "bidModel":bidModel,
23 "bidPrice":bidPrice,
24 "memoryCapacityInGB": memoryCapacityInGB,
25 "rootDiskSizeInGb":rootDiskSizeInGb,
26 "rootDiskStorageType":"rootDiskStorageType",
27 "createCdsList": [
28 {
29 "storageType": storageType,
30 "cdsSizeInGB": cdsSizeInGB,
31 "snapshotId": "snapshotId"
32 }
33 ],
34 "userData": "userData",
35 "purchaseNum": purchaseNum
36 "isomerismCard": "isomerismCard",
37 "name": "name",
38 "hostname": "hostname",
39 "autoSeqSuffix": autoSeqSuffix,
40 "isOpenHostnameDomain": isOpenHostnameDomain,
41 "imageId": "imageId",
42 "networkCapacityInMbps": networkCapacityInMbps,
43 "eipName": "eipName",
44 "internetChargeType": internetChargeType,
45 "purchaseCount": purchaseCount,
46 "zoneName": zoneName,
47 "subnetId": subnetId,
48 "securityGroupId": securityGroupId,
49 "deletionProtection": "deletionProtection",
50 "enterpriseSecurityGroupId": "enterpriseSecurityGroupId",
51 "relationTag": relationTag,
52 "isOpenIpv6": isOpenIpv6,
53 "tags": [
54 {
55 "tagKey": tagKey,
56 "tagValue": tagValue
57 }
58 ],
59 "keypairId": keypairId,
60 "fileSystems": {
61 "fsId": "fsId",
62 "mountAds": "mountAds",
63 "path": "path",
64 "protocol": "protocol"
65 },
66 "resGroupId": "resGroupId"
67}
Request headers
There are no special headers required beyond the common headers.
Request parameters
| Parameter name | Types | Whether required | Parameter location | Description |
|---|---|---|---|---|
| version | String | Yes | URL parameter | API version number |
| clientToken | String | Yes | Query | Idempotence Token, which is an ASCII string with a length not exceeding 64 bits. For details, see the [Link](BCC/API Reference/General Description.md#Idempotence) |
| imageId | String | Yes | RequestBody | The image ID for the virtual machine instance to be created. You can select and retrieve the required image ID by calling the [Query Image List ](BCC/API Reference/Image Related Interfaces/Query the image list.md#Query the image list)API. |
| instanceType | String | No | RequestBody | Type of virtual machine instance to be created. For specific options, refer to [InstanceType](BCC/API Reference/Appendix.md#InstanceType) below. If empty, the default virtual machine type will be used. |
| cpuCount | int | Yes | RequestBody | Count of CPU cores for virtual machine instance to be created. Refer to [Regional Machine Types and Optional Configurations ](BCC/API Reference/Appendix.md#Regional models and optional configurations) for optional configurations. |
| bidModel | String | Yes | RequestBody | Spot instance bidding model; market price: "market"; custom: "custom". Refer to [BidModel](BCC/API Reference/Appendix.md#BidModel) |
| bidPrice | String | No | RequestBody | Spot Instance Bidding Price: Specify the price in RMB/minute. If selecting "custom" bidding and your bid is lower than the market price, creation will be rejected. This applies only when bidModel='custom'. |
| memoryCapacityInGB | int | Yes | RequestBody | Memory capacity for virtual machine instance to be created, in GB. Refer to [Regional Machine Types and Optional Configurations ](BCC/API Reference/Appendix.md#Regional models and optional configurations) for optional configurations. |
| rootDiskSizeInGb | int | No | RequestBody | Size of system disk for virtual machine instance to be created, in GB. The default is 40 GB, with a range of [40 to 2,048]GB. Sizes exceeding 40 GB are charged according to cloud disk server prices. Note that the specified system disk size must meet the minimum disk space requirements of the image being used. |
| rootDiskStorageType | String | No | RequestBody | Medium of system disk for virtual machine instance to be created. By default, an SSD cloud disk server is used. The disk type for the system disk can be specified; refer to [StorageType](BCC/API Reference/Appendix.md#StorageType). |
| createCdsList | List<[CreateCdsModel](BCC/API Reference/Appendix.md#CreateCdsModel)> | No | RequestBody | List of CDS disks to be created. For specific data formats, refer to [CreateCdsModel](BCC/API Reference/Appendix.md#CreateCdsModel) below |
| networkCapacityInMbps | int | No | RequestBody | Public network bandwidth in Mbps, an integer from 0 to 200. Setting it to 0 means no public IP will be assigned, with a default of 0 Mbps. |
| internetChargeType | String | No | RequestBody | Charge type for public network bandwidth. Options are detailed in [internetChargeType](BCC/API Reference/Appendix.md#InternetChargeType). If internetChargeType is not specified, it is based on actual bandwidth use by default. |
| purchaseCount | int | No | RequestBody | Count of virtual machine instances to be created (purchased) in batch, which must be an integer greater than 0 (optional). The default is 1 |
| name | String | No | RequestBody | Name of the virtual machine (optional) By default, no name is specified. If a name is specified: For batch creation, the name serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}. If no name is specified, it will be automatically generated as follows: {instance-eight-digit random string-sequence number}. Note: The random string is generated from 0~9a~z; the sequence number increments according to the magnitude of the count. If the count is 100, the sequence number increments from 000~100; if the count is 10, it increments from 00~10. Support uppercase and lowercase letters, numbers, Chinese characters, and -_/special characters, starting with a letter and a length of 1-65. |
| hostname | String | No | RequestBody | Hostname of the virtual machine (optional). By default, no hostname is specified. If a hostname is specified: For batch creation, the hostname serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}. If no name is specified, it will be automatically generated as follows: {instance-eight-digit random string-sequence number}. Note: The random string is generated from 0~9a~z; the sequence number increments according to the magnitude of the count. If the count is 100, the sequence number increments from 000~100; if the count is 10, it increments from 00~10. Only support lowercase letters, numbers and -_/special characters, starting with a letter and a length of 2-64. Not contain consecutive special characters and not start or end with a special character. |
| autoSeqSuffix | boolean | No | RequestBody | Whether to automatically generate ordered suffixes for name and hostname (optional). Yes: true No: false |
| isOpenHostnameDomain | boolean | No | RequestBody | Whether to automatically generate the hostname domain (optional) Yes: true No: false |
| adminPass | String | No | RequestBody | Instance administrator password to be specified: 8-16 characters; it must contain English letters, numbers, and symbols (limited to !@#$%^*()) simultaneously. Password must be encrypted during transmission. The password must be encrypted for transmission. For details, see the [Link](BCC/API Reference/General Description.md#Password encryption transmission specification) |
| zoneName | String | No | RequestBody | Specify zone information. By default, it is empty and automatically selected by the system. The list of availability zones can be queried by calling the [ Query Availability Zone List ](BCC/API Reference/Other APIs/Query list of availability zones.md#Query list of availability zones) API. The naming convention for zoneName is lowercase "country-region-availability zone sequence", such as "cn-bj-a" for Beijing availability zone A. Dedicated instances use the zone where the dedicated server is located, so this field does not need to be specified. |
| subnetId | String | No | RequestBody | Specify subnet information. If empty, it is the default subnet |
| securityGroupId | String | No | RequestBody | Specify security group information. If empty, it is the default security group |
| relationTag | boolean | No | RequestBody | Instance Tag Association: Specify whether the tag for the instance must be linked to an existing tag key (default: false). Note: If set to true, ensure the tag key already exists. |
| isOpenIpv6 | boolean | No | RequestBody | Whether to enable IPv6 for the instance to be created. IPv6 can only be enabled if both the image and subnet support it. True indicates enable, false indicates disable, and not specifying the parameter indicates automatic adaptation to the IPv6 support status of the image and subnet |
| tags | List<[TagModel](BCC/API Reference/Appendix.md#TagModel)> | No | RequestBody | List of tags to be created. For the specific data format, refer to the following [TagModel](BCC/API Reference/Appendix.md#TagModel) |
| keypairId | String | No | RequestBody | ID of the key pair to be bound to the instance to be created |
| aspId | String | No | RequestBody | Automatic snapshot policy ID |
| specId | String | No | RequestBody | Instance family |
| spec | String | No | RequestBody | Instance specification. |
| ephemeralDisks | List<[EphemeralDisk](BCC/API Reference/Appendix.md#EphemeralDisk)> | No | RequestBody | DCC instances can create multiple local disks, requiring specifying the disk type and size. Other types of BCC instances can use at most one local disk, using the default disk type and requiring specifying the disk size. FPGA and GPU instances default to using one local disk, with the local disk size specified according to the configuration. For details, refer to [GPU BCC Optional Specification Configurations](BCC/API Reference/Appendix.md#GPU-purpose BCC Optional Specification Configuration) and [FPGA BCC Optional Specification Configurations ](BCC/API Reference/Appendix.md#FPGA-purpose BCC Optional Specification Configuration). |
| adminPass | String | No | RequestBody | Instance administrator password to be specified: 8-16 characters; it must contain English letters, numbers, and symbols (limited to !@#$%^*()) simultaneously |
| userData | String | No | RequestBody | User Data Specifications: If compliant with instance limitations, encode UserData in Base64 before specifying it. As UserData is not encrypted during API transmission, avoid including sensitive information (e.g., passwords, private keys) in plaintext. If necessary, encrypt the data for secure decryption within the instance. |
| isomerismCard | String | No | RequestBody | Information about heterogeneous cards to be carried by the instance to be created. For options, refer to the relevant document. This field does not need to be specified for non-GPU instances |
| fileSystems | List<[FileSystemModel](BCC/API Reference/Appendix.md#FileSystemModel)> | No | RequestBody | Mount cloud file system (CFS). For specific parameters, refer to [FileSystemModel](BCC/API Reference/Appendix.md#FileSystemModel). |
| enterpriseSecurityGroupId | String | No | RequestBody | Specify enterprise security group |
| deletionProtection | int | No | RequestBody | Instance deletion protection: 0 (default) for disabled, 1 for enabled. When enabled, manual release of the virtual machine is prohibited |
| eipName | String | No | RequestBody | Name Specifications: Length: 1–65 bytes, must start with a letter. Permitted characters include letters, numbers, and -_/. If no name is specified, one will be automatically generated. |
| resGroupId | String | No | RequestBody | Specify the resource group ID to which the instance is to be bound |
Response headers
No special headers are required beyond the standard ones.
Response parameters
| Parameter name | Types | Description |
|---|---|---|
| instanceIds | List |
VM Instance ID Collection: Complies with BCE standards, accepting fixed-length strings comprising uppercase/lowercase letters, numbers, hyphens (-), and underscores (_). |
Error codes
| Error code | Error description | HTTP status code | Chinese explanation |
|---|---|---|---|
| Instance.InsufficientRootDiskSize | Not enough root disk size. | 400 | The image used is too large, and the system disk size is insufficient |
| Instance.InvalidateRootDiskStorageType | Invalidate root disk storage type. | 400 | Invalid system disk medium |
| Instance.InstanceBeBanned | The instance is banned, contact technical support for assistance. | 403 | The BCC service has been banned |
| Instance.GlobalInstanceQuotaLimitExceeded | Quota exceeds limit for regional postpaid instances pool, contact technical support for further assistance. | 413 | The count of postpaid virtual machines exceeds the pre-sale quota limit for the current region |
| Instance.InstanceQuotaLimitExceeded | Quota exceeds limit. | 413 | The count of instances exceeds the limit |
| Instance.EipQuotaLimitExceeded | The number of eip will exceed the limit. | 413 | The count of EIPs exceeds the limit during purchase |
| Instance.InvalidateConfiguration | Invalidate cpu memory configuration. | 400 | Invalid virtual machine configuration |
| BadRequest | bid price should be greater than market price. | 400 | The custom bidding price for the spot instance shall be greater than the market price |
| BadRequest | invalid purchaseNum. | 400 | The purchase count must be greater than 0. |
| BadRequest | missing bcc config. | 400 | Missing BCC configuration |
| BadRequest | invalid instanceType. | 400 | Invalid instance type |
| BadRequest | bidPrice can not be null when bidModel is custom. | 400 | The bidPrice cannot be empty when custom bidding is used |
| BadRequest | bidModel is invalid. | 400 | The value of bidModel is invalid |
| BadRequest | bidPrice is invalid. | 400 | The value of bidPrice is invalid |
| Instance.PermissionDeny | Instance permission deny. permission deny | 401 | No permission |
| RealNameQualify | No real name authentication | 409 | Operation is not allowed; real-name certification is not completed |
| Instance.RegionDenyException | You're not allowed to access this region. | 403 | Exception in region access denial |
| BadRequest | Not support serviceType. | 400 | This service type is not supported |
| BadRequest | cds config error. | 400 | Incorrect CDS configuration |
| Instance.InstanceCountCdsCountNotMatchException | Cds count must be multiple number of Instance count | 400 | The count of virtual machines created does not match the count of CDS disks |
| Instance.InvalidateZoneException | Invalidate zone name. | 400 | Invalid availability zone |
| Instance.NotSupportInstanceTypeException | not support the instance type. | 403 | This machine type is not supported. |
| BadRequest | Not support serviceType | 400 | This service type is not supported |
| BadRequest | invalid deploy id | 400 | Invalid deployment group ID |
| BadRequest | invalid cds count | 400 | The count of CDS disks should be an integer multiple of the count of BCC disks |
| BadRequest | cannot get market price | 400 | Failed to retrieve the market price |
Request example
Plain Text
1POST /v2/instance/bid HTTP/1.1
2Host: bcc.bj.baidubce.com
3ContentType: application/json
4Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
5
6{
7 "instanceType": "N1",
8 "cpuCount": 2,
9 "bidModel": "custom",
10 "bidPrice": 0.01,
11 "memoryCapacityInGB": 2,
12 "rootDiskSizeInGb":45,
13 "rootDiskStorageType":"cloud_hp1",
14 "createCdsList": [
15 {
16 "storageType": "std1",
17 "cdsSizeInGB": 5
18 }
19 ],
20 "name": "example",
21 "imageId": "m-mRjO3cjs",
22 "networkCapacityInMbps": 1,
23 "internetChargeType": "BANDWIDTH_POSTPAID_BY_HOUR",
24 "purchaseCount": 1,
25 "relationTag": true,
26 "tags": [
27 {
28 "tagKey":"tag1",
29 "tagValue":"var1"
30 }
31 ],
32 "keypairId":"k-R0J0BEA9"
33}
Response example
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Wed, 03 Dec 2014 06:42:19 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
6
7{
8 "orderId": "d1ace996973643b299ea506a80dae4da",
9 "instanceIds": [
10 "i-T1I3OtUO"
11 ]
12}
