> 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/modifyinstancesattribute.md).

# ModifyInstancesAttribute

## 1. API Description

This API (ModifyInstancesAttribute) is used to modify the attributes of one or more elastic compute instances. Only the instance name to be displayed can be modified for now.

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

* Batch operations are supported. Up to 100 instances can be operated on in each request.
* If any of the instance IDs does not exist, the operation fails immediately.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------- | -------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| instanceIds    | Yes      | Array of String | <p>ID list of the instances whose attributes are to be modified.</p><p>It can be obtained by calling <a href="/api-reference/zec/instance/describeinstances.md">DescribeInstances</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| instanceName   | Yes      | String          | <p>Instance name.</p><p>2 to 63 characters in length.</p><p>Only letters, digits, periods (.), underscores (\_), slashes (/) and hyphens (-) are supported, and it must start and end with a letter or a digit.</p><p>When modifying multiple instances at a time, you can specify a pattern string \[begin\_number,bits]. The instances are numbered in the order of the instanceIds list.</p><p>begin\_number: the starting value of the ordered number, value range: \[0,99999].</p><p>bits: the number of digits occupied by the ordered number, value range: \[1,6]. It is padded with leading zeros when the value has fewer digits, and it is not truncated when the value exceeds the specified digits.</p><p>Note that spaces are not allowed in the pattern string.</p><p>For example, when modifying 2 instances with server-\[3,3] specified, the instance names are server-003 and server-004.</p><p>Multiple pattern strings are supported, such as server-\[3,3]-\[1,1].</p><p>When no pattern string is specified, all the instances are renamed to the same name.</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. Batch modify the names of instances.**

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

Request：
{
  "instanceIds": [
    "instanceId1",
    "instanceId2"
  ],
  "instanceName": "Test-Instance"
}

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

**2. Batch modify the names of instances and append ordered numbers in sequence.**

The names of instanceId1, instanceId2 and instanceId3 are modified to Test-Instance-1, Test-Instance-2 and Test-Instance-3 in sequence.

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

Request：
{
  "instanceIds": [
    "instanceId1",
    "instanceId2",
    "instanceId3"
  ],
  "instanceName": "Test-Instance-[1,1]"
}

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\_INSTANCE\_NOT\_FOUND                               | Instance not found.                                    |
| 400              | INVALID\_PARAMETER\_INSTANCE\_NAME\_MALFORMED               | Invalid instance name format.                          |
| 400              | INVALID\_PARAMETER\_INSTANCE\_NAME\_EXCEED                  | Instance name exceeds the maximum limit.               |
| 400              | INVALID\_PARAMETER\_INSTANCE\_NAME\_EXCEED\_MINIMUM\_LENGTH | Instance name should be larger than the minimum limit. |
