> 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/security-group/deletesecuritygroup.md).

# DeleteSecurityGroup

## 1. API Description

This API (DeleteSecurityGroup) is used to delete a security group.

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

* <mark style="color:blue;">Operations on security groups with instances in it are not supported. You can use</mark> [<mark style="color:purple;">`DescribeSecurityGroups`</mark>](/api-reference/compute/vm/security-group/describesecuritygroups.md) <mark style="color:blue;">to query the status of the security group.</mark>
* <mark style="color:blue;">Only operations on security groups in the status of</mark> <mark style="color:blue;">`AVAILABLE`</mark> <mark style="color:blue;">or</mark> <mark style="color:blue;">`FAIL`</mark> <mark style="color:blue;">are supported.</mark>
* <mark style="color:blue;">Deleting is not supported for default security group.</mark>
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name  | Required | Type   | Description        |
| --------------- | -------- | ------ | ------------------ |
| securityGroupId | Yes      | String | Security group ID. |

## 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" %}
**Delete a security group.**

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

Request:
{
  "securityGroupId": "your-security-group-id"
}

Response:
{
  "requestId": "T980F9D21-D7E4-4C6D-8B79-91A15861FB05",
  "response": {
    "requestId": "T980F9D21-D7E4-4C6D-8B79-91A15861FB05"
  }
}
```

{% 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\_SECURITY\_GROUP\_NOT\_FOUND                              | Security group does not exist.                                          |
| 403              | OPERATION\_DENIED\_SECURITY\_GROUP\_STATUS\_NOT\_SUPPORT          | Operations on the security group with current status are not supported. |
| 403              | OPERATION\_DENIED\_SECURITY\_GROUP\_EXIST\_INSTANCE               | Operations on security groups with instances in it are not supported.   |
| 403              | OPERATION\_DENIED\_SECURITY\_GROUP\_EXIST\_PRE\_PRODUCT\_INSTANCE | Instance is being created.                                              |
| 403              | OPERATION\_DENIED\_DEFAULT\_SECURITY\_GROUP\_NOT\_SUPPORT         | Operations on the default security groups are not supported.            |
