# Connect bidirectional runtime RPC (/brain/docs/api/generated/executorRPC)

WebSocket upgrade using brain-rpc and brain-auth.TOKEN subprotocols. Commands and replies use the same contract as SSE/HTTP. Browser origins are rejected.

## GET /executors/{id}/rpc

Bearer authentication is required.

```json
{
  "openapi": "3.1.0",
  "info": {
    "description": "HTTP API for the Brain agent session server.",
    "title": "Brain",
    "version": "current"
  },
  "servers": [
    {
      "description": "Local development",
      "url": "http://127.0.0.1:8080"
    }
  ],
  "paths": {
    "/executors/{id}/rpc": {
      "get": {
        "description": "WebSocket upgrade using brain-rpc and brain-auth.TOKEN subprotocols. Commands and replies use the same contract as SSE/HTTP. Browser origins are rejected.",
        "operationId": "executorRPC",
        "parameters": [
          {
            "description": "Opaque executor ID.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "pattern": "^[a-fA-F0-9]{32}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "101": {
            "content": {},
            "description": "Connect bidirectional runtime RPC"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Error. 400 invalid_request; 401 missing/invalid Bearer token; 403 forbidden; 404 not_found; 409 conflict or cursor_unavailable; 413 body limit; 422 unsupported; 429 overloaded (Retry-After: 1); 500 brain_error. X-Request-ID is present on every response."
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Connect bidirectional runtime RPC"
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorDetail"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "type": "object"
      },
      "ErrorDetail": {
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
```

[Complete OpenAPI document](/brain/openapi.json)