Skip to main content
This document explains the detailed usage of a specific policy. If you are using Apinizer policies for the first time or want to learn the general working principles of policies, we recommend reading the What is Policy? page first.

Overview

What is its Purpose?

  • Temporarily removes clients from resource consumption by detecting increasing abuse or error rates.
  • Executes targeted ban policies by associating each request with identity variables (header, query, JWT, etc.).
  • Maintains systemic stability in API Proxy infrastructure with threshold window and ban duration parameters.
  • Enforces business rules by taking action on specific error patterns through Assertion Condition configuration.

Working Principle

  1. Request Arrival: For each HTTP/HTTPS request arriving at the API Gateway, the source IP address of the request is identified.
  2. Policy Check: If the Client Ban policy is active, the system checks in the following order:
    • Is a Condition defined? If so, is the condition met?
    • Is the policy active (active=true)?
    • Is a Variable being used or is Apinizer default?
  3. Identity and Threshold Evaluation: Values from selected clientIdentityVariableList in the request create a key; if assertionCondition is met, requests/responses within the window are counted according to thresholdCalculationType.
  4. Decision Making:
    • Match Found: Blocking is initiated for the key exceeding threshold value for banTimeInSeconds duration, Retry-After header is returned if enableRetryAfterHeader is active.
    • No Match: Request continues in normal flow, counters are not updated.
  5. Error Handling: Customizable HTTP status code and error message are returned for requests that do not comply with the policy rule.

Features and Capabilities

Basic Features

  • Multiple Identity Detection: Client identity is calculated through composite key by selecting multiple variables, supporting segmentation.
  • Adaptable Threshold Management: Fixed or percentage-based (EnumErrorThresholdType) thresholds are defined with thresholdWindowInSeconds and thresholdCountPerWindow parameters.
  • Dynamic Ban Durations: Ban duration is determined in seconds with banTimeInSeconds field; ignoreWhenKeyIsEmpty option ignores empty keys.
  • Active/Passive Status Control: Easily change the active or passive status of the policy (active/passive toggle). In passive mode, the policy is not applied but its configuration is preserved.
  • Condition-Based Application: Determine when the policy will be applied by creating complex conditions with Query Builder (e.g., only for specific endpoints or header values).

Advanced Features

  • Fine Distinction with Assertion Condition: You can trigger bans based on error/response content through Assertion Query Builder. Counters are not updated when conditions are not met, preventing false positives; update conditions with versioning as rules change.
  • Retry-After Header Management: When enableRetryAfterHeader key is active, Retry-After is automatically added to error responses. Value matches banTimeInSeconds and communicates wait time to clients; standardizes retry strategy in queued systems.
  • Multiple Threshold Type Scenario: COUNT mode counts consecutive request count while PERCENT mode focuses on error rates. Two different key sets changing with window duration can be managed within the same policy, performance is optimized by switching modes according to your traffic profile.
  • Export/Import Feature: Export policy configuration as a ZIP file and import to different environments (Development, Test, Production) for version control and backup.
  • Policy Group and Proxy Group Support: Manage multiple policies within Policy Group and assign bulk policies to Proxy Groups to accelerate centralized update and deploy operations.
  • Deploy and Versioning: Deploy policy changes to live environment and monitor which API Proxies use it through Policy Usage, evaluate Proxy Group and Policy Group usage reports.

Usage Scenarios

Configuring Policy Parameters

In this step, users can create a new policy or configure existing policy parameters to define access rules.

Creating a New Client Ban Policy

Client Ban Policy Configuration

Configuration Steps

For descriptions of Conditions and Error Message Customization panels, you can review the Conditions and Error Message Customization sections on the What is Policy? page. For a complete guide on all layers, priority order and scenario examples of the error message configuration system, see the Error Message Configuration Guide page.

Deleting the Policy

For deletion steps of this policy and operations to be applied when in use, you can refer to the Remove Policy from Flow section on the Policy Management page.

Exporting/Importing the Policy

For export (Export) and import (Import) steps of this policy, you can refer to the Export/Import page.

Connecting the Policy to API

For the process of how this policy will be connected to APIs, you can refer to the Connect Policy to API section on the Policy Management page.

Advanced Features

Best Practices

Things to Do and Best Practices

Security Best Practices

Things to Avoid

Performance Tips

Frequently Asked Questions (FAQ)