Client Ban Policy
General Information
Policy Type
policy-client-banner
Endpoints
List Policies
GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/
Add Policy
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Update Policy
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Delete Policy
DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
List Policies
Endpoint
GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
Response
Success Response (200 OK)
{
"status": "SUCCESS",
"resultList": [
{
"apiProxy": {
"name": "MyAPI",
"requestPolicyList": [
{
"type": "policy-client-banner",
"name": "client-ban-policy",
"description": "Ban clients exceeding error threshold",
"active": true,
"clientIdentityVariableList": [
{
"type": "HEADER",
"headerName": "X-API-Key"
}
],
"thresholdWindowInSeconds": 10,
"thresholdCountPerWindow": 5,
"thresholdCalculationType": "COUNT",
"banTimeInSeconds": 300,
"enableRetryAfterHeader": true,
"ignoreWhenKeyIsEmpty": false,
"assertionCondition": {
"conditionRuleList": [
{
"conditionCriteria": "VALUE",
"firstVariable": {
"type": "CONTEXT_VALUES",
"contextValue": "RESPONSE_STATUS_CODE"
},
"variableDataType": "NUMERIC",
"valueComparisonOperator": "GE",
"secondValueSource": "VALUE",
"secondValue": "400"
}
]
}
}
],
"responsePolicyList": [],
"errorPolicyList": []
}
}
],
"resultCount": 1
}
cURL Example
curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/" \
-H "Authorization: Bearer YOUR_TOKEN"
Add Policy
Endpoint
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name (must match name in body) |
Request Body
Important: The request body must follow the PolicyOperationDTO structure with separate operationMetadata and policy objects. See Add Policy for the general structure.
Full JSON Body Example - Basic Client Ban
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-client-banner",
"name": "client-ban-policy",
"description": "Ban clients exceeding error threshold",
"active": true,
"clientIdentityVariableList": [
{
"type": "HEADER",
"headerName": "X-API-Key"
}
],
"thresholdWindowInSeconds": 10,
"thresholdCountPerWindow": 5,
"thresholdCalculationType": "COUNT",
"banTimeInSeconds": 300,
"enableRetryAfterHeader": true,
"ignoreWhenKeyIsEmpty": false,
"assertionCondition": {
"conditionRuleList": [
{
"conditionCriteria": "VALUE",
"firstVariable": {
"type": "CONTEXT_VALUES",
"contextValue": "RESPONSE_STATUS_CODE"
},
"variableDataType": "NUMERIC",
"valueComparisonOperator": "GE",
"secondValueSource": "VALUE",
"secondValue": "400"
}
]
}
}
}
Full JSON Body Example - IP-Based Ban with Percentage Threshold
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-client-banner",
"name": "ip-ban-policy",
"description": "Ban IPs with high error percentage",
"active": true,
"clientIdentityVariableList": [
{
"type": "CONTEXT_VALUES",
"contextValue": "REQUEST_REMOTE_ADDRESS"
}
],
"thresholdWindowInSeconds": 60,
"thresholdCountPerWindow": 50,
"thresholdCalculationType": "PERCENT",
"banTimeInSeconds": 600,
"enableRetryAfterHeader": true,
"ignoreWhenKeyIsEmpty": false,
"assertionCondition": {
"conditionRuleList": [
{
"conditionCriteria": "VALUE",
"firstVariable": {
"type": "CONTEXT_VALUES",
"contextValue": "RESPONSE_STATUS_CODE"
},
"variableDataType": "NUMERIC",
"valueComparisonOperator": "GE",
"secondValueSource": "VALUE",
"secondValue": "500"
}
]
}
}
}
Full JSON Body Example - Multi-Variable Client Ban
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-client-banner",
"name": "multi-variable-ban",
"description": "Ban clients using multiple identity variables",
"active": true,
"clientIdentityVariableList": [
{
"type": "HEADER",
"headerName": "X-API-Key"
},
{
"type": "CONTEXT_VALUES",
"contextValue": "REQUEST_REMOTE_ADDRESS"
}
],
"thresholdWindowInSeconds": 30,
"thresholdCountPerWindow": 10,
"thresholdCalculationType": "COUNT",
"banTimeInSeconds": 1800,
"enableRetryAfterHeader": true,
"ignoreWhenKeyIsEmpty": false,
"assertionCondition": {
"conditionRuleList": [
{
"conditionCriteria": "AND",
"conditionRuleList": [
{
"conditionCriteria": "VALUE",
"firstVariable": {
"type": "CONTEXT_VALUES",
"contextValue": "RESPONSE_STATUS_CODE"
},
"variableDataType": "NUMERIC",
"valueComparisonOperator": "EQ",
"secondValueSource": "VALUE",
"secondValue": "401"
},
{
"conditionCriteria": "VALUE",
"firstVariable": {
"type": "CONTEXT_VALUES",
"contextValue": "REQUEST_PATH_INFO"
},
"variableDataType": "STRING",
"valueComparisonOperator": "CONTAINS",
"secondValueSource": "VALUE",
"secondValue": "/auth"
}
]
}
]
}
}
}
Request Body Fields
The request body has two top-level fields:
| Field | Type | Required | Description |
|---|---|---|---|
| operationMetadata | object | Yes | Operation metadata. See Policy Operation Metadata |
| policy | object | Yes | Policy configuration (see below) |
Common Policy Fields (policy object)
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | Yes | - | Policy type: policy-client-banner |
| name | string | Yes | - | Policy name (must match path parameter) |
| description | string | No | - | Policy description |
| active | boolean | No | true | Whether policy is active |
| policyCondition | object | No | - | Runs the policy only when the condition matches. See Add Policy |
Client Ban Specific Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| clientIdentityVariableList | array | Yes | [] | List of variables used to identify clients |
| thresholdWindowInSeconds | integer | Yes | 10 | Time window in seconds for threshold calculation |
| thresholdCountPerWindow | integer | Yes | 1 | Threshold count or percentage per window |
| thresholdCalculationType | string | Yes | COUNT | Threshold calculation type |
| banTimeInSeconds | integer | Yes | 10 | Duration to ban client in seconds |
| enableRetryAfterHeader | boolean | No | false | Enable Retry-After header in ban response |
| ignoreWhenKeyIsEmpty | boolean | No | false | Ignore requests when identity key is empty |
| assertionCondition | object | Yes | - | Condition that triggers ban counting |
EnumErrorThresholdType (thresholdCalculationType)
COUNT- Count-based threshold (number of errors)PERCENT- Percentage-based threshold (percentage of errors)
VariableDTO (clientIdentityVariableList item)
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Variable type |
| headerName | string | No* | Header name (required if type=HEADER) |
| paramName | string | No* | Parameter name (required if type=PARAMETER) |
| contextValue | string | No* | Context value (required if type=CONTEXT_VALUES) |
Variable Types
HEADER- Extract from HTTP headerPARAMETER- Extract from query/path/form parameterBODY- Extract from request/response body (XML, JSON, or raw)CONTEXT_VALUES- Extract from system context values (e.g., REQUEST_REMOTE_ADDRESS for client IP)CUSTOM- Extract using custom script
Note: For client IP, use type=CONTEXT_VALUES with contextValue=REQUEST_REMOTE_ADDRESS.
PolicyConditionDTO (assertionCondition)
| Field | Type | Required | Description |
|---|---|---|---|
| conditionRuleList | array | Yes | List of condition rules |