---
title: "Create a NetworkPolicy."
method: POST
path: "/v1/network-policies"
tags: ["network-policies"]
---

# Create a NetworkPolicy.

`POST /v1/network-policies`

Create a new NetworkPolicy with the specified egress rules. The policy can then be applied to blueprints, devboxes, or snapshot resumes.

## Request body

- NetworkPolicyCreateParameters — Parameters required to create a new NetworkPolicy.
  - `name` string, required — The human-readable name for the NetworkPolicy. Must be unique within the account.
  - `description` string, nullable — Optional description for the NetworkPolicy.
  - `allow_all` boolean, nullable — (Optional) If true, all egress traffic is allowed (ALLOW_ALL policy). Defaults to false.
  - `allow_devbox_to_devbox` boolean, nullable — (Optional) If true, allows traffic between the account's own devboxes via tunnels. Defaults to false. If allow_all is true, this is automatically set to true.
  - `allowed_hostnames` string[], nullable — (Optional) DNS-based allow list with wildcard support. Examples: ['github.com', '*.npmjs.org'].

## Response `200`

NetworkPolicy created successfully.

- NetworkPolicyView — A NetworkPolicy defines egress network access rules for devboxes. Policies can be applied to blueprints, devboxes, and snapshot resumes.
  - `id` string, required — The unique identifier of the NetworkPolicy.
  - `name` string, required — The human-readable name of the NetworkPolicy. Unique per account.
  - `description` string, nullable — Optional description of the NetworkPolicy.
  - `egress` EgressRulesView, required — Egress (outbound) network rules for a NetworkPolicy.
    - `allow_all` boolean, required — If true, all egress traffic is allowed and other fields are ignored. Used for ALLOW_ALL policies.
    - `allow_devbox_to_devbox` boolean, required — If true, allows traffic between the account's own devboxes via tunnels.
    - `allowed_hostnames` string[], required — DNS-based allow list with wildcard support. Examples: ['github.com', '*.npmjs.org', 'api.openai.com']. Empty list with allow_all=false means no network access (DENY_ALL behavior).
  - `create_time_ms` integer, required — The creation time of the NetworkPolicy (Unix timestamp in milliseconds).
  - `update_time_ms` integer, required — Last update time of the NetworkPolicy (Unix timestamp in milliseconds).

## Other responses

- `400` — Bad request. Name already exists or is invalid.
- `401` — Unauthorized. Invalid or missing authentication.
- `403` — Forbidden. Account does not have devbox capability.
- `500` — Internal server error.

## Changes

- **2026-01-19** `8ebd9dbfacb1` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/runloopai/apis/runloop-api/changes/v1/network-policies/post.md)

---

[API](https://skmtc.dev/runloopai/apis/runloop-api.md) · [All operations](https://skmtc.dev/runloopai/apis/runloop-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/runloopai/runloop-api/revisions/c8d61a0c8b88/schema)
