Update policy
Changed onUpdate a single policy in place without resending the environment's full policy list. The policy keeps its id and its position in the evaluation order, and all other policies are untouched.
Omitted fields keep their stored values; at least one updatable field must be provided. Setting match to null removes all match expressions so the policy applies to every request. Providing one of keyauth, ratelimit, firewall or openapi replaces the policy's rule entirely, including switching its type; at most one may be set.
Policy ids are regenerated whenever gateway.setPolicies replaces the list, so fetch current ids via gateway.listPolicies first.
Required Permissions
Your root key must have one of the following permissions:
- environment.*.update_policy (for any environment)
- environment.<environment_id>.update_policy (for a specific environment)
Request
- Base URLhttps://api.unkey.com
- URLhttps://api.unkey.com/v2/gateway.updatePolicy
- AuthHTTP bearer
Request body
Example request
{
"project": "proj_1234abcd",
"app": "proj_1234abcd",
"environment": "proj_1234abcd",
"policyId": "pol_9d2Fk1LmQ",
"match": [
{
"path": {
"path": {
"prefix": "/api/"
}
}
}
],
"keyauth": {
"keyspaces": [
"ks_1234abcd"
]
},
"ratelimit": {
"limit": 100,
"windowMs": 60000,
"identifiers": [
{
"remoteIp": {}
}
]
},
"firewall": {
"action": "ACTION_DENY"
},
"openapi": {},
"logging": {
"requestHeaders": true,
"responseHeaders": true,
"requestBody": true,
"responseBody": true,
"query": true
}
}Response
Successfully updated the policy.
Example response
{
"meta": {
"requestId": "req_123"
}
}Changes
- breaking
removed the enum value
trueof the request property/// - breaking
removed the enum value
trueof the request property///
- breaking
- info
added the new optional request property
//
- info