Skip to content

Base API

Bunny Shield: a powerful, next-generation web security suite—built to democratize access to serious, scalable protection that supports you from the moment you go live.

Setup

<?php

require 'vendor/autoload.php';

use ToshY\BunnyNet\ShieldAPI;
use ToshY\BunnyNet\Client\BunnyClient;

$bunnyClient = new BunnyClient(
    client: new \Symfony\Component\HttpClient\Psr18Client(),
);

// Provide the account API key.
$shieldApi = new ShieldAPI(
    apiKey: '2cebf4f8-4bff-429f-86f6-bce2c2163d7e89fb0a86-a1b2-463c-a142-11eba8811989',
    client: $bunnyClient,
);

Usage

Shield Zone

List Shield Zones

$shieldApi->listShieldZones(
    query: [
        'page' => 1,
        'perPage' => 1000,
    ],
);

Get Shield Zone

$shieldApi->getShieldZone(
    shieldZoneId: 1,
);

Get Shield Zone (by PullZoneId)

$shieldApi->getShieldZoneByPullZoneId(
    pullZoneId: 1,
);

Create Shield Zone

$shieldApi->createShieldZone(
    body: [
        'pullZoneId' => 1,
        'shieldZone' => [
            'shieldZoneId' => 2,
            'premiumPlan' => false,
            'learningMode' => true,
            'learningModeUntil' => 'Y-m-d\TH:i:s',
            'wafEnabled' => true,
            'wafExecutionMode' => 1,
            'wafDisabledRules' => [],
            'wafLogOnlyRules' => [],
            'wafRequestHeaderLoggingEnabled' => true,
            'wafRequestIgnoredHeaders' => [],
            'wafRealtimeThreatIntelligenceEnabled' => false,
            'wafProfileId' => 1,
            'wafEngineConfig' => [],
            'dDoSShieldSensitivity' => 1,
            'dDoSExecutionMode' => 1,
            'dDoSChallengeWindow' => 1,
            'blockVpn' => false,
            'blockTor' => false,
            'blockDatacentre' => false,
            'whitelabelResponsePages' => false,
        ],
    ],
);

Note

  • The key shieldZoneId is not needed or required when creating a shield zone.

Update Shield Zone

$shieldApi->updateShieldZone(
body: [
        'shieldZoneId' => 2,
        'shieldZone' => [
            'shieldZoneId' => 2,
            'premiumPlan' => false,
            'learningMode' => true,
            'learningModeUntil' => 'Y-m-d\TH:i:s',
            'wafEnabled' => true,
            'wafExecutionMode' => 1,
            'wafDisabledRules' => [],
            'wafLogOnlyRules' => [],
            'wafRequestHeaderLoggingEnabled' => true,
            'wafRequestIgnoredHeaders' => [],
            'wafRealtimeThreatIntelligenceEnabled' => false,
            'wafProfileId' => 1,
            'wafEngineConfig' => [],
            'dDoSShieldSensitivity' => 1,
            'dDoSExecutionMode' => 1,
            'dDoSChallengeWindow' => 1,
            'blockVpn' => false,
            'blockTor' => false,
            'blockDatacentre' => false,
            'whitelabelResponsePages' => false,
        ],
    ],
);

WAF

List WAF Rules

$shieldApi->listWafRules();

Review Triggered Rules

$shieldApi->reviewTriggeredRules(
    shieldZoneId: 1,
);

Review Triggered Rule

$shieldApi->reviewTriggeredRule(
    shieldZoneId: 1,
    body: [
        'ruleId' => '46d1703e-7d63-4138-83b1-78695bee5a07',
        'action' => 2,
    ],
);

Shield AI Triggered Rule Recommendation

$shieldApi->reviewTriggeredRuleAiRecommendation(
    shieldZoneId: 1,
    ruleId: '46d1703e-7d63-4138-83b1-78695bee5a07',
);

List Custom WAF Rules

$shieldApi->listCustomWafRules(
    shieldZoneId: 1,
    query: [
        'page' => 1,
        'perPage' => 1000,
    ],
);

Get Custom WAF Rule

$shieldApi->getCustomWafRule(
    id: 1,
);

Update Custom WAF Rule

$shieldApi->updateCustomWafRule(
    id: 1,
    body: [
        'ruleName' => 'string',
        'ruleDescription' => 'string',
        'ruleConfiguration' => [
            'actionType' => 1,
            'variableTypes' => [
                'REQUEST_URI' => 'string',
                'REQUEST_URI_RAW' => 'string',
                'ARGS' => 'string',
                'ARGS_COMBINED_SIZE' => 'string',
                'ARGS_GET' => 'string',
                'ARGS_GET_NAMES' => 'string',
                'ARGS_POST' => 'string',
                'ARGS_POST_NAMES' => 'string',
                'FILES_NAMES' => 'string',
                'GEO' => 'string',
                'REMOTE_ADDR' => 'string',
                'QUERY_STRING' => 'string',
                'REQUEST_BASENAME' => 'string',
                'REQUEST_BODY' => 'string',
                'REQUEST_COOKIES_NAMES' => 'string',
                'REQUEST_COOKIES' => 'string',
                'REQUEST_FILENAME' => 'string',
                'REQUEST_HEADERS_NAMES' => 'string',
                'REQUEST_HEADERS' => 'string',
                'REQUEST_LINE' => 'string',
                'REQUEST_METHOD' => 'string',
                'REQUEST_PROTOCOL' => 'string',
                'RESPONSE_BODY' => 'string',
                'RESPONSE_HEADERS' => 'string',
                'RESPONSE_STATUS' => 'string',
            ],
            'operatorType' => 0,
            'severityType' => 0,
            'transformationTypes' => [1],
            'value' => 'string',
            'requestCount' => 0,
            'timeframe' => 1,
            'blockTime' => 30,
        ],
    ]
);

Update Custom WAF Rule (PATCH)

$shieldApi->updateCustomWafRuleByPatch(
    id: 1,
    body: [
        'ruleName' => 'string',
        'ruleDescription' => 'string',
        'ruleConfiguration' => [
            'actionType' => 1,
            'variableTypes' => [
                'REQUEST_URI' => 'string',
                'REQUEST_URI_RAW' => 'string',
                'ARGS' => 'string',
                'ARGS_COMBINED_SIZE' => 'string',
                'ARGS_GET' => 'string',
                'ARGS_GET_NAMES' => 'string',
                'ARGS_POST' => 'string',
                'ARGS_POST_NAMES' => 'string',
                'FILES_NAMES' => 'string',
                'GEO' => 'string',
                'REMOTE_ADDR' => 'string',
                'QUERY_STRING' => 'string',
                'REQUEST_BASENAME' => 'string',
                'REQUEST_BODY' => 'string',
                'REQUEST_COOKIES_NAMES' => 'string',
                'REQUEST_COOKIES' => 'string',
                'REQUEST_FILENAME' => 'string',
                'REQUEST_HEADERS_NAMES' => 'string',
                'REQUEST_HEADERS' => 'string',
                'REQUEST_LINE' => 'string',
                'REQUEST_METHOD' => 'string',
                'REQUEST_PROTOCOL' => 'string',
                'RESPONSE_BODY' => 'string',
                'RESPONSE_HEADERS' => 'string',
                'RESPONSE_STATUS' => 'string',
            ],
            'operatorType' => 0,
            'severityType' => 0,
            'transformationTypes' => [1],
            'value' => 'string',
            'requestCount' => 0,
            'timeframe' => 1,
            'blockTime' => 30,
        ],
    ]
);

Delete Custom WAF Rule

$shieldApi->deleteCustomWafRule(
    id: 1,
);

Create Custom WAF Rule

$shieldApi->createCustomWafRule(
    body: [
        'shieldZoneId' => 1,
        'ruleName' => 'string',
        'ruleDescription' => 'string',
        'ruleConfiguration' => [
            'actionType' => 1,
            'variableTypes' => [
                'REQUEST_URI' => 'string',
                'REQUEST_URI_RAW' => 'string',
                'ARGS' => 'string',
                'ARGS_COMBINED_SIZE' => 'string',
                'ARGS_GET' => 'string',
                'ARGS_GET_NAMES' => 'string',
                'ARGS_POST' => 'string',
                'ARGS_POST_NAMES' => 'string',
                'FILES_NAMES' => 'string',
                'GEO' => 'string',
                'REMOTE_ADDR' => 'string',
                'QUERY_STRING' => 'string',
                'REQUEST_BASENAME' => 'string',
                'REQUEST_BODY' => 'string',
                'REQUEST_COOKIES_NAMES' => 'string',
                'REQUEST_COOKIES' => 'string',
                'REQUEST_FILENAME' => 'string',
                'REQUEST_HEADERS_NAMES' => 'string',
                'REQUEST_HEADERS' => 'string',
                'REQUEST_LINE' => 'string',
                'REQUEST_METHOD' => 'string',
                'REQUEST_PROTOCOL' => 'string',
                'RESPONSE_BODY' => 'string',
                'RESPONSE_HEADERS' => 'string',
                'RESPONSE_STATUS' => 'string',
            ],
            'operatorType' => 0,
            'severityType' => 0,
            'transformationTypes' => [1],
            'value' => 'string',
            'requestCount' => 0,
            'timeframe' => 1,
            'blockTime' => 30,
        ],
    ]
);

Warning

  • If this endpoint is requested for a shield zone on a free tier, it returns a 202 status code with the error message: We do not support Custom WAF Rule creation on our Free Tier of Bunny Shield, please upgrade to Advanced.

List WAF Profiles

$shieldApi->listWafProfiles();

List WAF Enums

$shieldApi->listWafEnums();

List WAF Engine Configuration

$shieldApi->listWafEngineConfiguration();

DDoS

List DDoS Enums

$shieldApi->listDdosEnums();

Rate Limiting

List Rate Limits

$shieldApi->listRateLimits(
    shieldZoneId: 1,
    query: [
        'page' => 1,
        'perPage' => 1000,
    ],
);

Get Rate Limit

$shieldApi->getRateLimit(
    id: 1,
);

Update Rate Limit

$shieldApi->updateRateLimit(
    id: 1,
    body: [
        'ruleName' => 'string',
        'ruleDescription' => 'string',
        'ruleConfiguration' => [
            'actionType' => 1,
            'variableTypes' => [
                'REQUEST_URI' => 'string',
                'REQUEST_URI_RAW' => 'string',
                'ARGS' => 'string',
                'ARGS_COMBINED_SIZE' => 'string',
                'ARGS_GET' => 'string',
                'ARGS_GET_NAMES' => 'string',
                'ARGS_POST' => 'string',
                'ARGS_POST_NAMES' => 'string',
                'FILES_NAMES' => 'string',
                'GEO' => 'string',
                'REMOTE_ADDR' => 'string',
                'QUERY_STRING' => 'string',
                'REQUEST_BASENAME' => 'string',
                'REQUEST_BODY' => 'string',
                'REQUEST_COOKIES_NAMES' => 'string',
                'REQUEST_COOKIES' => 'string',
                'REQUEST_FILENAME' => 'string',
                'REQUEST_HEADERS_NAMES' => 'string',
                'REQUEST_HEADERS' => 'string',
                'REQUEST_LINE' => 'string',
                'REQUEST_METHOD' => 'string',
                'REQUEST_PROTOCOL' => 'string',
                'RESPONSE_BODY' => 'string',
                'RESPONSE_HEADERS' => 'string',
                'RESPONSE_STATUS' => 'string',
            ],
            'operatorType' => 0,
            'severityType' => 0,
            'transformationTypes' => [1],
            'value' => 'string',
            'requestCount' => 0,
            'timeframe' => 1,
            'blockTime' => 30,
        ],
    ],
);

Delete Rate Limit

$shieldApi->deleteRateLimit(
    id: 1,
);

Create Rate Limit

$shieldApi->createRateLimit(
    id: 1,
    body: [
        'shieldZoneId' => 1,
        'ruleName' => 'string',
        'ruleDescription' => 'string',
        'ruleConfiguration' => [
            'actionType' => 1,
            'variableTypes' => [
                'REQUEST_URI' => 'string',
                'REQUEST_URI_RAW' => 'string',
                'ARGS' => 'string',
                'ARGS_COMBINED_SIZE' => 'string',
                'ARGS_GET' => 'string',
                'ARGS_GET_NAMES' => 'string',
                'ARGS_POST' => 'string',
                'ARGS_POST_NAMES' => 'string',
                'FILES_NAMES' => 'string',
                'GEO' => 'string',
                'REMOTE_ADDR' => 'string',
                'QUERY_STRING' => 'string',
                'REQUEST_BASENAME' => 'string',
                'REQUEST_BODY' => 'string',
                'REQUEST_COOKIES_NAMES' => 'string',
                'REQUEST_COOKIES' => 'string',
                'REQUEST_FILENAME' => 'string',
                'REQUEST_HEADERS_NAMES' => 'string',
                'REQUEST_HEADERS' => 'string',
                'REQUEST_LINE' => 'string',
                'REQUEST_METHOD' => 'string',
                'REQUEST_PROTOCOL' => 'string',
                'RESPONSE_BODY' => 'string',
                'RESPONSE_HEADERS' => 'string',
                'RESPONSE_STATUS' => 'string',
            ],
            'operatorType' => 0,
            'severityType' => 0,
            'transformationTypes' => [1],
            'value' => 'string',
            'requestCount' => 0,
            'timeframe' => 1,
            'blockTime' => 30,
        ],
    ],
);

Metrics

Get Overview Metrics

$shieldApi->getOverviewMetrics(
    shieldZoneId: 1,
);

List Rate Limit Metrics

$shieldApi->listRateLimitMetrics(
    shieldZoneId: 1,
);

Get Rate Limit Metrics

$shieldApi->getRateLimitMetrics(
    id: 1,
);

Get WAF Rule Metrics

$shieldApi->getWafRuleMetrics(
    shieldZoneId: 1,
    ruleId: '68332416-124a-4a55-b3fd-4f6c995a3bdf',
);

Event Logs

List Event Logs

$shieldApi->listEventLogs(
    shieldZoneId: 1,
    date: 'Y-m-d\TH:i:s',
    continuationToken: 'string',
);

Reference