# DetachFromPolicy

## 1. API Description

This API (DetachFromPolicy) is used to remove a protection strategy from a protection target.

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type            | Description                 |
| -------------- | -------- | --------------- | --------------------------- |
| policyId       | Yes      | String          | Protection strategy ID.     |
| ipv4IdList     | No       | Array of String | List of protection targets. |

## 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" %}
**Remove a protection strategy from a protection target.**

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

Request：
{
    "policyId": "<policyId>",
    "ipv4IdList": ["eipId1","eipId2"]
}

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](https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk)，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](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode).

| HTTP Status Code | Error Code                                        | Description                                                        |
| ---------------- | ------------------------------------------------- | ------------------------------------------------------------------ |
| 404              | INVALID\_DDOS\_POLICY\_IP\_NOT\_CONFIG            | No IPv4 or IPv6 address is configured for the protection strategy. |
| 404              | INVALID\_DDOS\_POLICY\_NOT\_FOUND                 | The protection strategy does not exist.                            |
| 404              | INVALID\_EIP\_NOT\_FOUND                          | Elastic IP does not exist.                                         |
| 404              | INVALID\_IPV6\_NOT\_FOUND                         | The IPv6 address is not found.                                     |
| 400              | INVALID\_IPV6\_STATUS                             | The IPv6 address is not active.                                    |
| 400              | OPERATION\_DENIED\_EIP\_DDOS\_POLICY\_NOT\_FOUND  | The elastic IP is not linked to a protection strategy.             |
| 500              | OPERATION\_DENIED\_EIP\_STATUS\_NOT\_SUPPORT      | Operation is not supported for the elastic IP in current status.   |
| 400              | OPERATION\_DENIED\_IPV6\_DDOS\_POLICY\_NOT\_FOUND | No protection strategy is linked to the IPv6 address.              |
