Skip to main content
POST
/
chats
/
messages
Create message
curl --request POST \
  --url https://api.ledgerbeam.com/v1/chats/messages \
  --header 'API-KEY: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "resource_id": "res_123456789",
  "content": "What are my top 10 customers by revenue this month?",
  "thread_id": "thread_abc123",
  "stream": false,
  "action": "<string>"
}
'
{
  "user_message": {
    "id": "msg_abc123",
    "content": [
      {
        "type": 1,
        "value": "Here are your top customers...",
        "meta": {}
      }
    ],
    "role": "user",
    "meta": {}
  },
  "assistant_message": {
    "id": "msg_abc123",
    "content": [
      {
        "type": 1,
        "value": "Here are your top customers...",
        "meta": {}
      }
    ],
    "role": "user",
    "meta": {}
  },
  "meta": {
    "answer": "Your top 10 customers by revenue this month are...",
    "row_count": 10,
    "query_time": "0.45s",
    "query_type": "SELECT",
    "query": "SELECT customer_name, SUM(revenue) as total_revenue FROM orders WHERE ...",
    "rows": [
      {}
    ],
    "thinking": [
      "<string>"
    ],
    "rendered": {}
  },
  "thread_id": "thread_abc123"
}

Overview

Create a new message in a chat thread to query your data using natural language. This endpoint processes your question, generates appropriate queries, executes them against your connected resource, and returns intelligent responses.

Authorizations

API-KEY
string
header
required

API key for authentication

Body

application/json
resource_id
string
required

The unique identifier of the resource (data source) to query

Example:

"res_123456789"

content
string
required

Your natural language question or query

Example:

"What are my top 10 customers by revenue this month?"

thread_id
string

Optional. The thread ID to continue an existing conversation. If not provided, a new thread will be created.

Example:

"thread_abc123"

stream
boolean
default:false

Optional. Set to true to enable streaming responses via Server-Sent Events (SSE). Defaults to false.

action
string

Optional. Specify an action type for the query (e.g., 'analyze', 'visualize', 'summarize').

Response

Message created successfully

user_message
object
assistant_message
object
meta
object
thread_id
string

Thread ID

Example:

"thread_abc123"