> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/zec/instance/placement-group/modifyplacementgroupattributes.md).

# ModifyPlacementGroupAttributes

## 1. API Description

This API (ModifyPlacementGroupAttributes) is used to modify the name, number of partitions, affinity of the placement group.

{% hint style="info" %}
**Notes**

* The number of partitions (partitionNum) must be greater than or equal to the current number of instances.
* The affinity ranges from 1 to floor(number of partitions / 2).
* If the modified number of partitions or affinity does not match the current distribution of the instances, the modification is rejected. Remove the relevant instances before the operation.
* The availability zone of the placement group cannot be modified.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name   | Required | Type    | Description                                                                                                                                                                                                                                                                                                                              |
| ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| placementGroupId | Yes      | String  | <p>Placement group ID.</p><p>It can be obtained by calling <a href="/api-reference/zec/instance/placement-group/describeplacementgroups.md">DescribePlacementGroups</a>.</p>                                                                                                                                                             |
| name             | No       | String  | <p>Name for the placement group.</p><p>Length 2 to 63 characters.</p><p>Must start and end with a letter or number, supports letters, numbers, spaces, hyphens, slashes, and periods.</p>                                                                                                                                                |
| partitionNum     | No       | Integer | <p>The number of partitions in the placement group.</p><p>The range is from 2 to 5.</p><p>The number of partitions can only be increased, not decreased.</p><p>If the modified number of partitions or affinity does not meet the current instance distribution state, the modification will be rejected.</p><p>Value range: \[2, +)</p> |
| affinity         | No       | Integer | <p>Affinity of the placement group.</p><p>Valid values range from 1 to floor(partitionNum / 2).</p><p>Value range: \[1, +)</p>                                                                                                                                                                                                           |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Modify the placement group name.**

```json
POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: ModifyPlacementGroupAttributes
<Common Request Params>

Request：
{
  "placementGroupId": "placementgroup-xxxxxxxx",
  "name": "new-placement-group-name"
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3"
  }
}
```

**2. Modify the number of partitions for the placement group.**

```json
POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: ModifyPlacementGroupAttributes
<Common Request Params>

Request：
{
  "placementGroupId": "placementgroup-xxxxxxxx",
  "partitionNum": 5
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](/api-reference/api-introduction/toolkit/api-sdk.md)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                                                  | Description                                                                                                                                       |
| ---------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| 404              | INVALID\_PLACEMENT\_GROUP\_NOT\_FOUND                       | The placement group does not exist.                                                                                                               |
| 400              | INVALID\_PLACEMENT\_GROUP\_PARTITION\_NUM\_CANNOT\_DECREASE | The partition count of the placement group cannot be decreased.                                                                                   |
| 400              | INVALID\_PLACEMENT\_GROUP\_CONSTRAINT\_VIOLATION            | The modified partition count or affinity does not satisfy the current instance distribution. Please remove the related instances before retrying. |
| 400              | INVALID\_PLACEMENT\_GROUP\_PARTITION\_NUM\_EXCEED\_LIMIT    | The number of partitions in the placement group exceeds the limit.                                                                                |
