Deleting a Firewall Rule via API

Trying to delete rule via api but the rule cannot be deleted and is only being deactivated,

Here’s a example of how i’m trying to delete a firewall rule using fetch in JavaScript:

async function deleteFirewallRule(zoneId, ruleId, apiToken) {
const url = https://api.cloudflare.com/client/v4/zones/${zoneId}/firewall/rules/${ruleId};

try {
const response = await fetch(url, {
method: ‘DELETE’,
headers: {
‘Authorization’: Bearer ${apiToken},
‘Content-Type’: ‘application/json’,
},
});

if (!response.ok) {
  throw new Error(`Network response was not ok: ${response.statusText}`);
}

const data = await response.json();
console.log(data); // Check the response data for success or explanation

} catch (error) {
console.error(‘Error:’, error);
}
}

const zoneId = ‘your_zone_id’;
const ruleId = ‘the_rule_id_to_delete’;
const apiToken = ‘your_api_token’;
deleteFirewallRule(zoneId, ruleId, apiToken);

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.