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

# Create an ephemeral PTY tunnel for a running Devbox.

> Create an ephemeral authenticated tunnel for terminal access to a running Devbox. This tunnel is not persisted on the Devbox and is generated fresh on each request. The returned auth_token should be passed as a Bearer token in the X-Runloop-Tunnel-Authorization header.



## OpenAPI

````yaml /openapi-specs/stainless-processed-openapi.json post /v1/devboxes/{id}/create_pty_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}/create_pty_tunnel:
    post:
      tags:
        - Devbox
        - Devbox-NetworkTools
      summary: Create an ephemeral PTY tunnel for a running Devbox.
      description: >-
        Create an ephemeral authenticated tunnel for terminal access to a
        running Devbox. This tunnel is not persisted on the Devbox and is
        generated fresh on each request. The returned auth_token should be
        passed as a Bearer token in the X-Runloop-Tunnel-Authorization header.
      operationId: createDevboxPtyTunnel
      parameters:
        - name: id
          in: path
          description: The Devbox ID.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PtyTunnelView'
        '400':
          description: Devbox is not currently running.
        '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 ptyTunnelView = await client.devboxes.createPtyTunnel('id');

            console.log(ptyTunnelView.auth_token);
        - 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
            )
            pty_tunnel_view = client.devboxes.create_pty_tunnel(
                "id",
            )
            print(pty_tunnel_view.auth_token)
components:
  schemas:
    PtyTunnelView:
      type: object
      description: >-
        An ephemeral PTY tunnel providing authenticated terminal access to a
        Devbox. These tunnels are not stored on the Devbox and are generated
        fresh on each request. Usage:
        https://{port}-{tunnel_key}.tunnel.runloop.ai with
        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_token:
          type: string
          description: >-
            Bearer token for tunnel authentication. Always required for PTY
            tunnels. Pass as X-Runloop-Tunnel-Authorization: Bearer
            {auth_token}.
      required:
        - tunnel_key
        - auth_token
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````