Creates a capacity reservation.

Usage notes

When you create a capacity reservation, you can specify attributes such as zone and instance type. The system uses a private pool to reserve resources that match the specified attributes. For more information, see Overview of Immediate Capacity Reservation.

  • Currently, only immediate capacity reservations are supported. Immediate capacity reservations take effect as soon as they are purchased. After you purchase an immediate capacity reservation, the specified instance type is billed on a pay-as-you-go basis, regardless of whether you actually use the capacity reservation to create pay-as-you-go instances. Billing stops until you manually release the capacity reservation or until the capacity reservation expires and is automatically released.
    • You can call the CreateInstance or RunInstances operation to specify private pool attributes when you create instances. You can also call the ModifyInstanceAttachmentAttributes operation to modify the attributes of a private pool. When an instance matches a private pool that is associated with a capacity reservation, you are charged based on the configurations of the instance, such as the instance type, disks, and public bandwidth.
    • Before a private pool associated with a capacity reservation is used to create pay-as-you-go instances, you are charged only for the specified instance type.
  • Savings plans or regional reserved instances can be applied to offset the hourly bills of the unused capacity of immediate capacity reservations and the hourly bills of the instances that match immediate capacity reservations. Zonal reserved instances cannot be applied to offset these bills. We recommend that you purchase reserved instances or savings plans before you purchase immediate capacity reservations. This way, you can have guaranteed access to resources for free within the coverage of the reserved instances or savings plans.
Note This operation can be called to create only immediate capacity reservations. The ECS console can be used to create immediate or scheduled capacity reservations. For more information, see Overview.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateCapacityReservation

The operation that you want to perform. Set the value to CreateCapacityReservation.

RegionId String Yes cn-hangzhou

The ID of the region in which to create the capacity reservation. You can call the DescribeRegions operation to query the most recent region list.

ResourceGroupId String No rg-bp67acfmxazb4p****

The ID of the resource group to which to assign the capacity reservation.

Tag.N.Key String No TestKey

The key of tag N to add to the capacity reservation. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot contain http:// or https://. It cannot start with acs: or aliyun.

Tag.N.Value String No TestValue

The value of tag N to add to the capacity reservation. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot start with acs:. The tag value cannot contain http:// or https://.

ClientToken String No 0c593ea1-3bea-11e9-b96b-88e9fe637760

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that it is unique among different requests. The ClientToken value can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

PrivatePoolOptions.Name String No crpTestName

The name of the capacity reservation. The name must be 2 to 128 characters in length. The description must start with a letter but cannot start with http:// or https://. It can contain letters, digits, colons (:), underscores (_), and hyphens (-).

Description String No This is description.

The description of the capacity reservation. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

This parameter is empty by default.

PrivatePoolOptions.MatchCriteria String No Open

The type of the private pool to generate after the capacity reservation takes effect. Valid values:

  • Open: open private pool
  • Target: targeted private pool

Default value: Open.

InstanceAmount Integer Yes 2

The total number of instances for which to reserve capacity of an instance type.

InstanceType String Yes ecs.g6.xlarge

The instance type. A capacity reservation can be created to reserve the capacity of only a single instance type. You can call the DescribeInstanceTypes operation to query the instance types provided by ECS.

StartTime String No 2021-10-30T05:32:00Z

The mode in which the capacity reservation takes effect. The CreateCapacityReservation operation can only be called to create immediate capacity reservations.

Note If this parameter is empty, the capacity reservation is created as an immediate capacity reservation.
EndTime String No 2021-10-30T06:32:00Z

The time when the capacity reservation expires. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC. For more information, see ISO 8601.

EndTimeType String No Unlimited

The release mode of the capacity reservation. Valid values:

  • Limited: The capacity reservation is automatically released at the specified time. If you specify this parameter, you must also specify the EndTime parameter.
  • Unlimited: The capacity reservation must be manually released. You can release it anytime.
Platform String No Linux

The operating system type. This parameter corresponds to the Platform parameter of regional reserved instances. If the operating system of a capacity reservation matches the operating system of a regional reserved instance, the regional reserved instance can be applied to offset bills of the unused capacity of the capacity reservation. Valid values:

  • Windows: Windows Server operating system
  • Linux: Linux and UNIX-like operating system

Default value: Linux.

Note This parameter is unavailable.
ZoneId.N String Yes cn-hangzhou-h

The ID of zone N within the region in which to create the capacity reservation. A capacity reservation can reserve resources within only a single zone.

Response parameters

Parameter Type Example Description
PrivatePoolOptionsId String crp-bp67acfmxazb4****

The ID of the capacity reservation.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

http(s)://ecs.aliyuncs.com/?Action=CreateCapacityReservation
&RegionId=cn-hangzhou
&InstanceType=ecs.g6.xlarge
&InstanceAmount=2
&ZoneId.1=cn-hangzhou-h
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateCapacityReservationResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
    <PrivatePoolOptionsId>crp-bp67acfmxazb4****</PrivatePoolOptionsId>
</CreateCapacityReservationResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "PrivatePoolOptionsId" : "crp-bp67acfmxazb4****"
}

Error codes

HTTP status code Error code Error message Description
400 OperationDenied The specified InstanceType or Zone is not available or not authorized. The error message returned because the specified instance type or zone is unavailable or because you are not authorized to use resources of the specified instance type or use resources within the specified zone.
400 MissingParameter.RegionId The specified RegionId should not be null. The error message returned because the required RegionId parameter is not specified.
400 InvalidStartTime.NotSupported The specified StartTime should be within 180 calendar days from the current date, and you must specify a precision to hour. The error message returned because the specified StartTime parameter is invalid.
400 InvalidStartTime.MalFormed The specified StartTime is out of the permitted range. The error message returned because the specified StartTime parameter is invalid.
400 DedicatedHostNotSupported DedicatedHost is not supported for PrivatePool. The error message returned because private pools cannot be used to create instances on dedicated hosts.
400 SpotNotSupported Spot is not supported for PrivatePool. The error message returned because private pools cannot be used to create preemptible instances.
400 ClassicNetworkNotSupported Classic network is not supported for PrivatePool. The error message returned because private pools cannot be used to create instances in the classic network.
400 Invalid.InstanceId Instance does not exist. The error message returned because the instance does not exist.
400 Invalid.PrivatePoolOptions.MatchCriteria Target mode does not support this operation. The error message returned because the operation is not supported while the PrivatePoolOptions.MatchCriteria parameter is set to Target.
400 MissingParameter.PrivatePoolOptions.Id The specified PrivatePoolOptions.Id should not be null. The error message returned because the PrivatePoolOptions.Id parameter is not specified.
400 Invalid.PrivatePoolOptions.Id The PrivatePool does not exist. The error message returned because the private pool does not exist.
400 Invalid.InstanceType The InstanceType does not match the PrivatePool. The error message returned because the specified instance type does not match the specified private pool.
400 Invalid.InstanceChargeType The InstanceChargeType does not match the PrivatePool. The error message returned because the billing method of the instance does not match the private pool.
400 Invalid.ZoneId The ZoneId does not match the PrivatePool. The error message returned because the zone does not match the private pool.
400 Invalid.PrivatePoolOptions.MatchCriteria The PrivatePoolOptions.MatchCriteria does not match the PrivatePool. The error message returned because the specified PrivatePoolOptions.MatchCriteria parameter does not match the private pool.
400 InvalidPlatform.ValueNotSupported The Platform does not match the PrivatePool. The error message returned because the specified Platform parameter does not match the private pool.
400 InvalidAliUid The PrivatePool does not belong to the user of the Instance. The error message returned because the specified private pool does not belong to the user who attempted to create the instance.
400 Invalid.InstanceId The Instance dose not attached to a PrivatePool. The error message returned because the instance does not match the private pool.
400 Invalid.TooManyPrivatePoolOptions.Ids Too many PrivatePoolOptions.Ids in this request. The error message returned because the number of specified capacity reservation IDs exceeds the upper limit.
400 Invalid.TooManyZoneIds Too many ZoneIds in the request. The error message returned because the number of specified zone IDs exceeds the upper limit.
400 Invalid.TooManyInstanceTypes Too many InstanceTypes in the request. The error message returned because the number of specified instance types exceeds the upper limit.
400 Invalid.TooManyUnpaidPrivatePool Too many PrivatePools create but still unpaid. The error message returned because multiple private pools are created and not paid.
400 Invalid.InstanceCpuCoreCountOrInstanceAmount Both InstanceCpuCoreCount and InstanceAmount are provided. The error message returned because the InstanceCpuCoreCount and InstanceAmount parameters cannot be specified at the same time.
400 Invalid.PrivatePool.Purchase The PrivatePool has already paid. The error message returned because the private pool is already paid.
400 Invalid.AssuranceTimes.NotSupported The value of AssuranceTimes is not supported. The error message returned because the specified AssuranceTimes parameter is invalid.
400 RepeatStartPrivatePool PrivatePool has already been started. The error message returned because the private pool is already started.
400 AccountForbidden.ProductCreationLimited The commodity must be officially operated by Aliyun and in pay-as-you-go billing method. The error message returned because you can use Alibaba Cloud accounts to purchase only pay-as-you-go ECS instances and cannot purchase third-party products, such as images provided in Alibaba Cloud Marketplace. Check parameters. Make sure that all parameters meet the conditions and try again.
400 PriceNotFound The price of your queried resource is not available now, please try other resources. The error message returned because the price of the specified resource is not found. Modify the parameter value and try again later.
403 Zone.NotOpen The specified zone is not granted to you to buy resources yet. The error message returned because you are not authorized to purchase resources in the specified zone.
403 OperationDenied.NoStock The resource is out of stock in the specified zone. Please try other types, or choose other regions and zones. The error message returned because the specified resource is unavailable in the specified zone. Try a different resource type or select a different region or zone.
403 InvalidInstanceType.NotSupported The specified InstanceType is invalid. The error message returned because the specified InstanceType parameter is invalid.
403 Zone.NotOnSale The specified zone is not available for purchase. The error message returned because the requested resources are unavailable in the specified zone. Try a different instance type or select a different region or zone.
404 InvalidZoneId.NotFound The specified zoneId does not exist. The error message returned because the specified zone ID does not exist.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The error message returned because the specified resource group does not exist.
500 InternalError The request processing has failed due to some unknown error, exception or failure. The error message returned because an internal error has occurred. Try again later.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred. Try again later.

For a list of error codes, see Service error codes.