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

# Socket.IO Real-time Connection

> Socket.IO connection for real-time bidirectional communication. The server uses Socket.IO v4.x for WebSocket transport with automatic fallback.

**Connection URL**: `ws://localhost:3000/socket.io/` (or `wss://` for secure connections)

**Socket.IO Client Connection Example**:
```javascript
import { io } from 'socket.io-client';
const socket = io('http://localhost:3000');
```

**Events**:

### Client to Server Events:
- `join` - Join a room/channel
  ```json
  {
    "roomId": "uuid",
    "agentId": "uuid"
  }
  ```

- `leave` - Leave a room/channel
  ```json
  {
    "roomId": "uuid",
    "agentId": "uuid"
  }
  ```

- `message` - Send a message
  ```json
  {
    "text": "string",
    "roomId": "uuid",
    "userId": "uuid",
    "name": "string"
  }
  ```

- `request-world-state` - Request current state
  ```json
  {
    "roomId": "uuid"
  }
  ```

### Server to Client Events:
- `messageBroadcast` - New message broadcast
  ```json
  {
    "senderId": "uuid",
    "senderName": "string",
    "text": "string",
    "roomId": "uuid",
    "serverId": "uuid",
    "createdAt": "timestamp",
    "source": "string",
    "id": "uuid",
    "thought": "string",
    "actions": ["string"],
    "attachments": []
  }
  ```

- `messageComplete` - Message processing complete
  ```json
  {
    "channelId": "uuid",
    "serverId": "uuid"
  }
  ```

- `world-state` - World state update
  ```json
  {
    "agents": {},
    "users": {},
    "channels": {},
    "messages": {}
  }
  ```

- `logEntry` - Real-time log entry
  ```json
  {
    "level": "number",
    "time": "timestamp",
    "msg": "string",
    "agentId": "uuid",
    "agentName": "string"
  }
  ```

- `error` - Error event
  ```json
  {
    "error": "string",
    "details": {}
  }
  ```




## OpenAPI

````yaml get /websocket
openapi: 3.1.0
info:
  title: Eliza OS API
  description: >-
    API documentation for Eliza OS v1.2.0 - A flexible and scalable AI agent
    framework.


    This API is designed to be used with a locally running Eliza instance.
    Endpoints allow for creating,

    managing, and interacting with AI agents through a REST interface.


    The API is organized into the following domains:

    - **System**: System-wide operations and environment management

    - **Agents**: Agent lifecycle and management operations

    - **Memory**: Agent memory and room management

    - **Messaging**: Message handling, channels, and servers

    - **Audio**: Audio processing and speech synthesis

    - **Media**: File upload and media management

    - **TEE**: Trusted Execution Environment operations

    - **WebSocket**: Real-time communication via Socket.IO
  version: 1.2.0
  contact:
    name: Eliza OS Community
    url: https://github.com/elizaos/eliza
servers:
  - url: http://localhost:3000
    description: Local development server
security: []
tags:
  - name: system
    description: System-wide operations and environment management
  - name: agents
    description: Operations for managing AI agents
  - name: memory
    description: Operations for managing agent memories
  - name: rooms
    description: Operations for managing rooms
  - name: messaging
    description: Operations for messages, channels, and servers
  - name: audio
    description: Operations for speech and audio processing
  - name: media
    description: Operations for file uploads and media management
  - name: logs
    description: Operations for accessing system and agent logs
  - name: tee
    description: Trusted Execution Environment operations
  - name: websocket
    description: Real-time WebSocket communication
paths:
  /websocket:
    get:
      tags:
        - websocket
      summary: Socket.IO Real-time Connection
      description: >
        Socket.IO connection for real-time bidirectional communication. The
        server uses Socket.IO v4.x for WebSocket transport with automatic
        fallback.


        **Connection URL**: `ws://localhost:3000/socket.io/` (or `wss://` for
        secure connections)


        **Socket.IO Client Connection Example**:

        ```javascript

        import { io } from 'socket.io-client';

        const socket = io('http://localhost:3000');

        ```


        **Events**:


        ### Client to Server Events:

        - `join` - Join a room/channel
          ```json
          {
            "roomId": "uuid",
            "agentId": "uuid"
          }
          ```

        - `leave` - Leave a room/channel
          ```json
          {
            "roomId": "uuid",
            "agentId": "uuid"
          }
          ```

        - `message` - Send a message
          ```json
          {
            "text": "string",
            "roomId": "uuid",
            "userId": "uuid",
            "name": "string"
          }
          ```

        - `request-world-state` - Request current state
          ```json
          {
            "roomId": "uuid"
          }
          ```

        ### Server to Client Events:

        - `messageBroadcast` - New message broadcast
          ```json
          {
            "senderId": "uuid",
            "senderName": "string",
            "text": "string",
            "roomId": "uuid",
            "serverId": "uuid",
            "createdAt": "timestamp",
            "source": "string",
            "id": "uuid",
            "thought": "string",
            "actions": ["string"],
            "attachments": []
          }
          ```

        - `messageComplete` - Message processing complete
          ```json
          {
            "channelId": "uuid",
            "serverId": "uuid"
          }
          ```

        - `world-state` - World state update
          ```json
          {
            "agents": {},
            "users": {},
            "channels": {},
            "messages": {}
          }
          ```

        - `logEntry` - Real-time log entry
          ```json
          {
            "level": "number",
            "time": "timestamp",
            "msg": "string",
            "agentId": "uuid",
            "agentName": "string"
          }
          ```

        - `error` - Error event
          ```json
          {
            "error": "string",
            "details": {}
          }
          ```
      responses:
        '101':
          description: Switching Protocols - WebSocket connection established

````