> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runloop.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a NetworkPolicy.

> Update an existing NetworkPolicy. All fields are optional - null fields preserve existing values, provided fields replace entirely.



## OpenAPI

````yaml /openapi-specs/stainless-processed-openapi.json post /v1/network-policies/{id}
openapi: 3.1.0
info:
  title: RunLoop API
  version: '0.1'
  description: >-
    The RunLoop API spec that allows you to host lambda functions and Devboxes
    to enable scaled long running ai workflows.
  contact:
    name: Runloop AI Support
    url: https://runloop.ai
    email: support@runloop.ai
servers:
  - url: https://api.runloop.ai
    description: Runloop API
    variables: {}
security:
  - bearerAuth: []
tags:
  - name: Benchmark
  - name: Blueprint
  - name: Blueprint-Lifecycle
  - name: Blueprint-ObservabilityTools
  - name: Devbox
  - name: Devbox-FileTools
  - name: Devbox-Lifecycle
  - name: Devbox-NetworkTools
  - name: Devbox-ObservabilityTools
  - name: Devbox-PersistenceTools
  - name: Devbox-ShellTools
  - name: Scenario
  - name: ScenarioScorer
  - name: accounts
  - name: agents
  - name: apikeys
  - name: axons
  - name: executions
  - name: gateway-configs
  - name: mcp-configs
  - name: network-policies
  - name: objects
  - name: restricted_keys
  - name: secrets
  - name: streaming
paths:
  /v1/network-policies/{id}:
    post:
      tags:
        - network-policies
      summary: Update a NetworkPolicy.
      description: >-
        Update an existing NetworkPolicy. All fields are optional - null fields
        preserve existing values, provided fields replace entirely.
      operationId: updateNetworkPolicy
      parameters:
        - name: id
          in: path
          description: The unique identifier of the NetworkPolicy to update.
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NetworkPolicyUpdateParameters'
      responses:
        '200':
          description: NetworkPolicy updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkPolicyView'
        '400':
          description: Bad request. Invalid parameters.
        '401':
          description: Unauthorized. Invalid or missing authentication.
        '403':
          description: Forbidden. Account does not have devbox capability.
        '404':
          description: NetworkPolicy not found.
        '500':
          description: Internal server error.
      x-codeSamples:
        - lang: JavaScript
          source: |-
            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.update('id');

            console.log(networkPolicyView.id);
        - lang: Python
          source: |-
            import os
            from runloop_api_client import Runloop

            client = Runloop(
                bearer_token=os.environ.get("RUNLOOP_API_KEY"),  # This is the default and can be omitted
            )
            network_policy_view = client.network_policies.update(
                id="id",
            )
            print(network_policy_view.id)
components:
  schemas:
    NetworkPolicyUpdateParameters:
      type: object
      description: >-
        Parameters for updating an existing NetworkPolicy. All fields are
        optional.
      properties:
        name:
          description: Updated human-readable name for the NetworkPolicy.
          type:
            - string
            - 'null'
        description:
          description: Updated description for the NetworkPolicy.
          type:
            - string
            - 'null'
        allow_all:
          description: If true, all egress traffic is allowed (ALLOW_ALL policy).
          type:
            - boolean
            - 'null'
        allow_devbox_to_devbox:
          description: >-
            If true, allows traffic between the account's own devboxes via
            tunnels.
          type:
            - boolean
            - 'null'
        allowed_hostnames:
          items:
            type: string
          description: >-
            Updated DNS-based allow list with wildcard support. Examples:
            ['github.com', '*.npmjs.org'].
          type:
            - array
            - 'null'
        allowed_cidrs:
          items:
            $ref: '#/components/schemas/AllowedCidr'
          description: >-
            Updated IPv4 CIDR-based allow list with optional port restrictions,
            additive with allowed_hostnames.
          type:
            - array
            - 'null'
        allow_agent_gateway:
          description: If true, allows devbox egress to the agent gateway.
          type:
            - boolean
            - 'null'
        allow_mcp_gateway:
          description: If true, allows devbox egress to the MCP hub.
          type:
            - boolean
            - 'null'
        allow_runloop_mirrors:
          description: >-
            If true, allows devbox egress to Runloop's package/image registry
            mirrors. Implicitly allowed when allow_all is true.
          type:
            - boolean
            - 'null'
    NetworkPolicyView:
      type: object
      description: >-
        A NetworkPolicy defines egress network access rules for devboxes.
        Policies can be applied to blueprints, devboxes, and snapshot resumes.
      properties:
        id:
          type: string
          description: The unique identifier of the NetworkPolicy.
        name:
          type: string
          description: The human-readable name of the NetworkPolicy. Unique per account.
        description:
          description: Optional description of the NetworkPolicy.
          type:
            - string
            - 'null'
        egress:
          $ref: '#/components/schemas/EgressRulesView'
          description: The egress rules for this policy.
        create_time_ms:
          type: integer
          format: int64
          description: >-
            The creation time of the NetworkPolicy (Unix timestamp in
            milliseconds).
        update_time_ms:
          type: integer
          format: int64
          description: >-
            Last update time of the NetworkPolicy (Unix timestamp in
            milliseconds).
      required:
        - id
        - name
        - egress
        - create_time_ms
        - update_time_ms
    AllowedCidr:
      type: object
      description: A CIDR-based egress allow rule with optional port restrictions.
      properties:
        cidr:
          type: string
          description: >-
            IPv4 CIDR block in canonical form (host bits zero), e.g.
            '10.12.0.0/16'.
        ports:
          items:
            $ref: '#/components/schemas/PortRule'
          description: >-
            (Optional) Ports allowed for this CIDR. Empty or omitted means all
            ports and protocols.
          type:
            - array
            - 'null'
      required:
        - cidr
    EgressRulesView:
      type: object
      description: Egress (outbound) network rules for a NetworkPolicy.
      properties:
        allow_all:
          type: boolean
          description: >-
            If true, all egress traffic is allowed and other fields are ignored.
            Used for ALLOW_ALL policies.
        allow_devbox_to_devbox:
          type: boolean
          description: >-
            If true, allows traffic between the account's own devboxes via
            tunnels.
        allowed_hostnames:
          type: array
          items:
            type: string
          description: >-
            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).
        allowed_cidrs:
          type: array
          items:
            $ref: '#/components/schemas/AllowedCidr'
          description: >-
            CIDR-based allow list with optional port restrictions, additive with
            allowed_hostnames.
        allow_agent_gateway:
          type: boolean
          description: >-
            If true, allows devbox egress to the agent gateway for credential
            proxying.
        allow_mcp_gateway:
          type: boolean
          description: If true, allows devbox egress to the MCP hub for MCP server access.
        allow_runloop_mirrors:
          type: boolean
          description: >-
            If true, allows devbox egress to Runloop's package/image registry
            mirrors. Implicitly allowed when allow_all is true.
      required:
        - allow_all
        - allow_devbox_to_devbox
        - allowed_hostnames
        - allowed_cidrs
        - allow_agent_gateway
        - allow_mcp_gateway
        - allow_runloop_mirrors
    PortRule:
      type: object
      description: A port or port range allowed for a CIDR egress rule.
      properties:
        port:
          type: integer
          format: int32
          description: The allowed port (1-65535), or the start of a port range.
        end_port:
          format: int32
          description: >-
            (Optional) Inclusive end of the port range (port-65535). Omit for a
            single port.
          type:
            - integer
            - 'null'
        protocol:
          description: (Optional) 'TCP' or 'UDP'. Defaults to 'TCP'.
          anyOf:
            - $ref: '#/components/schemas/PortProtocol'
            - type: 'null'
      required:
        - port
    PortProtocol:
      type: string
      enum:
        - TCP
        - UDP
      description: L4 protocol for a port rule.
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````