# add_rule
The EvoShield add_rule POST endpoint adds a particular EvoShield rule/profile to the specified IP address
Parameters
account
: The account key - which can be found in the Settings area of the Evolution Host client area: https://evolution-host.com/controlPanelservice_key
: The unique key for the particular Evolution Host service being used in this API call - Can be found by using the /list_services API endpointip
: The IPv4 address of the tunnel or VPS the rule should be added toapp_code
: The unique application/game short code for the particular profile the rule is being added for - Can be found using the list_evoshield_profiles API endpointport
: The main server port for the game/application - The default port can be found using the list_evoshield_profiles API endpoint however any port can be specifiedselected_protocol
: (optional - cannot be changed for some games/apps, if not specified the default protocol will be used) The default protocol (UDP or TCP) for the main port - The main port default protocol can be found using the list_evoshield_profiles API endpointextra_ports
: (optional - If no other rules are occupying any of the default extra_ports, this parameter is not required and the default ones will be set.) An array of additional ports the rule should apply to. Some games/apps require additional ports to function correctly - The list of default additional ports can be found using the list_evoshield_profiles API endpoint$url = "https://evolution-host.com/api.php";
$ip = '123.123.123.123';
$port = 7777;
$app_code = 'conan_exiles';
$extra_ports = array(
'Query' => ['port' => 47013, 'protocol' => 'udp'],
'RCON' => ['port' => 44019, 'protocol' => 'tcp'],
'Pinger' => ['port' => 42018, 'protocol' => 'udp'],
'Download' => ['port' => 41017, 'protocol' => 'tcp'],
);
$extra_ports = json_encode($extra_ports);
$postData = http_build_query([
'account' => 'YOUR_ACCOUNT_KEY',
'service_key' => 'YOUR_SERVICE_KEY',
'action' => 'add_rule',
'ip' => $ip,
'app_code' => $app_code,
'extra_ports' => $extra_ports,
'port' => $port,
]);
$headers = array(
'http' => array(
'method' => "POST",
'ignore_errors' => true,
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'content' => $postData,
),
);
$api_context = stream_context_create($headers);
$result = file_get_contents($url, false, $api_context);
$result = json_decode($result);
echo '<pre>' . json_encode($result, JSON_PRETTY_PRINT) . '</pre>';
Example Response
The Conan Exiles DDoS Protection profile has been added to port 7777. Enjoy your advanced Evolution Host Conan Exiles DDoS protection!
$url = "https://evolution-host.com/api.php";
$postData = http_build_query([
'account' => 'YOUR_ACCOUNT_KEY',
'service_key' => 'YOUR_SERVICE_KEY',
'action' => 'add_rule',
'ip' => '123.123.123.123',
'app_code' => 'openvpn',
'port' => 1194,
'selected_protocol' => 'UDP',
]);
$headers = array(
'http' => array
(
'method' => "POST",
'ignore_errors' => true,
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'content' => $postData,
),
);
$api_context = stream_context_create($headers);
$result = file_get_contents($url, false, $api_context);
$result = json_decode($result);
echo '<pre>' . json_encode($result, JSON_PRETTY_PRINT) . '</pre>';
Example Response
The OpenVPN DDoS Protection profile has been added to port 1194. Enjoy your advanced Evolution Host OpenVPN DDoS protection!