Skip to main content
POST
/
v1
/
network-policies
JavaScript
import Runloop from '@runloop/api-client';

const client = new Runloop({
  bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
});

const networkPolicyView = await client.networkPolicies.create({ name: 'name' });

console.log(networkPolicyView.id);
{
  "id": "<string>",
  "name": "<string>",
  "egress": {
    "allow_all": true,
    "allow_devbox_to_devbox": true,
    "allowed_hostnames": [
      "<string>"
    ]
  },
  "create_time_ms": 123,
  "update_time_ms": 123,
  "description": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

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 | null

Optional description for the NetworkPolicy.

allow_all
boolean | null

(Optional) If true, all egress traffic is allowed (ALLOW_ALL policy). Defaults to false.

allow_devbox_to_devbox
boolean | null

(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[] | null

(Optional) DNS-based allow list with wildcard support. Examples: ['github.com', '*.npmjs.org'].

Response

NetworkPolicy created successfully.

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.

egress
object
required

The egress rules for this policy.

create_time_ms
integer<int64>
required

The creation time of the NetworkPolicy (Unix timestamp in milliseconds).

update_time_ms
integer<int64>
required

Last update time of the NetworkPolicy (Unix timestamp in milliseconds).

description
string | null

Optional description of the NetworkPolicy.