dots.v2.firewalls.post()

Generated on 13 Nov 2026 from DoTs version v1.24.0

Usage

client.v2.firewalls.post(body: Firewall, requestConfiguration?: RequestConfiguration<object>): Promise<undefined | FirewallsPostResponse>

Description

To create a new firewall, send a POST request to /v2/firewalls. The request must contain at least one inbound or outbound access rule.

Parameters

id string optional read-only

Example: bb4b2611-3d72-467b-8602-280330ecd65c

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

status string optional read-only

A status string indicating the current state of the firewall. This can be "waiting", "succeeded", or "failed".

One of: waiting, succeeded, failed

createdAt string optional read-only

Example: 2020-05-23T21:24:00Z

A time value given in ISO8601 combined date and time format that represents when the firewall was created.

pendingChanges array of objects optional read-only

Example: [{"droplet_id": 8043964, "removing": false, "status": "waiting"}]

An array of objects each containing the fields "droplet_id", "removing", and "status". It is provided to detail exactly which Droplets are having their security policies updated. When empty, all changes have been successfully applied.

Show child properties
dropletId integer optional

Example: 8043964

removing boolean optional

Example: false

status string optional

Example: waiting

name string required

Example: firewall

A human-readable name for a firewall. The name must begin with an alphanumeric character. Subsequent characters must either be alphanumeric characters, a period (.), or a dash (-).

dropletIds array of integers or null optional

Example: [8043964]

An array containing the IDs of the Droplets assigned to the firewall.

Requires droplet:read scope.

tags array of strings or null optional

Example: ["base-image", "prod"]

A flat array of tag names as strings to be applied to the resource. Tag names must exist in order to be referenced in a request.

Requires tag:create and tag:read scopes.

inboundRules 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

An object specifying locations from which inbound traffic will be accepted.

Additional nested properties are not shown.

outboundRules 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

An object specifying locations to which outbound traffic that will be allowed.

Additional nested properties are not shown.

Request Sample

Show Request Sample
import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
import {
    createDigitalOceanClient,
    DigitalOceanApiKeyAuthenticationProvider,
} from "@digitalocean/dots";

const authProvider = new DigitalOceanApiKeyAuthenticationProvider(process.env.DIGITALOCEAN_TOKEN!);
const adapter = new FetchRequestAdapter(authProvider);
const client = createDigitalOceanClient(adapter);

const response = await client.v2.firewalls.post({
    name: "firewall",
    inboundRules: [
        {
            protocol: "tcp",
            ports: "80",
            action: "allow",
            sources: {
                loadBalancerUids: [
                    "4de7ac8b-495b-4884-9a69-1050c6793cd6",
                ],
            },
        },
        {
            protocol: "tcp",
            ports: "22",
            action: "allow",
            sources: {
                tags: [
                    "gateway",
                ],
                addresses: [
                    "18.0.0.0/8",
                ],
            },
        },
    ],
    outboundRules: [
        {
            protocol: "tcp",
            ports: "80",
            action: "allow",
            destinations: {
                addresses: [
                    "0.0.0.0/0",
                    "::/0",
                ],
            },
        },
    ],
    dropletIds: [
        8043964,
    ],
});

Response Example

Show Response Example
{
  "firewall": {
    "id": "bb4b2611-3d72-467b-8602-280330ecd65c",
    "name": "firewall",
    "status": "waiting",
    "inbound_rules": [
      {
        "protocol": "tcp",
        "ports": "80",
        "action": "allow",
        "sources": {
          "load_balancer_uids": [
            "4de7ac8b-495b-4884-9a69-1050c6793cd6"
          ]
        }
      },
      {
        "protocol": "tcp",
        "ports": "22",
        "action": "allow",
        "sources": {
          "tags": [
            "gateway"
          ],
          "addresses": [
            "18.0.0.0/8"
          ]
        }
      }
    ],
    "outbound_rules": [
      {
        "protocol": "tcp",
        "ports": "80",
        "action": "allow",
        "destinations": {
          "addresses": [
            "0.0.0.0/0",
            "::/0"
          ]
        }
      }
    ],
    "created_at": "2017-05-23T21:24:00Z",
    "droplet_ids": [
      8043964
    ],
    "tags": [],
    "pending_changes": [
      {
        "droplet_id": 8043964,
        "removing": false,
        "status": "waiting"
      }
    ]
  }
}

More Information

See /v2/firewalls in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.