Create Firewall Policy

POST /v1/firewall/policies

Create a new firewall policy (allow/block/challenge), with its conditions in the same call: pass conditions and the policy and every condition are saved together — or, if any condition is refused, nothing is. Without conditions the policy starts with none (attach them later via POST /v1/firewall/policies/{uuid}/conditions). A policy with zero conditions matches every request, so send its conditions with it, or create it with enabled: false and flip it on once its conditions are in.

Plan-gated: requires the firewall_policies entitlement.

Request body

name string Req
Policy name.
description string
Free-form description.
action string
allow (default), block or challenge. challenge makes HTTP visitors pass the edge browser check (the challenge rule's check) first; on TCP/UDP endpoints it blocks. Anything else returns 400.
priority int
Evaluation order. Lower first. Default 100.
enabled boolean
Default true. Set false while you build out conditions, then flip on.
conditions array
The policy's conditions, in evaluation order, each {type, operator, value, logical_operator?} exactly as in Add Firewall Condition. All are validated first, then the policy and its conditions are written in one transaction: all or nothing. Adding conditions takes the firewall update permission as well as create.

Firewall policies are always account-scoped — they apply to every endpoint owned by the caller. There is no per-endpoint scope and no per-policy custom block status; block-action policies use the user's configured custom firewall error template if active, otherwise the platform default (HTTP 403).

Response (201 Created)

The newly-created policy, in the list entry shape: its id and uuid (the same uuid string), plus user_uuid and account_uuid, the stored fields, created_at / updated_at, hit_count (0 for a new policy) — and its conditions (each with its uuid) when you sent any (omitted otherwise).

Deprecated: until the sunset this response also carries the legacy integer user_id and account_id fields. Don't use them; read user_uuid and account_uuid.

Errors

400 Bad Request
Missing name, invalid action, an invalid condition, or invalid JSON. A refused condition is named — "error": "Condition 2: …" with the field under fields as conditions[1].value (0-based) — and nothing is saved.
401 Unauthorized
Missing auth.
403 Forbidden
Plan doesn't include firewall_policies, or your role lacks the firewall permission (create; with conditions, also update).
Request — block list
curl -X POST "https://api.ngris.com/v1/firewall/policies" \ -H "X-API-KEY: <your_api_key>" \ -H "Content-Type: application/json" \ -d '{ "name": "block-known-bad-ips", "action": "block", "priority": 10, "conditions": [ {"type": "source_ip", "operator": "in", "value": "203.0.113.0/24, 198.51.100.7"} ] }'
Python
from ngris import Ngris client = Ngris(api_key="<your_api_key>") policy = client.firewall.create_policy({ "name": "block-known-bad-ips", "action": "block", "priority": 10, "conditions": [ {"type": "source_ip", "operator": "in", "value": "203.0.113.0/24, 198.51.100.7"}, ], })
Response — 201 Created
{ "id": "019c32cb-35d7-786f-b2c5-d108951e23d8", "uuid": "019c32cb-35d7-786f-b2c5-d108951e23d8", "user_uuid": "019a52c2-ca1e-78ba-ab5c-50362cc29134", "account_uuid": "019a68b9-1a79-7820-a884-41f554aba6bd", "name": "block-known-bad-ips", "action": "block", "priority": 10, "enabled": true, "created_at": "2026-04-29T13:00:00Z", "updated_at": "2026-04-29T13:00:00Z", "hit_count": 0, "conditions": [ { "id": "019c32cb-35d8-7a41-9e2f-5b7c1d0e4f21", "uuid": "019c32cb-35d8-7a41-9e2f-5b7c1d0e4f21", "policy_id": "019c32cb-35d7-786f-b2c5-d108951e23d8", "policy_uuid": "019c32cb-35d7-786f-b2c5-d108951e23d8", "condition_type": "source_ip", "operator": "in", "condition_value": "203.0.113.0/24, 198.51.100.7", "logical_operator": "AND", "created_at": "2026-04-29T13:00:00Z" } ] }
Was this helpful?
On this page
Create Firewall Policy
Was this helpful?