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

# ModifyInstanceType

## 1. API Description

This API (ModifyInstanceType) is used to changes the instance type of the specified elastic compute instance.

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

* This interface is asynchronous. The request to change the instance type returns immediately after it is sent successfully, but the operation is not completed at that point. The operation result can be queried by calling the [DescribeInstancesStatus](/api-reference/zec/instance/describeinstancesstatus.md) interface: if the instance status (`instanceStatus`) changes from `RESIZING` to `STOPPED`, the instance type is changed successfully. No operation can be performed on the instance during the change.
* This operation can be performed only on instances in the `STOPPED` status.
* The `instanceType` of a VM instance is an instance type ID, such as `z2a.cpu.4`; the `instanceType` of a GPU instance is a GPU instance type ID, such as `z3a.g.C49.c8m32.1`; the `instanceType` of an accelerator instance is an accelerator instance type ID, such as `z2a.v.T1U.c16m64.1`.
* Changing the type of an accelerator instance can only adjust the CPU, memory, and number of cards. The accelerator card model cannot be changed through a type change.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                         |
| -------------- | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| instanceId     | Yes      | String | <p>ID of the instance to be changed.</p><p>It can be obtained by calling <a href="/api-reference/zec/instance/describeinstances.md">DescribeInstances</a>.</p>                                                                                                                                                                                                                                      |
| instanceType   | Yes      | String | <p>Target instance type to change to.</p><p>The value for a regular instance can be obtained through <a href="/api-reference/zec/instance/describezoneinstanceconfiginfos.md">DescribeZoneInstanceConfigInfos</a>, and the value for a GPU instance can be obtained through <a href="/api-reference/zec/instance/describezonegpuinstanceconfiginfos.md">DescribeZoneGpuInstanceConfigInfos</a>.</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 type of a VM instance.**

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

Request：
{
  "instanceId": "instanceId",
  "instanceType": "z2a.cpu.4"
}

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

**2. Modify the type of a GPU instance.**

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

Request：
{
  "instanceId": "instanceId",
  "instanceType": "z3a.g.C49.c8m32.1"
}

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

**3. Modify the type of an accelerator instance.**

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

Request：
{
  "instanceId": "instanceId",
  "instanceType": "z2a.v.T1U.c16m64.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.                                                                 |
| 404              | INVALID\_INSTANCE\_TYPE\_NOT\_FOUND                  | Instance type not found.                                                            |
| 400              | OPERATION\_DENIED\_INSTANCE\_STATUS\_NOT\_SUPPORT    | Current instance state does not allow this operation.                               |
| 400              | OPERATION\_FAILED\_INSTANCE\_TYPE\_UNSUPPORTED       | The specified instance type is not supported for this instance.                     |
| 400              | OPERATION\_DENIED\_INSTANCE\_TYPE\_SAME\_AS\_CURRENT | The target instance type is the same as the current one. No modification is needed. |
| 400              | INVALID\_IMAGE\_SPEC\_NOT\_SUPPORT                   | The minimum specification required by the image exceeds the current instance type.  |
