All Products
Search
Document Center

Auto Scaling:DetachServerGroups

Last Updated:Dec 30, 2025

You can call the DetachServerGroups operation to remove one or more server groups from a scaling group. This lets you dynamically adjust traffic steering policies for changing workloads and ensure high application availability. Supported server group types include Application Load Balancer (ALB), Network Load Balancer (NLB), and Gateway Load Balancer (GWLB).

Try it now

Run this operation directly in OpenAPI Explorer without needing to calculate signatures. After a successful call, OpenAPI Explorer automatically generates sample code for different software development kits (SDKs).

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

DetachServerGroups

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

RegionId

String

Yes

cn-hangzhou

The region ID of the scaling group.

ScalingGroupId

String

Yes

asg-bp18p2yfxow2dloq****

The ID of the scaling group.

ClientToken

String

No

123e4567-e89b-12d3-a456-42665544****

A client token to ensure the idempotence of the request.

Generate a value from your client and make sure it is unique across different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

ForceDetach

Boolean

No

false

Specifies whether to remove the ECS instances or ECI instances in the scaling group from the server groups to be detached. Valid values:

  • true: Removes the instances.

  • false: Does not remove the instances.

Default value: false.

ServerGroup.N.ServerGroupId

String

Yes

sgp-1gv2uidn2msy****

The server group ID.

ServerGroup.N.Type

String

Yes

ALB

The type of server group N. Valid values:

  • ALB: Application Load Balancer.

  • NLB: Network Load Balancer.

  • GWLB: Gateway Load Balancer.

ServerGroup.N.Port

Integer

No

22

The port number used by the ECS or ECI instances in the server group.

Note

This parameter is required for ALB and NLB server groups. Do not set this parameter for GWLB server groups. The default value is 6081 for GWLB server groups.

Response parameters

Parameter

Type

Example

Description

ScalingActivityId

String

asa-bp1gbswjhjrw8tko****

The ID of the scaling activity that is triggered when you detach the server groups and remove the instances from them.

Note

This parameter is returned only if ForceDetach is set to true.

RequestId

String

6EF9BFEE-FE07-4627-B8FB-14326FB9****

The request ID.

Examples

Sample request

http(s)://ess.aliyuncs.com/?Action=DetachServerGroups
&RegionId=cn-hangzhou
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&ForceDetach=false
&ServerGroup=[{"ServerGroupId":"sgp-1gv2uidn2msy****","Type":"ALB","Port":22}]
&<Common request parameters>

Sample success responses

XML format

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

<DetachServerGroupsResponse>
    <ScalingActivityId>asa-bp1gbswjhjrw8tko****</ScalingActivityId>
    <RequestId>6EF9BFEE-FE07-4627-B8FB-14326FB9****</RequestId>
</DetachServerGroupsResponse>

JSON format

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

{
  "ScalingActivityId" : "asa-bp1gbswjhjrw8tko****",
  "RequestId" : "6EF9BFEE-FE07-4627-B8FB-14326FB9****"
}

Error codes

For a list of error codes, see the Error Center.