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

# Send Message

> Send a message and receive AI response

### Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token. Format: `Bearer synthra_live_abc123def456`
</ParamField>

### Path Parameters

<ParamField path="sessionId" type="string" required>
  Unique session identifier. Format: `session_<16 chars>`
</ParamField>

### Body Parameters

<ParamField body="content" type="string" required>
  Message content. Max 10,000 characters.
</ParamField>

<ParamField body="role" type="string" default="user">
  Message role. Options: `user`, `system`
</ParamField>

<ParamField body="streaming" type="boolean" default="false">
  Enable streaming response via WebSocket
</ParamField>

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

### Response

<ResponseField name="messageId" type="string">
  Unique message identifier
</ResponseField>

<ResponseField name="sessionId" type="string">
  Session identifier
</ResponseField>

<ResponseField name="role" type="string">
  Message role (assistant)
</ResponseField>

<ResponseField name="content" type="string">
  AI-generated response content
</ResponseField>

<ResponseField name="tokens" type="number">
  Token count for this message
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO 8601 timestamp
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.synthra.ai/v1/sessions/session_abc123def456/messages \
    --header 'Authorization: Bearer synthra_live_abc123def456' \
    --header 'Content-Type: application/json' \
    --data '{
      "content": "What is the current price of SOL?",
      "role": "user"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.synthra.ai/v1/sessions/session_abc123def456/messages',
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.SYNTHRA_API_KEY}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        content: 'What is the current price of SOL?',
        role: 'user'
      })
    }
  );
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.synthra.ai/v1/sessions/session_abc123def456/messages',
      headers={
          'Authorization': f'Bearer {api_key}',
          'Content-Type': 'application/json'
      },
      json={
          'content': 'What is the current price of SOL?',
          'role': 'user'
      }
  )
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "messageId": "msg_xyz789ghi012",
    "sessionId": "session_abc123def456",
    "role": "assistant",
    "content": "The current price of Solana (SOL) is $147.23 USD, up 3.2% in the last 24 hours.",
    "tokens": 28,
    "createdAt": "2024-03-08T14:30:15Z"
  }
  ```

  ```json 413 - Context Overflow theme={null}
  {
    "error": {
      "code": "context_overflow",
      "message": "Context window exceeded. Enable compression or clear session history.",
      "currentTokens": 8192,
      "maxTokens": 8192
    }
  }
  ```
</ResponseExample>
