Create network rule

Create a new firewall rule on your server.


POST/api/servers/{server}/network-rules

Create a network rule

This endpoint allows you to create a new firewall rule on your server.

Required attributes

  • Name
    name
    Type
    string
    Description

    The rule name. Max: 100 characters.

  • Name
    port
    Type
    string
    Description

    The port number (1-65535). Can be a range like 1000:2000.

  • Name
    type
    Type
    string
    Description

    The protocol type: tcp or udp.

  • Name
    rule_type
    Type
    string
    Description

    Whether to allow or deny traffic.

Optional attributes

  • Name
    from_ip_address
    Type
    string
    Description

    IP address that is allowed (or denied) to interact with this port.

Request

POST
/api/servers/{server}/network-rules
curl -X POST "https://ploi.io/api/servers/{server}/network-rules" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "name": "My Rule",
    "port": "1000",
    "type": "tcp",
    "rule_type": "allow",
    "from_ip_address": "127.0.0.1"
  }'

Response

{
  "data": {
    "id": 1,
    "name": "My Rule",
    "port": 1000,
    "from_ip_address": "127.0.0.1",
    "rule_type": "allow",
    "status": "created",
    "created_at": "2021-01-21 09:09:59"
  }
}