Deletes a policy.
Note
- Before you delete a policy, you must delete all non-default versions of the policy. For more information about how to delete a policy version, see DeletePolicyVersion.
- Before you delete a policy, make sure that the policy is not referenced. This means that the policy is not attached to RAM users, RAM user groups, or RAM roles. For more information about how to detach a policy, see DetachPolicy.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | DeletePolicy |
The operation that you want to perform. Set the value to DeletePolicy. |
PolicyName | String | Yes | OSS-Administrator |
The name of the policy. The name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-). |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 898FAB24-7509-43EE-A287-086FE4C44394 |
The ID of the request. |
Examples
Sample requests
https://resourcemanager.aliyuncs.com/?Action=DeletePolicy
&PolicyName=OSS-Administrator
&<Common request parameters>
Sample success responses
XML
format
<DeletePolicyResponse>
<RequestId>898FAB24-7509-43EE-A287-086FE4C44394</RequestId>
</DeletePolicyResponse>
JSON
format
{
"RequestId": "898FAB24-7509-43EE-A287-086FE4C44394"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidParameter.PolicyName.InvalidChars | The policy name contains invalid characters. It must only contain upper or lower case letters, numbers, and dash (-). | The error message returned because the policy name contains invalid characters. The policy name can only contain letters, digits, and hyphens (-). |
400 | InvalidParameter.PolicyName.Length | The length of the policy name is invalid. It must be 1 to 64 characters in length. | The error message returned because the length of the policy name is invalid. The policy name must be 1 to 64 characters in length. |
404 | EntityNotExist.Policy | The policy does not exist. | The error message returned because the policy does not exist. |
409 | DeleteConflict.Policy.User | Before deleting the policy, it may not be attached to any user. | The error message returned because the policy is attached to a RAM user. Detach the policy from the RAM user first. |
409 | DeleteConflict.Policy.Group | The policy cannot be attached to any group when you delete it. | The error message returned because the policy is attached to a RAM user group. Detach the policy from the RAM user group first. |
409 | DeleteConflict.Policy.Version | You must delete all non-default versions before you delete the policy. | The error message returned because all non-default versions of the policy are not deleted. Delete the non-default versions first. |
For a list of error codes, visit the API Error Center.