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>"
}
'import requests
url = "https://api.ledgerbeam.com/v1/chats/messages"
payload = {
"resource_id": "res_123456789",
"content": "What are my top 10 customers by revenue this month?",
"thread_id": "thread_abc123",
"stream": False,
"action": "<string>"
}
headers = {
"API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resource_id: 'res_123456789',
content: 'What are my top 10 customers by revenue this month?',
thread_id: 'thread_abc123',
stream: false,
action: '<string>'
})
};
fetch('https://api.ledgerbeam.com/v1/chats/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ledgerbeam.com/v1/chats/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resource_id' => 'res_123456789',
'content' => 'What are my top 10 customers by revenue this month?',
'thread_id' => 'thread_abc123',
'stream' => false,
'action' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"API-KEY: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ledgerbeam.com/v1/chats/messages"
payload := strings.NewReader("{\n \"resource_id\": \"res_123456789\",\n \"content\": \"What are my top 10 customers by revenue this month?\",\n \"thread_id\": \"thread_abc123\",\n \"stream\": false,\n \"action\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ledgerbeam.com/v1/chats/messages")
.header("API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resource_id\": \"res_123456789\",\n \"content\": \"What are my top 10 customers by revenue this month?\",\n \"thread_id\": \"thread_abc123\",\n \"stream\": false,\n \"action\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ledgerbeam.com/v1/chats/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resource_id\": \"res_123456789\",\n \"content\": \"What are my top 10 customers by revenue this month?\",\n \"thread_id\": \"thread_abc123\",\n \"stream\": false,\n \"action\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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"
}{
"error": "Unauthorized access"
}Chat
Create Message
Create a new message in a chat thread to query your data using natural language
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>"
}
'import requests
url = "https://api.ledgerbeam.com/v1/chats/messages"
payload = {
"resource_id": "res_123456789",
"content": "What are my top 10 customers by revenue this month?",
"thread_id": "thread_abc123",
"stream": False,
"action": "<string>"
}
headers = {
"API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resource_id: 'res_123456789',
content: 'What are my top 10 customers by revenue this month?',
thread_id: 'thread_abc123',
stream: false,
action: '<string>'
})
};
fetch('https://api.ledgerbeam.com/v1/chats/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ledgerbeam.com/v1/chats/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resource_id' => 'res_123456789',
'content' => 'What are my top 10 customers by revenue this month?',
'thread_id' => 'thread_abc123',
'stream' => false,
'action' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"API-KEY: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ledgerbeam.com/v1/chats/messages"
payload := strings.NewReader("{\n \"resource_id\": \"res_123456789\",\n \"content\": \"What are my top 10 customers by revenue this month?\",\n \"thread_id\": \"thread_abc123\",\n \"stream\": false,\n \"action\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ledgerbeam.com/v1/chats/messages")
.header("API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resource_id\": \"res_123456789\",\n \"content\": \"What are my top 10 customers by revenue this month?\",\n \"thread_id\": \"thread_abc123\",\n \"stream\": false,\n \"action\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ledgerbeam.com/v1/chats/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resource_id\": \"res_123456789\",\n \"content\": \"What are my top 10 customers by revenue this month?\",\n \"thread_id\": \"thread_abc123\",\n \"stream\": false,\n \"action\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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"
}{
"error": "Unauthorized access"
}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 for authentication
Body
application/json
The unique identifier of the resource (data source) to query
Example:
"res_123456789"
Your natural language question or query
Example:
"What are my top 10 customers by revenue this month?"
Optional. The thread ID to continue an existing conversation. If not provided, a new thread will be created.
Example:
"thread_abc123"
Optional. Set to true to enable streaming responses via Server-Sent Events (SSE). Defaults to false.
Optional. Specify an action type for the query (e.g., 'analyze', 'visualize', 'summarize').
⌘I

