---
title: pydo.firewalls.delete_rules()
description: Remove Rules from a Firewall
product: Reference
url: https://docs.digitalocean.com/reference/pydo/reference/firewalls/delete_rules/
last_updated: "2026-11-06"
---

> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document).

# pydo.firewalls.delete_rules()

Generated on 6 Nov 2026 from `pydo` version [`v0.45.0`](https://github.com/digitalocean/pydo/releases/tag/v0.45.0)

## Usage

```python
client.firewalls.delete_rules(
    firewall_id="bb4b2611-3d72-467b-8602-280330ecd65c",
    body={
        "inbound_rules": [...],
        "outbound_rules": [...],
    },
)
```

Returns `None` Raises `HttpResponseError`

## Description

To remove access rules from a firewall, send a DELETE request to [`/v2/firewalls/{firewall_id}/rules`](https://docs.digitalocean.com/reference/api/reference/firewalls/index.html.md). The body of the request may include an `inbound_rules` and/or `outbound_rules` attribute containing an array of rules to be removed.

No response body will be sent back, but the response code will indicate success. Specifically, the response code will be a 204, which means that the action was successful with no returned body data.

## Parameters

`firewall_id` string required

A unique ID that can be used to identify and reference a firewall.

`inbound_rules` array of objects or null optional

## Show child properties

`protocol` string required

The type of traffic to be allowed. This may be one of `tcp`, `udp`, or `icmp`.

One of: `tcp`, `udp`, `icmp`

`ports` string required

Example: `8000`

The ports on which traffic will be allowed specified as a string containing a single port, a range (e.g. "8000-9000"), or "0" when all ports are open for a protocol. For ICMP rules this parameter will always return "0".

`action` string optional

The action to be taken when traffic matches the rule. This may be one of `allow` or `deny`. For backward compatibility, this field is optional. When not set, it defaults to `allow`.

One of: `allow`, `deny`

Default: `allow`

`sources` object required

### Show child properties

`addresses` array of strings optional

Example: `['1.2.3.4', '18.0.0.0/8']`

An array of strings containing the IPv4 addresses, IPv6 addresses, IPv4 CIDRs, and/or IPv6 CIDRs to which the firewall will allow traffic.

`droplet_ids` array of integers optional

Example: `[8043964]`

An array containing the IDs of the Droplets to which the firewall will allow traffic.

`load_balancer_uids` array of strings optional

Example: `['4de7ac8b-495b-4884-9a69-1050c6793cd6']`

An array containing the IDs of the load balancers to which the firewall will allow traffic.

`kubernetes_ids` array of strings optional

Example: `['41b74c5d-9bd0-5555-5555-a57c495b81a3']`

An array containing the IDs of the Kubernetes clusters to which the firewall will allow traffic.

`tags` object optional

`outbound_rules` array of objects or null optional

## Show child properties

`protocol` string required

The type of traffic to be allowed. This may be one of `tcp`, `udp`, or `icmp`.

One of: `tcp`, `udp`, `icmp`

`ports` string required

Example: `8000`

The ports on which traffic will be allowed specified as a string containing a single port, a range (e.g. "8000-9000"), or "0" when all ports are open for a protocol. For ICMP rules this parameter will always return "0".

`action` string optional

The action to be taken when traffic matches the rule. This may be one of `allow` or `deny`. For backward compatibility, this field is optional. When not set, it defaults to `allow`.

One of: `allow`, `deny`

Default: `allow`

`destinations` object required

### Show child properties

`addresses` array of strings optional

Example: `['1.2.3.4', '18.0.0.0/8']`

An array of strings containing the IPv4 addresses, IPv6 addresses, IPv4 CIDRs, and/or IPv6 CIDRs to which the firewall will allow traffic.

`droplet_ids` array of integers optional

Example: `[8043964]`

An array containing the IDs of the Droplets to which the firewall will allow traffic.

`load_balancer_uids` array of strings optional

Example: `['4de7ac8b-495b-4884-9a69-1050c6793cd6']`

An array containing the IDs of the load balancers to which the firewall will allow traffic.

`kubernetes_ids` array of strings optional

Example: `['41b74c5d-9bd0-5555-5555-a57c495b81a3']`

An array containing the IDs of the Kubernetes clusters to which the firewall will allow traffic.

`tags` object optional

## Request Sample

## Show Request Sample

```python
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "inbound_rules": [
    {
      "protocol": "tcp",
      "ports": "3306",
      "action": "allow",
      "sources": {
        "droplet_ids": [
          49696269
        ]
      }
    }
  ],
  "outbound_rules": [
    {
      "protocol": "tcp",
      "ports": "3306",
      "action": "allow",
      "destinations": {
        "droplet_ids": [
          49696269
        ]
      }
    }
  ]
}

resp = client.firewalls.delete_rules(firewall_id="39fa4gz", body=req)
```

## More Information

See [`/v2/firewalls/{firewall_id}/rules`](https://docs.digitalocean.com/reference/api/reference/firewalls/index.html.md#firewalls_delete_rules) in the API reference for additional detail on responses, headers, parameters, and more.