> ## 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.

# Get a NetworkPolicy.

> Get a specific NetworkPolicy by its unique identifier.



## OpenAPI

````yaml /openapi-specs/stainless-processed-openapi.json get /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}:
    get:
      tags:
        - network-policies
      summary: Get a NetworkPolicy.
      description: Get a specific NetworkPolicy by its unique identifier.
      operationId: getNetworkPolicy
      parameters:
        - name: id
          in: path
          description: The unique identifier of the NetworkPolicy.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successfully retrieved the NetworkPolicy.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkPolicyView'
        '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.retrieve('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.retrieve(
                "id",
            )
            print(network_policy_view.id)
components:
  schemas:
    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
    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
    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
    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

````