Set policies
Replace an environment's gateway policies in a single atomic request. Policies run at the edge before requests reach your app: verify API keys, rate limit, block requests outright, or validate them against your OpenAPI spec.
Policies are an ordered list: the gateway evaluates them top to bottom and the first rejection short-circuits the request.
Each policy sets exactly one of keyauth, ratelimit, firewall or openapi, plus optional match expressions restricting which requests it applies to.
Every call is a full replace: the environment's policies become exactly the request list in the given order, and the server generates a fresh id for each one. An empty list removes all policies. The operation is atomic: if any policy is invalid, nothing is written.
Required Permissions
Your root key must have one of the following permissions:
- environment.*.set_policies (for any environment)
- environment.<environment_id>.set_policies (for a specific environment)
Request body
Example request
{
"project": "proj_1234abcd",
"app": "proj_1234abcd",
"environment": "proj_1234abcd",
"policies": [
{
"name": "Block internal paths",
"enabled": true,
"match": [
{
"path": {
"path": {
"prefix": "/internal/"
}
}
}
],
"firewall": {
"action": "ACTION_DENY"
}
}
]
}Response
Successfully set the policies.
Example response
{
"meta": {
"requestId": "req_123"
}
}Changes
Changed in 4 of the 91 revisions of this API.256
- ○
added the new optional request property
policies/items/loggingnew-optional-request-property
- ○
- ○
added the new optional request property
policies/items/keyauth/creditsnew-optional-request-property
- ○
- ▲
added
RatelimitIdentifierto thepolicies/items/ratelimit/identifierrequest propertyallOflistrequest-property-all-of-added
- ▲
the
policies/items/ratelimit/identifierrequest property type/format changed fromobject/to/request-property-type-changed
- ●
removed the request property
policies/items/ratelimit/identifier/authenticatedSubjectrequest-property-removed
- ●
removed the request property
policies/items/ratelimit/identifier/headerrequest-property-removed
- ●
removed the request property
policies/items/ratelimit/identifier/pathrequest-property-removed
- ●
removed the request property
policies/items/ratelimit/identifier/principalFieldrequest-property-removed
- ●
removed the request property
policies/items/ratelimit/identifier/remoteIprequest-property-removed
- ○
added the new optional request property
policies/items/ratelimit/identifiersnew-optional-request-property
- ○
the request property
policies/items/ratelimit/identifierbecame optionalrequest-property-became-optional
- ○
request property
policies/items/ratelimit/identifierdeprecatedrequest-property-deprecated
- ▲
- ○
endpoint added
endpoint-added
- ○