# Create

Create a new firewall rule for the server.

# HTTP Request:

POST https://api.serveravatar.com/organizations/{organization}/servers/{server}/firewall-rules

# Parameter:

Parameters Required Type Description
start_port Yes Numeric Select Firewall Start Port Between 1 to 65534 on your server.
end_port No String Firewall End port, If available select port between 1 to 65534 on your server.
traffic Yes String allow or deny traffic.
protocol Yes String Select any one protocol: all, tcp or udp.
ip No IP IPv4 address, If available.

# Curl Request example:

curl --request POST \
  --url "https://api.serveravatar.com/organizations/5/servers/15/firewall-rules" \
  --header 'content-type: application/json' \
  --header 'accept: application/json' \
  --header 'Authorization: <YOUR API TOKEN>' \
  --data '{
        "start_port": 45,
        "end_port": 450,
        "traffic": "allow",
        "protocol": "udp",
        "ip": "207.148.86.87"
  }'

# Response:

# Firewall Create:

  • 200 (Ok)
{
  "firewallRule": {
    "id": 896,
    "server_id": 15,
    "start_port": 45,
    "end_port": 450,
    "protocol": "udp",
    "traffic": 1,
    "ip": "207.148.86.87",
    "created_at": "2022-02-16 15:44:45",
    "updated_at": "2022-02-16 15:44:45"
  },
  "message": "Rule has been successfully added to firewall!"
}

# Organization Not Found

  • 404 (Not Found)
{
    "message": "Organization not found!"
}

# Server Not Found

  • 404 (Not Found)
{
    "message": "Server not found!"
}

# End Port Range Higher than Start Port

  • 500 (Internal Server Error)
{
    "message": "Ending port of the range must be higher than the starting port."
}

# End Port Range Specify TCP or UDP

  • 500 (Internal Server Error)
{
    "message": "You must specify TCP or UDP protocol while specifying port ranges."
}

# Firewall Not Enabled

  • 500 (Internal Server Error)
{
    "message": "Firewall not enabled!"
}

# Server Error

  • 500 (Internal Server Error)
{
    "message": "Something went really wrong!"
}
Last Updated: 5/2/2023, 12:48:26 PM