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

# Watch Ports

> Watch for port open/close events across all processes in the sprite namespace. On connect, sends a snapshot of all currently listening ports as a port_list message, then streams incremental port_opened/port_closed events.



## AsyncAPI

````yaml sprites/api/asyncapi.json portsWatch
id: portsWatch
title: Watch Ports
description: >-
  Watch for port open/close events across all processes in the sprite namespace.
  On connect, sends a snapshot of all currently listening ports as a port_list
  message, then streams incremental port_opened/port_closed events.
servers:
  - id: production
    protocol: wss
    host: api.sprites.dev
    bindings: []
    variables: []
address: /v1/sprites/{name}/ports/watch
parameters:
  - id: name
    jsonSchema:
      type: string
      description: Sprite name within the organization.
    description: Sprite name within the organization.
    type: string
    required: true
    deprecated: false
bindings: []
operations:
  - &ref_1
    id: portsWatchSend
    title: 'Watch Ports: messages to client'
    description: Messages the Sprites API sends to the client.
    type: send
    messages:
      - &ref_2
        id: PortListMessage
        contentType: application/json
        payload:
          - name: PortListMessage
            type: object
            properties:
              - name: type
                type: string
                description: port_list
                required: true
              - name: ports
                type: array
                required: true
                properties:
                  - name: type
                    type: string
                    description: Notification type
                    enumValues:
                      - port_opened
                      - port_closed
                    required: true
                  - name: port
                    type: integer
                    description: Port number
                    required: true
                  - name: address
                    type: string
                    description: Proxy URL for accessing the port
                    required: true
                  - name: pid
                    type: integer
                    description: Process ID that opened/closed the port
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              const: port_list
              x-parser-schema-id: <anonymous-schema-32>
            ports:
              type: array
              items: &ref_0
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - port_opened
                      - port_closed
                    description: Notification type
                    x-parser-schema-id: <anonymous-schema-15>
                  port:
                    type: integer
                    description: Port number
                    x-parser-schema-id: <anonymous-schema-16>
                  address:
                    type: string
                    description: Proxy URL for accessing the port
                    x-parser-schema-id: <anonymous-schema-17>
                  pid:
                    type: integer
                    description: Process ID that opened/closed the port
                    x-parser-schema-id: <anonymous-schema-18>
                required:
                  - type
                  - port
                  - address
                  - pid
                examples:
                  - address: https://my-sprite.sprites.dev:3000
                    pid: 1847
                    port: 3000
                    type: port_opened
                x-parser-schema-id: PortNotificationMessage
              x-parser-schema-id: <anonymous-schema-33>
          required:
            - type
            - ports
          x-parser-schema-id: PortListMessage
        title: Port list message
        example: |-
          {
            "type": "<string>",
            "ports": {
              "type": "<string>",
              "port": 123,
              "address": "<string>",
              "pid": 123
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: PortListMessage
      - &ref_3
        id: PortNotificationMessage
        contentType: application/json
        payload:
          - name: PortNotificationMessage
            type: object
            properties:
              - name: type
                type: string
                description: Notification type
                enumValues:
                  - port_opened
                  - port_closed
                required: true
              - name: port
                type: integer
                description: Port number
                required: true
              - name: address
                type: string
                description: Proxy URL for accessing the port
                required: true
              - name: pid
                type: integer
                description: Process ID that opened/closed the port
                required: true
        headers: []
        jsonPayloadSchema: *ref_0
        title: Port notification message
        example: |-
          {
            "address": "https://my-sprite.sprites.dev:3000",
            "pid": 1847,
            "port": 3000,
            "type": "port_opened"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: PortNotificationMessage
    bindings: []
    extensions:
      - id: x-parser-unique-object-id
        value: portsWatch
sendOperations: []
receiveOperations:
  - *ref_1
sendMessages: []
receiveMessages:
  - *ref_2
  - *ref_3
extensions:
  - id: x-parser-unique-object-id
    value: portsWatch
securitySchemes:
  - id: bearerAuth
    name: bearerAuth
    type: http
    description: >-
      Sprites API token in the form `<org>/<id>/<secret>`, sent as
      `Authorization: Bearer <token>` on the upgrade request.
    scheme: bearer
    extensions: []

````