Extract Facts
curl --request POST \
--url https://api.memoclaw.com/v1/memories/extract \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{}
],
"namespace": "<string>",
"session_id": "<string>",
"agent_id": "<string>"
}
'import requests
url = "https://api.memoclaw.com/v1/memories/extract"
payload = {
"messages": [{}],
"namespace": "<string>",
"session_id": "<string>",
"agent_id": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{}],
namespace: '<string>',
session_id: '<string>',
agent_id: '<string>'
})
};
fetch('https://api.memoclaw.com/v1/memories/extract', 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.memoclaw.com/v1/memories/extract",
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([
'messages' => [
[
]
],
'namespace' => '<string>',
'session_id' => '<string>',
'agent_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.memoclaw.com/v1/memories/extract"
payload := strings.NewReader("{\n \"messages\": [\n {}\n ],\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.memoclaw.com/v1/memories/extract")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {}\n ],\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.memoclaw.com/v1/memories/extract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {}\n ],\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"memory_ids": [
"<string>"
],
"facts_extracted": 123,
"facts_stored": 123,
"facts_deduplicated": 123,
"tokens_used": 123
}API Reference
Extract Facts
POST /v1/memories/extract — Extract and store facts from conversation via LLM.
POST
/
v1
/
memories
/
extract
Extract Facts
curl --request POST \
--url https://api.memoclaw.com/v1/memories/extract \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{}
],
"namespace": "<string>",
"session_id": "<string>",
"agent_id": "<string>"
}
'import requests
url = "https://api.memoclaw.com/v1/memories/extract"
payload = {
"messages": [{}],
"namespace": "<string>",
"session_id": "<string>",
"agent_id": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{}],
namespace: '<string>',
session_id: '<string>',
agent_id: '<string>'
})
};
fetch('https://api.memoclaw.com/v1/memories/extract', 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.memoclaw.com/v1/memories/extract",
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([
'messages' => [
[
]
],
'namespace' => '<string>',
'session_id' => '<string>',
'agent_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.memoclaw.com/v1/memories/extract"
payload := strings.NewReader("{\n \"messages\": [\n {}\n ],\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.memoclaw.com/v1/memories/extract")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {}\n ],\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.memoclaw.com/v1/memories/extract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {}\n ],\n \"namespace\": \"<string>\",\n \"session_id\": \"<string>\",\n \"agent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"memory_ids": [
"<string>"
],
"facts_extracted": 123,
"facts_stored": 123,
"facts_deduplicated": 123,
"tokens_used": 123
}This endpoint requires an x402 payment header.
Request Body
array
required
Array of conversation messages. Each message must have
role (string) and content (string). Max 100 messages, 32,768 characters per message.string
Namespace for extracted memories. Default:
"default".string
Associate extracted memories with a session.
string
Associate extracted memories with an agent.
Response (201 Created)
string[]
UUIDs of the stored memories (includes both new and deduplicated).
number
Total facts identified by the LLM.
number
New facts stored (not duplicates).
number
Facts that matched existing memories (skipped).
number
Total tokens consumed (LLM + embeddings).
Example
curl -X POST https://api.memoclaw.com/v1/memories/extract \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "I prefer dark mode in all my apps. Also, my timezone is PST."},
{"role": "assistant", "content": "Got it! I will remember your preferences."}
]
}'
const response = await fetch("https://api.memoclaw.com/v1/memories/extract", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
messages: [
{ role: "user", content: "I prefer dark mode in all my apps. Also, my timezone is PST." },
{ role: "assistant", content: "Got it! I will remember your preferences." },
],
}),
});
const data = await response.json();
from memoclaw import MemoClaw
client = MemoClaw()
result = client.extract([
{"role": "user", "content": "I prefer dark mode in all my apps. Also, my timezone is PST."},
{"role": "assistant", "content": "Got it! I will remember your preferences."},
])
Response
{
"memory_ids": [
"550e8400-e29b-41d4-a716-446655440010",
"550e8400-e29b-41d4-a716-446655440011"
],
"facts_extracted": 2,
"facts_stored": 2,
"facts_deduplicated": 0,
"tokens_used": 185
}
The LLM automatically assigns importance and memory type based on the content. Corrections and preferences get higher importance; observations get lower. Each fact is deduplicated against existing memories.