# ModifyInstanceType

## 1. API Description

This API (ModifyInstanceType) is used to modify the specifications of a virtual machine instance.

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

* <mark style="color:blue;">You can only perform this operation on instances whose status is</mark> <mark style="color:blue;">`RUNNING`</mark> <mark style="color:blue;">or</mark><mark style="color:blue;">`STOPPED`</mark><mark style="color:blue;">.</mark>
* <mark style="color:blue;">If the</mark> <mark style="color:blue;">`internetChargeType`</mark> <mark style="color:blue;">of your instance is</mark> <mark style="color:blue;">`PREPAID:`</mark>
  * <mark style="color:blue;">Upgrade (target > current) operation will generate an order to be paid and deduct the amount required for this instance purchase. The request takes effect immediately.</mark>
  * <mark style="color:blue;">Downgrade (target < current) operation will generate an order for the next billing cycle and will take effect by then.</mark>
* <mark style="color:blue;">If the</mark> <mark style="color:blue;">`internetChargeType`</mark> <mark style="color:blue;">of your instance is</mark> <mark style="color:blue;">`POSTPAID`</mark><mark style="color:blue;">:</mark>
  * <mark style="color:blue;">The change takes immediate effect.</mark>
* <mark style="color:blue;">This API is an async API. Use</mark> <mark style="color:blue;">`DescribeInstanceTypeStatus`</mark> <mark style="color:blue;">to query specifications of an instance.</mark>
* <mark style="color:blue;">Rules of specification change:</mark>
  * <mark style="color:blue;">Changes between models with same series are allowed. For example, change the model of</mark> <mark style="color:blue;">`c.1c2g`</mark> <mark style="color:blue;">to</mark> <mark style="color:blue;">`c.2c4g`</mark><mark style="color:blue;">.</mark>
  * <mark style="color:blue;">Some changes between models with different series are allowed. For example, changes between</mark> <mark style="color:blue;">`c`</mark><mark style="color:blue;">,</mark> <mark style="color:blue;">`g`</mark> <mark style="color:blue;">and</mark> <mark style="color:blue;">`m`</mark> <mark style="color:blue;">series.</mark>
  * <mark style="color:blue;">Some changes between models with different series are not allowed. For example, changes between</mark> <mark style="color:blue;">`s`</mark> <mark style="color:blue;">and</mark> <mark style="color:blue;">`h`</mark> <mark style="color:blue;">series.</mark>
    {% 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 modified.</p><p>To obtain the instance ID, you can call DescribeInstances and look for instanceId in the response.</p>             |
| instanceTypeId | Yes      | String | <p>ID of the target model to change.</p><p>To obtain the model ID, you can call DescribeZoneInstanceConfigInfos and look for instanceType in the response.</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> |
| orderNumber    | String | Number of order.                                                                                                      |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Modify the model of an instance.**

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

Request：
{
  "instanceId": "instanceId",
  "instanceTypeId": "c.2c4g"
}

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

{% 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 does not exist.                                                 |
| 400              | INVALID\_INSTANCE\_TYPE\_NOT\_CHANGED            | Instance model does not changed.                                         |
| 400              | OPERATION\_FAILED\_INSTANCE\_TYPE\_UNSUPPORTED   | Unsupported model for the current instance.                              |
| 403              | OPERATION\_DENIED\_INSTANCE\_EXIST\_PLAN         | A scheduling change exists.                                              |
| 403              | OPERATION\_DENIED\_INSTANCE\_PLAN\_PROCESSING    | A processing change exists.                                              |
| 400              | UNSUPPORTED\_OPERATION\_INSTANCE\_STATUS         | Only operations on instances in RUNNING or STOPPED status are supported. |
| 400              | UNSUPPORTED\_OPERATION\_ZONE\_NOT\_SUPPORT       | Operations not supported in current zone.                                |
| 400              | UNSUPPORTED\_OPERATION\_INSTANCE\_BEING\_RECYCLE | Operations on instances in recycle bin are not supported.                |
| 404              | INVALID\_PRODUCT\_NOT\_FOUND                     | Model does not exist.                                                    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/api-reference/compute/vm/virtual-machine-instance/modifyinstancetype.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
