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

# Send Session Message

> Send a message to a conversation session with automatic renewal tracking

<Note>
  Sending a message automatically updates the session's last activity timestamp. If auto-renewal is enabled, the session will be renewed, extending its expiration time.
</Note>

## Path Parameters

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

## Request Body

<ParamField body="content" type="string" required>
  The message content (maximum 4000 characters)
</ParamField>

<ParamField body="metadata" type="object">
  Optional metadata to attach to the message
</ParamField>

<ParamField body="attachments" type="array">
  Optional array of attachments
</ParamField>

## Response

<ResponseField name="id" type="string">
  Unique identifier of the created message
</ResponseField>

<ResponseField name="content" type="string">
  The message content
</ResponseField>

<ResponseField name="authorId" type="string">
  UUID of the message author (user or agent)
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO timestamp of message creation
</ResponseField>

<ResponseField name="metadata" type="object">
  Any metadata attached to the message
</ResponseField>

<ResponseField name="sessionStatus" type="object">
  Current session status after sending the message

  <Expandable title="Session Status Properties">
    <ResponseField name="expiresAt" type="string">
      Updated expiration timestamp
    </ResponseField>

    <ResponseField name="renewalCount" type="number">
      Total number of times the session has been renewed
    </ResponseField>

    <ResponseField name="wasRenewed" type="boolean">
      Whether the session was renewed by this message
    </ResponseField>

    <ResponseField name="isNearExpiration" type="boolean">
      Whether the session is within the warning threshold
    </ResponseField>
  </Expandable>
</ResponseField>

## Error Responses

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

  // 410 - Session expired
  {
    "error": "Session has expired",
    "details": {
      "sessionId": "abc-123",
      "expiresAt": "2024-01-15T10:30:00Z"
    }
  }

  // 400 - Invalid content
  {
    "error": "Content exceeds maximum length of 4000 characters"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml post /api/messaging/sessions/{sessionId}/messages
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}/messages:
    post:
      tags:
        - messaging
      summary: Send a message to a session
      description: >-
        Send a message within an active session. The agent will process and
        respond to the message.
      operationId: sendSessionMessage
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
          description: ID of the session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - content
              properties:
                content:
                  type: string
                  description: The message content
                attachments:
                  type: array
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        description: Type of attachment
                      url:
                        type: string
                        description: URL of the attachment
                      name:
                        type: string
                        description: Name of the attachment
                metadata:
                  type: object
                  description: Additional message metadata
      responses:
        '201':
          description: Message sent and processed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Message ID
                  content:
                    type: string
                    description: The message content
                  authorId:
                    type: string
                    format: uuid
                  createdAt:
                    type: string
                    format: date-time
                  metadata:
                    type: object
                  sessionStatus:
                    type: object
                    description: Current session status after sending the message
                    properties:
                      expiresAt:
                        type: string
                        format: date-time
                        description: Updated expiration timestamp
                      renewalCount:
                        type: integer
                        description: Total number of times the session has been renewed
                      wasRenewed:
                        type: boolean
                        description: Whether the session was renewed by this message
                      isNearExpiration:
                        type: boolean
                        description: Whether the session is within the warning threshold
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: Session has expired
          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

````