Blocked IP List Policy
Policy Type
UI Documentation
📖 For detailed information: [UI Documentation Link - Link will be added here]
Description
Black IP policy blocks requests from specified IP addresses or IP ranges. Requests from blacklisted IPs are rejected before reaching the backend. This policy is useful for blocking malicious IPs, DDoS attacks, or specific geographic regions.
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
| 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)
{
"success": true,
"resultList": [
{
"apiProxy": {
"name": "MyAPI",
"requestPolicyList": [
{
"type": "policy-black-ip",
"name": "black-ip-policy",
"description": "Block malicious IPs",
"active": true,
"targetVariableForIP": null,
"ipList": [
"192.168.1.100",
"10.0.0.0/8",
"203.0.113.0/24"
]
}
],
"responsePolicyList": [],
"errorPolicyList": []
}
}
],
"resultCount": 1
}
Note: In list operations, ipList may be omitted for brevity.
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
| 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 |
Request Body
Full JSON Body Example
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-black-ip",
"description": "Block malicious IP addresses",
"active": true,
"targetVariableForIP": null,
"ipList": [
"192.168.1.100",
"10.0.0.0/8",
"203.0.113.0/24",
"2001:db8::/32"
]
}
}
Request Body Fields
| Field |
Type |
Required |
Default |
Description |
| targetScope |
string |
Yes |
- |
Policy scope: ALL or ENDPOINT |
| targetEndpoint |
string |
No* |
- |
Endpoint path (required if targetScope=ENDPOINT) |
| targetEndpointHTTPMethod |
string |
No* |
- |
HTTP method (required if targetScope=ENDPOINT) |
| targetPipeline |
string |
Yes |
- |
Pipeline: REQUEST, RESPONSE, or ERROR |
| deploy |
boolean |
No |
true |
Whether to deploy after adding policy |
| deployTargetEnvironmentNameList |
array |
No |
[] |
List of environment names to deploy to |
| order |
integer |
No |
null |
Policy execution order (starts from 1) |
Enum: targetScope
ALL - Policy applies to all endpoints
ENDPOINT - Policy applies only to specified endpoint
Enum: targetPipeline
REQUEST - Executes in request pipeline
RESPONSE - Executes in response pipeline
ERROR - Executes in error pipeline
Enum: targetEndpointHTTPMethod
GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
policy
| Field |
Type |
Required |
Default |
Description |
| type |
string |
Yes |
- |
Policy type: policy-black-ip |
| description |
string |
No |
- |
Policy description |
| active |
boolean |
No |
true |
Whether policy is active |
| targetVariableForIP |
object |
No |
null |
Variable to extract IP address (null = use Apinizer default) |
| ipList |
array |
Yes |
- |
List of IP addresses or CIDR ranges to block |
- Single IP:
192.168.1.100 (IPv4) or 2001:db8::1 (IPv6)
- CIDR Range:
10.0.0.0/8 (IPv4) or 2001:db8::/32 (IPv6)
- Multiple entries: Array of IPs and CIDR ranges
Note
ipList must contain at least one IP address or CIDR range.
- When
targetVariableForIP is null, Apinizer uses default IP detection (from X-Forwarded-For header or direct connection).
targetVariableForIP (Optional)
| Field |
Type |
Required |
Description |
| type |
string |
Yes |
Variable type: HEADER, PARAMETER, BODY, CONTEXT, SCRIPT |
| 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) |
type
HEADER - Extract from HTTP header (e.g., X-Forwarded-For, X-Real-IP)
PARAMETER - Extract from query/path parameter
BODY - Extract from request body
CONTEXT - Extract from context (e.g., CLIENT_IP)
SCRIPT - Extract using script
contextValue
CLIENT_IP - Client IP address (recommended for IP filtering)
REQUEST_URI - Request URI
REQUEST_METHOD - HTTP method
USER_AGENT - User agent string
Default IP Detection
When targetVariableForIP is null, Apinizer automatically detects the client IP from:
- X-Forwarded-For header (if present)
- Direct connection IP address
Response
Success Response (200 OK)
{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}
cURL Example
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/black-ip-policy/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-black-ip",
"description": "Block malicious IP addresses",
"active": true,
"ipList": [
"192.168.1.100",
"10.0.0.0/8",
"203.0.113.0/24"
]
}
}'
Update Policy
Endpoint
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Request
| 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 |
Request Body
Full JSON Body Example
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["tester"],
"order": 1
},
"policy": {
"type": "policy-black-ip",
"description": "Block malicious IP addresses from X-Forwarded-For",
"active": true,
"targetVariableForIP": {
"type": "HEADER",
"headerName": "X-Forwarded-For"
},
"ipList": [
"192.168.1.100",
"10.0.0.0/8",
"203.0.113.0/24"
]
}
}
Note: Request body structure is the same as Add Policy. All fields should be provided for update.
Response
Success Response (200 OK)
{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}
cURL Example
curl -X PUT \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/black-ip-policy/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-black-ip",
"description": "Updated black IP list",
"active": true,
"ipList": [
"192.168.1.100",
"10.0.0.0/8"
]
}
}'
Delete Policy
Endpoint
DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Request
| 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 |
Request Body
Full JSON Body Example
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": false
}
}
Request Body Fields
| Field |
Type |
Required |
Description |
|
| targetScope |
string |
Yes |
Policy scope: ALL or ENDPOINT |
|
| targetPipeline |
string |
Yes |
Pipeline: REQUEST, RESPONSE, or ERROR |
|
| deploy |
boolean |
No |
false |
Whether to deploy after deletion |
Response
Success Response (200 OK)
{
"success": true,
"deploymentResult": {
"success": true,
"deploymentResults": []
}
}
cURL Example
curl -X DELETE \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/black-ip-policy/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": false
}
}'
Notes and Warnings
- IP List: Must contain at least one IP address or CIDR range
- IP Formats:
- Single IP:
192.168.1.100 (IPv4) or 2001:db8::1 (IPv6)
- CIDR Range:
10.0.0.0/8 (IPv4) or 2001:db8::/32 (IPv6)
- IP Detection:
- When
targetVariableForIP is null, Apinizer uses default IP detection
- Default detection checks X-Forwarded-For header and direct connection IP
- Custom IP Extraction: Use
targetVariableForIP to extract IP from custom headers or parameters
- CIDR Notation: CIDR ranges block all IPs within the specified range
- IPv6 Support: Both IPv4 and IPv6 addresses are supported
- Performance: IP checking is fast, but large IP lists may impact performance
- Order: This policy should typically be executed early in the request pipeline (low order number)
- Deployment: Policy changes require deployment to take effect. Set
deploy: true or deploy manually.