Trouble removing IP address from Cloudflare list via API

I’m having issues deleting an IP from my Cloudflare list using their API. My code seems to return a success message, but the IP stays on the list. Here’s what I’ve tried:

$accountInfo = '...'
$targetIP = '4514a...'
$requestBody = @{
  entries = @(
    @{ identifier = $targetIP }
  )
}

$apiHeaders = @{
  Auth = 'Bearer ...'
  ContentType = 'application/json'
}
$response = Invoke-RestMethod -Method Remove `
  -Uri "https://api.cloudflare.com/client/v4/accounts/$accountInfo/rules/lists/$listInfo/entries" `
  -Headers $apiHeaders `
  -Body ($requestBody | ConvertTo-Json -Depth 5)

The API returns success, but nothing changes on the website. Is there a way to remove IPs using their address (like 192.168.1.1) instead of an ID? Any help would be great!

In my experience dealing with Cloudflare’s API, it can help to verify that the correct list identifier is being used. Sometimes the selected list does not match the one intended, making it appear as if the removal failed. Additionally, check that the IP address is formatted exactly as expected by Cloudflare, as even minor differences could lead to issues. Consider switching the HTTP method from Remove to DELETE since this may be required by the API. It is also important to ensure that your API token has the necessary administrative permissions. Finally, be aware that there might be a short delay before changes are reflected on the dashboard.

hey there, i’ve run into similar issues before. have u tried using the DELETE method instead of Remove? also, double-check ur API token permissions. sometimes cloudflare’s dashboard takes a bit to update after changes. if none of that works, maybe try removing by IP directly instead of identifier?

I’ve dealt with this exact issue before, and it can be frustrating. One thing that worked for me was using the ‘ip’ parameter instead of ‘identifier’ in the request body. Try modifying your code like this:

$requestBody = @{ 
  ip = $targetIP 
}

Also, make sure you’re using the correct list ID. Sometimes Cloudflare creates multiple lists, and you might be targeting the wrong one. Double-check this in your account settings.

If that doesn’t work, try clearing your browser cache or waiting a bit. Sometimes the changes take a while to propagate through Cloudflare’s system, even though the API returns a success message. Hope this helps!