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

# Enable a tunnel for a running Devbox.

> Enable a V2 tunnel for an existing running Devbox. Tunnels provide encrypted URL-based access to the Devbox without exposing internal IDs. The tunnel URL format is: https://&#123;port&#125;-&#123;tunnel_key&#125;.tunnel.runloop.ai

Each Devbox can have one tunnel.



## OpenAPI

````yaml /openapi-specs/stainless-processed-openapi.json post /v1/devboxes/{id}/enable_tunnel
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/devboxes/{id}/enable_tunnel:
    post:
      tags:
        - Devbox
        - Devbox-NetworkTools
      summary: Enable a tunnel for a running Devbox.
      description: >-
        Enable a V2 tunnel for an existing running Devbox. Tunnels provide
        encrypted URL-based access to the Devbox without exposing internal IDs.
        The tunnel URL format is:
        https://&#123;port&#125;-&#123;tunnel_key&#125;.tunnel.runloop.ai


        Each Devbox can have one tunnel.
      operationId: enableDevboxTunnel
      parameters:
        - name: id
          in: path
          description: The Devbox ID.
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TunnelConfig'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TunnelView'
        '400':
          description: Devbox is not running or already has a tunnel configured.
        '404':
          description: Devbox not found.
      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 tunnelView = await client.devboxes.enableTunnel('id');

            console.log(tunnelView.auth_mode);
        - 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
            )
            tunnel_view = client.devboxes.enable_tunnel(
                id="id",
            )
            print(tunnel_view.auth_mode)
components:
  schemas:
    TunnelConfig:
      type: object
      description: >-
        Configuration for creating a V2 tunnel. When specified at Devbox
        creation, a tunnel will be automatically provisioned.
      properties:
        auth_mode:
          description: >-
            Authentication mode for the tunnel. Defaults to 'public' if not
            specified.
          anyOf:
            - $ref: '#/components/schemas/TunnelAuthMode'
            - type: 'null'
        http_keep_alive:
          description: >-
            When true, HTTP traffic through the tunnel counts as activity for
            idle lifecycle policies, resetting the idle timer. Defaults to true
            if not specified.
          type:
            - boolean
            - 'null'
        wake_on_http:
          description: >-
            When true, HTTP traffic to a suspended devbox will automatically
            trigger a resume. Defaults to false if not specified. Prefer
            lifecycle.resume_triggers.http on launch_parameters for new
            integrations. If both are set, lifecycle.resume_triggers.http takes
            precedence.
          type:
            - boolean
            - 'null'
    TunnelView:
      type: object
      description: >-
        A V2 tunnel provides secure HTTP access to services running on a Devbox.
        Tunnels allow external clients to reach web servers, APIs, or other HTTP
        services running inside a Devbox without requiring direct network
        access. Each tunnel is uniquely identified by an encrypted tunnel_key
        and can be configured for either open (public) or authenticated access.

        Usage: https://{port}-{tunnel_key}.tunnel.runloop.ai. Authenticated
        tunnels should pass auth_token as X-Runloop-Tunnel-Authorization: Bearer
        {auth_token}.
      properties:
        tunnel_key:
          type: string
          description: >-
            The encrypted tunnel key used to construct the tunnel URL. URL
            format: https://{port}-{tunnel_key}.tunnel.runloop.{domain}
        auth_mode:
          $ref: '#/components/schemas/TunnelAuthModeView'
          description: The authentication mode for the tunnel.
        auth_token:
          description: >-
            Bearer token for tunnel authentication. Only present when auth_mode
            is 'authenticated'. Pass as X-Runloop-Tunnel-Authorization: Bearer
            {auth_token}.
          type:
            - string
            - 'null'
        create_time_ms:
          type: integer
          format: int64
          description: Creation time of the tunnel (Unix timestamp milliseconds).
        http_keep_alive:
          type: boolean
          description: >-
            When true, HTTP traffic through the tunnel counts as activity for
            idle lifecycle policies, resetting the idle timer.
        wake_on_http:
          type: boolean
          description: >-
            When true, HTTP traffic to a suspended devbox will automatically
            trigger a resume.
      required:
        - tunnel_key
        - auth_mode
        - create_time_ms
        - http_keep_alive
        - wake_on_http
    TunnelAuthMode:
      type: string
      enum:
        - open
        - authenticated
    TunnelAuthModeView:
      type: string
      enum:
        - open
        - authenticated
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````