> 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/compute/vm/virtual-machine-instance/resetinstance.md).

# ResetInstance

## 1. API Description

This API (ResetInstance) is used to reset the operating system (OS) of an instance.

#### Prerequisites

* Query image: call [`DescribeImages`](/api-reference/compute/vm/image/describeimages.md) to check information on image.

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

* <mark style="color:blue;">If</mark> <mark style="color:blue;">`imageId`</mark> <mark style="color:blue;">is specified, it will be used for OS reset, otherwise the current image will be used for OS reset.</mark>
* <mark style="color:blue;">The system disk will be formatted and reset. Please ensure that there is no important files in the system disk.</mark>
* <mark style="color:blue;">If no password is specified, you will receive a random code in mailbox.</mark>
* <mark style="color:blue;">You can only perform this operation on instances whose status is</mark> <mark style="color:blue;">`STOPPED`</mark> <mark style="color:blue;">and are not in the recycle bin.</mark>
* <mark style="color:blue;">If the API is called successfully, the instance status will become</mark> <mark style="color:blue;">`REBUILDING`</mark><mark style="color:blue;">.</mark> <mark style="color:blue;">After the instance is reset, its status will become</mark> <mark style="color:blue;">`RUNNING`</mark> <mark style="color:blue;">again. You can use</mark> [<mark style="color:purple;">`DescribeInstancesStatus`</mark>](/api-reference/compute/vm/virtual-machine-instance/describeinstancesstatus.md) <mark style="color:blue;">to query the status of the instance.</mark>
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                          |
| -------------- | -------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| instanceId     | Yes      | String | <p>Instance ID(s).</p><p>To obtain the instance IDs, you can call DescribeInstances and look for instanceId in the response.</p>                                                                                                                                                                                                                                                                     |
| password       | No       | String | <p>Instance login password.</p><p>The parameter must be 8-16 characters, including:lowercase letters: \[a-z]uppercase letters: \[A-Z]digits: 0-9special characters: !@#$%^&\*\`\~()-+=You must and can only pass the value of either password or keyId.</p>                                                                                                                                          |
| keyId          | No       | String | <p>SSH key pair ID.</p><p>Your SSH key pair contains several public keys that can be placed on your server. You can access your instance with the private key. SSH key pairs and passwords cannot to set at the same time. SSH key pairs are not supported for Windows operating system.</p><p>For example: key-YWD2QFOl</p><p>You must and can only pass the value of either password or keyId.</p> |
| imageId        | No       | String | <p>Valid image ID.</p><p>To obtain the image IDs, you can call DescribeImages and look for imageId in the response. If no image is specified, the current image will be used for OS reset.</p>                                                                                                                                                                                                       |
| instanceName   | No       | String | Instance name to be displayed.                                                                                                                                                                                                                                                                                                                                                                       |
| wanName        | No       | String | <p>Public NIC name.</p><p>Only numbers and lowercase letters are allowed, starting with a letter with a length limit of 4 to 15 characters.</p><p>The default public NIC name is eth0.</p>                                                                                                                                                                                                           |
| lanName        | No       | String | <p>Private NIC name.</p><p>Only numbers and lowercase letters are allowed, starting with a letter with a length limit of 4 to 15 characters.</p><p>The default private NIC name is eth1.</p>                                                                                                                                                                                                         |
| initScript     | No       | String | Initialization script.                                                                                                                                                                                                                                                                                                                                                                               |

## 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" %}

**Reset an instance with a specified image and a specified password.**

```json
POST / HTTP/1.1
Host: console.zenlayer.com/api/v2/vm
Content-Type: application/json
X-ZC-Action: resetInstance

Request：
{
  "instanceId": "instanceId",
  "imageId": "img-xxxxxxxxx",
  "password": "Example+123"
}

Response:
{
  "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453",
  "response": {
    "requestId": "TC1748D3E-452D-4F74-8485-7AA73718E453"
  }
}
```

## 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.                             |
| 404              | INVALID\_IMAGE\_NOT\_FOUND                     | Image not found.                                     |
| 400              | INVALID\_PARAMETER\_VALUE\_PASSWORD\_MALFORMED | Invalid password.                                    |
| 404              | INVALID\_IMAGE\_SIZE\_EXCEED                   | Image size exceeds the storage space of system disk. |
| 403              | INVALID\_REGION\_SCRIPT\_NOT\_SUPPORT          | The region does not support scripts.                 |
| 403              | INVALID\_REGION\_SCRIPT\_EXCEED\_LENGTH        | The length of the region script exceeds 32kb.        |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
