Applies for an elastic IP address (EIP).

Usage notes

Before you call this operation, make sure that you understand the billing methods and pricing of EIPs. For more information, see Billing.

After you call this operation, the system randomly allocates an EIP that is in the Available state in the specified region. EIPs support only the following transport layer protocols: Internet Control Message Protocol (ICMP), Transmission Control Protocol (TCP), and User Datagram Protocol (UDP). Internet Group Management Protocol (IGMP) and Stream Control Transmission Protocol (SCTP) are not supported.

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 AllocateEipAddress

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

RegionId String Yes cn-hangzhou

The ID of the region to which the EIP belongs.

You can call the DescribeRegions operation to query the most recent region list.

Bandwidth String No 5

The maximum bandwidth of the EIP. Unit: Mbit/s.

  • When InstanceChargeType is set to PostPaid and InternetChargeType is set to PayByBandwidth, valid values for Bandwidth are 1 to 500.
  • When InstanceChargeType is set to PostPaid and InternetChargeType is set to PayByTraffic, valid values for Bandwidth are 1 to 200.
  • When InstanceChargeType is set to PrePaid, valid values for Bandwidth are 1 to 1000.

Default value: 5. Unit: Mbit/s.

Period Integer No 1

The subscription duration.

When PricingCycle is set to Month, set Period to a value from 1 to 9.

When PricingCycle is set to Year, set Period to a value from 1 to 5.

This parameter is required when InstanceChargeType is set to PrePaid. This parameter is optional when InstanceChargeType is set to PostPaid.

ISP String No BGP

The line type. You can set this parameter only when you create a pay-as-you-go EIP. Valid values:

  • BGP: BGP (Multi-ISP) lines

    Up to 89 high-quality BGP lines are available worldwide. Direct connections with multiple Internet service providers (ISPs), including China Telecom, China Unicom, China Mobile, China Mobile Tietong, China Netcom, CERNET, China Broadcast Network, Dr. Peng Group, and Founder, can be established in all regions in mainland China.

  • BGP_PRO: BGP (Multi-ISP) Pro lines

    BGP (Multi-ISP) Pro lines optimize data transmission to mainland China and improve connection quality for international services. Compared with BGP (Multi-ISP), when BGP (Multi-ISP) Pro lines provide services to users in mainland China (excluding data centers), cross-border connections are established by using mainland China ISP services. This reduces network latency.

BGP (Multi-ISP) lines are supported in all regions. BGP (Multi-ISP) Pro lines are supported only in the China (Hong Kong) region.

Note If your Alibaba Cloud account is included in the BGP (single line) whitelist, you can set the Isp parameter to ChinaTelecom, ChinaUnicom, or ChinaMobile. If your workloads are deployed in China East 1 Finance, this parameter is required and you must set the value to BGP_FinanceCloud.
ActivityId Long No 123456

The promotion code. Ignore this parameter.

Netmode String No public

The network type. Set the value to public, which specifies the Internet.

AutoPay Boolean No false

Specifies whether to enable automatic payment. Valid values:

  • false (default): disables automatic payment. If you select this option, you must go to the Order Center to complete the payment after an order is generated.
  • true: enables automatic payment. Payments are automatically completed.

When InstanceChargeType is set to PrePaid, this parameter is required. When InstanceChargeType is set to PostPaid, this parameter is not required.

PricingCycle String No Month

The billing cycle of the subscription EIP. Valid values:

  • Month (default): The EIP is billed on a monthly basis.
  • Year: The EIP is billed on an annual basis.

    When InstanceChargeType is set to PrePaid, this parameter is required. When InstanceChargeType is set to PostPaid, this parameter is not required.

InstanceChargeType String No PostPaid

The billing method of the EIP. Valid values:

  • PrePaid: subscription
  • PostPaid (default): pay-as-you-go

When InstanceChargeType is set to PrePaid, set InternetChargeType to PayByBandwidth. When InstanceChargeType is set to PostPaid, set InternetChargeType to PayByBandwidth or PayByTraffic.

InternetChargeType String No PayByTraffic

The metering method of the EIP. Valid values:

  • PayByBandwidth (default): pay-by-bandwidth
  • PayByTraffic: pay-by-data-transfer

When InstanceChargeType is set to PrePaid, you must set InternetChargeType to PayByBandwidth.

When InstanceChargeType is set to PostPaid, set InternetChargeType to PayByBandwidth or PayByTraffic.

ResourceGroupId String No rg-acfmxazffggds****

The ID of the resource group.

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 the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

Note If you do not set this parameter, the system automatically uses RequestId as ClientToken. RequestId may be different for each API request.
Name String No EIP1

The name of the EIP.

The name must be 1 to 128 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter but cannot start with http:// or https://.

Note This parameter is unavailable when you create a subscription EIP.
Description String No test

The description of the EIP.

The description must be 2 to 256 characters in length. It must start with a letter, but cannot start with http:// or https://.

Note This parameter is unavailable when you create a subscription EIP.
SecurityProtectionTypes.N String No AntiDDoS_Enhanced

The edition of Anti-DDoS. Valid values of N: 1 to 10.

  • If you do not set this parameter, Basic Edition Anti-DDoS is used.
  • If you set the value to AntiDDoS_Enhanced, Enhanced Edition Anti-DDoS is used.

Response parameters

Parameter Type Example Description
RequestId String 4EC47282-1B74-4534-BD0E-403F3EE64CAF

The ID of the request.

OrderId Long 10

The order number. This parameter is returned only when InstanceChargeType is set to PrePaid.

ResourceGroupId String rg-acfmxazfdgdg****

The ID of the resource group.

EipAddress String 192.0.XX.XX

The EIP that is allocated.

AllocationId String eip-25877c70gddh****

The ID of the EIP.

Examples

Sample requests

http(s)://[Endpoint]/?Action=AllocateEipAddress
&RegionId=cn-hangzhou
&Bandwidth=5
&Period=1
&ISP=BGP
&ActivityId=123456
&Netmode=public
&AutoPay=false
&PricingCycle=Month
&InstanceChargeType=PostPaid
&InternetChargeType=PayByTraffic
&ResourceGroupId=rg-acfmxazffggds****
&ClientToken=0c593ea1-3bea-11e9-b96b-88e9fe637760
&Name=EIP1
&Description=test
&SecurityProtectionTypes=["AntiDDoS_Enhanced"]
&Common request parameters

Sample success responses

XML format

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

<AllocateEipAddressResponse>
    <RequestId>4EC47282-1B74-4534-BD0E-403F3EE64CAF</RequestId>
    <OrderId>10</OrderId>
    <ResourceGroupId>rg-acfmxazfdgdg****</ResourceGroupId>
    <EipAddress>192.0.XX.XX</EipAddress>
    <AllocationId>eip-25877c70gddh****</AllocationId>
</AllocateEipAddressResponse>

JSON format

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

{
  "RequestId" : "4EC47282-1B74-4534-BD0E-403F3EE64CAF",
  "OrderId" : 10,
  "ResourceGroupId" : "rg-acfmxazfdgdg****",
  "EipAddress" : "192.0.XX.XX",
  "AllocationId" : "eip-25877c70gddh****"
}

Error codes

HttpCode Error code Error message Description
400 InvalidParameter Specified value of "Bandwidth" is not valid. The error message returned because the specified bandwidth value is invalid.
400 InsufficientBalance Your account does not have enough balance. The error message returned because your Alibaba Cloud account has an insufficient balance. Top up your Alibaba Cloud account and try again.
400 QuotaExceeded.Eip Elastic IP address quota exceeded. The error message returned because the number of EIPs has reached the upper limit. We recommend that you use NAT gateways if you want to use more EIPs.
400 ReserveIpFail Reserve eip failed. The error message returned because the system failed to reserve the specified EIP.
400 InvalidRegion.NotSupport The specified region does not support. The error message returned because the operation is not supported in the specified region.
400 InvalidResourceGroupId The specified ResourceGroupId does not exist. The error message returned because the specified resource group ID is invalid.
400 ORDER.QUANTITY_INVALID User quota has exceeded the limit. The error message returned because the number of EIPs that you have created has reached the upper limit. Go to the Quota Management page to request a quota increase.
400 OrderError.EIP The Account failed to create order. The error message returned because the system failed to generate the order.
403 Forbbiden User not authorized to operate on the specified resource. The error message returned because you are unauthorized to perform this operation on the specified resource. Apply for the required permissions and try again.
409 OperationConflict Request was denied due to conflict with a previos request. The error message returned because your request is conflicting with another request. Try again later.

For a list of error codes, visit the API Error Center.