You can call this operation to apply for an Elastic IP address (EIP).

Description

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

After you call this operation, an EIP in the Available state in a specified region is randomly allocated. EIPs support only the following transport layer protocols: ICMP, TCP, and UDP.

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 AssociateEipAddress.

RegionId String Yes cn-hangzhou

The ID of the region where you want to create an EIP. You can call the DescribeRegions operation to query region IDs.

Bandwidth String No 5

The peak bandwidth of the EIP. Valid values:1 to 200. Unit: Mbit/s.

Default value:5.

Period Integer No 1

The subscription duration of the EIP.

When PricingCycle is set to Month, Period can be set from 1 to 9.

When PricingCycle is set to Year, Period can be set from 1 to 3.

This parameter is required when InstanceChargeType is set to PrePaid. Ignore this parameter when InstanceChargeType is set to PostPaid.

Note This parameter is unavailable for EIPs purchased on the Alibaba Cloud International Site.
ISP String No BGP

The type of connection. 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 Telecom, Unicom, Mobile, Railcom, Netcom, CERNET, China Broadcast Network, Dr. Peng, and Founder, can be established in all regions in mainland China.

  • BGP_PRO: BGP (Multi-ISP) Pro lines.

    BGP (Multi-ISP) Pro lines are provided to optimize data transmission to mainland China and improve connection quality for international services. Compared with traditional BGP (Multi-ISP) lines, BGP (Multi-ISP) Pro lines can be used to establish direct connection without using international ISP services and reduce network latency.

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

Note If your account is in the BGP (single line) whitelist, you can set the ISP field to ChinaTelecom, ChinaUnicom, or ChinaMobile. This parameter is required if you are connected to China East 1 Finance. Set the value to BGP_FinanceCloud.
ActivityId Long No 11111

The promotion code. Ignore this parameter.

Netmode String No public

The network type. Set the value to public (public network).

AutoPay Boolean No false

Specifies whether to enable automatic payment. Valid values:

false: disables automatic payment. After an order is generated, you must go to the order center to complete the payment.

true: enables automatic payment. The system automatically deducts funds from your account to pay for orders.

This parameter is required when InstanceChargeType is set to PrePaid. Ignore this parameter when InstanceChargeType is set to PostPaid.

Note This parameter is unavailable for EIPs purchased on the Alibaba Cloud International Site.
PricingCycle String No Month

The billing cycle of subscription EIPs. Valid values:

Month: Bills are paid on a monthly basis. This is the default value.

Year: Bills are paid on an annual basis.

This parameter is required when InstanceChargeType is set to PrePaid. Ignore this parameter when InstanceChargeType is set to PostPaid.

Note This parameter is unavailable for EIPs purchased on the Alibaba Cloud International Site.
InstanceChargeType String No PostPaid

The billing method of the EIP. Valid values:

PrePaid: subscription.

PostPaid: pay-as-you-go. This is the default value.

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

Note On the international site, you can set this parameter only to PostPaid (pay-as-you-go).
InternetChargeType String No PayByTraffic

The metering method of the EIP. Valid values:

PayByBandwidth: Fees are charged based on bandwidth usage. This is the default value.

PayByTraffic: Fees are charged based on data transfer.

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

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

ResourceGroupId String No rg-acfmxazffggds****

The ID of the enterprise 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 that is unique among different requests. The ClientToken value must contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

Response parameters

Parameter Type Example Description
EipAddress String 12.xx.xx.78

The EIP that was allocated.

AllocationId String eip-25877c70gddh****

The ID of the EIP.

OrderId Long 10

Order number. It is returned only when InstanceChargeType is set to PrePaid.

RequestId String 4EC47282-1B74-4534-BD0E-403F3EE64CAF

The ID of the request.

ResourceGroupId String rg-acfmxazfdgdg****

The ID of the resource group.

Examples

Sample requests

http(s)://vpc.aliyuncs.com/? Action=AllocateEipAddress
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

Error codes

HttpCode Error code Error message Description
403 Forbbiden User not authorized to operate on the specified resource. The error message returned because you are not authorized to perform this operation on the specified resource. You can apply for the permission and try again.
400 QuotaExceeded.Eip Elastic IP address quota exceeded The error message returned because the number of EIPs exceeds the threshold. To obtain more EIPs, submit a ticket. We recommend that you use NAT gateways.
400 InvalidParameter Specified value of "InternetChargeType" is not valid The error message returned because the specified InternetChargeType value is invalid.
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 you do not have sufficient account balance. Add funds to your account and try again.
400 QuotaExceeded.Eip Elastic IP address quota exceeded. The error message returned because the number of EIPs exceeds the threshold. To obtain more EIPs, submit a ticket. We recommend that you use NAT gateways.
400 ReserveIpFail Reserve eip failed. The error message returned because the specified EIP fails to be reserved.
400 InvalidRegion.NotSupport The specified region does not support. The error message returned because the specified region ID does not support this operation.
409 OperationConflict Request was denied due to conflict with a previos request. The error message returned because a request conflict occurs. Try again later or submit a ticket.

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