---
title: "POST /network-policy/rules"
method: POST
path: "/network-policy/rules"
tags: ["Network Policy"]
---

# POST /network-policy/rules

`POST /network-policy/rules`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/network-policy/rules`
- Auth: HTTP bearer

## Request body

- CreateNetworkPolicyRuleRequest
  - `action` string, required: `allow` or `deny`.
  - `description` string, nullable
  - `direction` string, required: `egress` or `ingress`.
  - `peer_kind` string, required: `service` (by id), `workload` (`<kind>/<id>`) or `cidr`. `host` parses but is refused with 409 until a node runs the shared egress proxy that enforces hostname rules.
  - `peer_ref` string, required
  - `port_end` integer, nullable
  - `port_start` integer, nullable: Omit both ports for every port (80/443 for a `host` rule).
  - `protocol` string, nullable: `tcp` (default), `udp` or `any`.
  - `subject_id` integer, required: Environment id for `deployment`; the row id for the other kinds.
  - `subject_kind` string, required: `deployment` (an environment), `sandbox`, `service`, `function` or `job`.

## Response `201`

Rule created

- NetworkPolicyRuleResponse
  - `action` string, required
  - `created_at` string, date-time, required
  - `created_by` integer, nullable
  - `description` string, nullable
  - `direction` string, required
  - `enforceable` boolean, required: False for a `host` rule: hostname rules are enforced only by the shared egress proxy, which no node runs yet, so such a rule (stored before new ones were refused) is shown but never enforced.
  - `id` integer, required
  - `link_id` integer, nullable
  - `link_table` string, nullable
  - `origin` string, required: `link` rules are removed by unlinking, not deleted directly.
  - `peer_kind` string, required
  - `peer_ref` string, required
  - `port_end` integer, nullable
  - `port_start` integer, nullable
  - `protocol` string, required
  - `subject_id` integer, required
  - `subject_kind` string, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: Invalid rule
- `401`: Unauthorized
- `403`: Instance administrators only
- `500`: Internal server error

## Changes

- **2026-11-09** `12896146b193`: 4 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `403` status
  - removed the required property `extensions` from the response with the `500` status
- **2026-10-28** `b8d51a990805`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/network-policy/rules/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
