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

# ReleaseInstances

## 1. API Description

This API (ReleaseInstances) is used to release one or more elastic compute instances.

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

* This interface is asynchronous. The request to release instances returns immediately after it is sent successfully, but the operation is not completed at that point. The instance status can be queried by calling the [DescribeInstances](/api-reference/zec/instance/describeinstances.md) interface. When an instance no longer appears in the query result, it has been destroyed completely. No operation can be performed on the instance during the release.
* In general, the resources are recycled directly after an instance is released and cannot be recovered. For some accounts, a released instance first enters the `RECYCLED` (recycle bin) status and is retained for a period of time, during which you can call this interface again to delete it completely. Please proceed with caution.
* Batch operations are supported. Up to 100 instances can be operated on in each request.
* When `dependResource` is `true` (default), the elastic IPs (non-default IPs), detachable disks, and non-primary network interfaces associated with the instance are released at the same time. When it is `false`, only the instance itself is released, and the associated resources are retained and continue to be billed.
  {% 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 to be released.</p><p>It can be obtained by calling <a href="/api-reference/zec/instance/describeinstances.md">DescribeInstances</a>.</p>                                                                            |
| dependResource | No       | Boolean         | <p>Whether to release associated resources synchronously when releasing an instance.</p><p>true: Synchronous release (default); false: Release only the instance itself, while retaining the associated resources.</p><p>Default value: true</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> |
| instanceIds    | Array of String | List of instance IDs that failed the operation.                                                                       |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Release instances in batches (associated resources are released at the same time, which is the default behavior).**

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

Request：
{
  "instanceIds": [
    "instanceId1",
    "instanceId2"
  ]
}

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

**2. Release only the instances themselves, and retain the associated resources (EIPs, disks, and network interfaces).**

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

Request：
{
  "instanceIds": [
    "instanceId1"
  ],
  "dependResource": false
}

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

{% 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 |
| ---------------- | ---------- | ----------- |
