Add a message to a session
curl --request POST \
--url https://api.tensorpro.ai/api/v1/sessions/{session_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": "Thanks, I will remember that.",
"role": "assistant"
}
'import requests
url = "https://api.tensorpro.ai/api/v1/sessions/{session_id}/messages"
payload = {
"content": "Thanks, I will remember that.",
"role": "assistant"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: 'Thanks, I will remember that.', role: 'assistant'})
};
fetch('https://api.tensorpro.ai/api/v1/sessions/{session_id}/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.tensorpro.ai/api/v1/sessions/{session_id}/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([
'content' => 'Thanks, I will remember that.',
'role' => 'assistant'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.tensorpro.ai/api/v1/sessions/{session_id}/messages"
payload := strings.NewReader("{\n \"content\": \"Thanks, I will remember that.\",\n \"role\": \"assistant\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.tensorpro.ai/api/v1/sessions/{session_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"Thanks, I will remember that.\",\n \"role\": \"assistant\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tensorpro.ai/api/v1/sessions/{session_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"Thanks, I will remember that.\",\n \"role\": \"assistant\"\n}"
response = http.request(request)
puts response.read_body{
"id": "m-2",
"role": "assistant",
"content": "Thanks, I will remember that.",
"created_at": "2026-11-10T04:43:22+00:00"
}
Sessions
Add a message to a session
Store one chat message in a session’s transcript. EDN uses the latest assistant message when it checks the next user message for a correction, so storing both sides of the conversation improves correction detection. The session is created if it doesn’t exist yet.
POST
/
api
/
v1
/
sessions
/
{session_id}
/
messages
Add a message to a session
curl --request POST \
--url https://api.tensorpro.ai/api/v1/sessions/{session_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": "Thanks, I will remember that.",
"role": "assistant"
}
'import requests
url = "https://api.tensorpro.ai/api/v1/sessions/{session_id}/messages"
payload = {
"content": "Thanks, I will remember that.",
"role": "assistant"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: 'Thanks, I will remember that.', role: 'assistant'})
};
fetch('https://api.tensorpro.ai/api/v1/sessions/{session_id}/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.tensorpro.ai/api/v1/sessions/{session_id}/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([
'content' => 'Thanks, I will remember that.',
'role' => 'assistant'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.tensorpro.ai/api/v1/sessions/{session_id}/messages"
payload := strings.NewReader("{\n \"content\": \"Thanks, I will remember that.\",\n \"role\": \"assistant\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.tensorpro.ai/api/v1/sessions/{session_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"Thanks, I will remember that.\",\n \"role\": \"assistant\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tensorpro.ai/api/v1/sessions/{session_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"Thanks, I will remember that.\",\n \"role\": \"assistant\"\n}"
response = http.request(request)
puts response.read_body{
"id": "m-2",
"role": "assistant",
"content": "Thanks, I will remember that.",
"created_at": "2026-11-10T04:43:22+00:00"
}
Use this endpoint to store your chat transcript in EDN, one message at a time. It’s separate from memory: storing a message doesn’t save it as a memory.
See Error handling.
What EDN does
- Stores the message in the session’s transcript.
- Creates the session if it’s new.
Required headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | Your EDN API key. Create keys in the Console. See Authentication |
Content-Type | application/json | The request body is JSON |
Request
Path parameters
| Parameter | Type | Description |
|---|---|---|
session_id | string | Identifier for the conversation. Use the same value for every turn in the same conversation. If EDN hasn’t seen this value before, it creates a new session. Format: 1 to 128 characters, using only letters, digits, period (.), underscore (_), colon (:) and hyphen (-) |
Body
| Field | Type | Required | Description |
|---|---|---|---|
role | string | Yes | Who wrote the message: user or assistant |
content | string | Yes | The message text, up to 100,000 characters |
curl -X POST "https://api.tensorpro.ai/api/v1/sessions/chat-42/messages" \
-H "Authorization: Bearer $EDN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"role": "assistant",
"content": "Thanks, I will remember that."
}'
import os
import requests
resp = requests.post(
"https://api.tensorpro.ai/api/v1/sessions/chat-42/messages",
headers={"Authorization": f"Bearer {os.environ['EDN_API_KEY']}"},
json={
"role": "assistant",
"content": "Thanks, I will remember that."
},
)
resp.raise_for_status()
print(resp.json())
const resp = await fetch("https://api.tensorpro.ai/api/v1/sessions/chat-42/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EDN_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"role": "assistant",
"content": "Thanks, I will remember that."
}),
});
console.log(await resp.json());
Response
200 OK
{
"id": "m-2",
"role": "assistant",
"content": "Thanks, I will remember that.",
"created_at": "2026-11-10T04:43:22+00:00"
}
| Field | Type | Description |
|---|---|---|
id | string | Identifier for the message |
role | string | user or assistant |
content | string | The message text |
created_at | string (date-time) | When the message was stored |
Important behavior
- Storing the transcript improves memory. EDN uses the assistant’s previous reply to recognise corrections in Save a conversation turn, and recent user messages to help Build a SIP with short follow-up questions.
- To save memory, use Save a conversation turn. This endpoint only stores the transcript.
Errors
| Status | Code | When |
|---|---|---|
401 | UNAUTHORIZED | The API key is missing, invalid or revoked |
422 | VALIDATION_ERROR | role isn’t user or assistant, content is missing or longer than 100,000 characters, or session_id has invalid characters |
429 | RATE_LIMITED | Per-minute limit reached. Retry after Retry-After seconds |
500 | INTERNAL_ERROR | Something failed on EDN’s side. Retry later |
{
"id": "m-2",
"role": "assistant",
"content": "Thanks, I will remember that.",
"created_at": "2026-11-10T04:43:22+00:00"
}
Authorizations
Body
application/json
