Add Policy
Endpoint
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Authentication
Requires a Personal API Access Token.
Header
Authorization: Bearer YOUR_TOKEN
Request
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {token} | Yes |
| Content-Type | application/json | Yes |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name (must be unique within the API Proxy) |
Request Body
Full JSON Body Example
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-api-based-throttling",
"description": "API throttling policy - 100 requests per minute",
"active": true,
"targetVariableForIdentity": {
"type": "HEADER",
"headerName": "X-API-Key"
},
"messageCountForInterval": 100,
"throttlingInterval": "ONE_MINUTE",
"intervalPeriodLength": 1,
"intervalWindowType": "FIXED",
"cacheConnectionTimeoutInSeconds": 3,
"cacheErrorHandlingType": "FAIL",
"showRateLimitStatisticsInResponseHeader": true,
"detailList": [
{
"targetValue": "VIP",
"regexExpression": false,
"messageCountForInterval": 1000,
"intervalPeriodLength": 1,
"quotaInterval": "ONE_MINUTE"
}
],
"policyCondition": {
"conditionRuleList": [
{
"conditionCriteria": "VALUE",
"firstVariable": {
"name": "userTypeHeader",
"type": "HEADER",
"headerName": "X-User-Type"
},
"variableDataType": "STRING",
"valueComparisonOperator": "EQ",
"secondValueSource": "VALUE",
"secondValue": "PREMIUM"
}
]
}
}
}
Request Body Fields
Policy Operation Metadata
| 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). If null or >= list size, policy is added at the end |
EnumPolicyTargetScope
ALL- Policy applies to all endpointsENDPOINT- Policy applies only to specified endpoint
EnumPolicyTargetPipeline
REQUEST- Executes in request pipelineRESPONSE- Executes in response pipelineERROR- Executes in error pipeline
EnumHttpRequestMethod
GET- GET methodPOST- POST methodPUT- PUT methodDELETE- DELETE methodPATCH- PATCH methodOPTIONS- OPTIONS methodHEAD- HEAD methodTRACE- TRACE methodALL- All methods
Note: When targetScope is ENDPOINT, both targetEndpoint and targetEndpointHTTPMethod are required.
policy
The policy object structure varies by policy type. All policies share common base fields:
Common Policy Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | Yes | - | Policy type (discriminator field) |
| description | string | No | - | Policy description |
| active | boolean | No | true | Whether policy is active |
| policyCondition | object | No | - | Policy condition configuration (see PolicyCondition below) |
| errorMessageList | array | No | - | Custom error messages (if not provided, standard messages are used). See Error Messages |
Note: The name field is not included in the request body. The policy name is taken from the path parameter {policyName}.
Error Messages (errorMessageList)
Optional list of custom error message objects. When omitted, the platform assigns standard policy error messages for the policy type. Structure matches the product error message model (HTTP status, fault code, message template). See individual policy pages for type-specific examples.
Policy Types
Each policy type has its own specific fields. See individual policy documentation pages for details:
- API Based Throttling
- Blocked IP List
- Allowed IP List
- Authentication Basic
- … (see Policies Index for complete list)