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

# End Session

> Explicitly end and delete a conversation session

<Note>
  This endpoint immediately ends a session regardless of its timeout configuration. The session is removed from memory but the underlying channel and messages are preserved for historical reference.
</Note>

## Path Parameters

<ParamField path="sessionId" type="string" required>
  The unique identifier of the session to delete
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the session was successfully deleted
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message with the session ID
</ResponseField>

## Example Response

```json theme={null}
{
  "success": true,
  "message": "Session abc-123-def-456 deleted successfully"
}
```

## Error Responses

<ResponseExample>
  ```json theme={null}
  // 404 - Session not found
  {
    "error": "Session not found",
    "code": "SESSION_NOT_FOUND",
    "details": {
      "sessionId": "abc-123"
    }
  }
  ```
</ResponseExample>

## Important Notes

* Deleting a session does not delete the conversation history
* The underlying channel and messages remain in the database
* Active WebSocket connections for the session will be terminated
* Any pending operations on the session will fail after deletion


## OpenAPI

````yaml delete /api/messaging/sessions/{sessionId}
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:
  /api/messaging/sessions/{sessionId}:
    delete:
      tags:
        - messaging
      summary: End a session
      description: End an active session and optionally archive its data
      operationId: endSession
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
          description: ID of the session to end
      responses:
        '200':
          description: Session ended successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Session ended successfully
        '404':
          description: Session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
            message:
              type: string
              description: Error message
            details:
              type: string
              description: Detailed error information

````