Memory Relations
curl --request POST \
--url https://api.memoclaw.com/v1/memories/{id}/relations \
--header 'Content-Type: application/json' \
--data '
{
"target_id": "<string>",
"relation_type": "<string>",
"metadata": {}
}
'import requests
url = "https://api.memoclaw.com/v1/memories/{id}/relations"
payload = {
"target_id": "<string>",
"relation_type": "<string>",
"metadata": {}
}
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({target_id: '<string>', relation_type: '<string>', metadata: {}})
};
fetch('https://api.memoclaw.com/v1/memories/{id}/relations', 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/{id}/relations",
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([
'target_id' => '<string>',
'relation_type' => '<string>',
'metadata' => [
]
]),
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/{id}/relations"
payload := strings.NewReader("{\n \"target_id\": \"<string>\",\n \"relation_type\": \"<string>\",\n \"metadata\": {}\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/{id}/relations")
.header("Content-Type", "application/json")
.body("{\n \"target_id\": \"<string>\",\n \"relation_type\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.memoclaw.com/v1/memories/{id}/relations")
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 \"target_id\": \"<string>\",\n \"relation_type\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_bodyAPI Reference
Memory Relations
CRUD operations for memory relationships — link memories together.
POST
/
v1
/
memories
/
{id}
/
relations
Memory Relations
curl --request POST \
--url https://api.memoclaw.com/v1/memories/{id}/relations \
--header 'Content-Type: application/json' \
--data '
{
"target_id": "<string>",
"relation_type": "<string>",
"metadata": {}
}
'import requests
url = "https://api.memoclaw.com/v1/memories/{id}/relations"
payload = {
"target_id": "<string>",
"relation_type": "<string>",
"metadata": {}
}
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({target_id: '<string>', relation_type: '<string>', metadata: {}})
};
fetch('https://api.memoclaw.com/v1/memories/{id}/relations', 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/{id}/relations",
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([
'target_id' => '<string>',
'relation_type' => '<string>',
'metadata' => [
]
]),
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/{id}/relations"
payload := strings.NewReader("{\n \"target_id\": \"<string>\",\n \"relation_type\": \"<string>\",\n \"metadata\": {}\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/{id}/relations")
.header("Content-Type", "application/json")
.body("{\n \"target_id\": \"<string>\",\n \"relation_type\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.memoclaw.com/v1/memories/{id}/relations")
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 \"target_id\": \"<string>\",\n \"relation_type\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body
Price: FREE
Relations let you create explicit links between memories. Use them to build knowledge graphs, track contradictions, or group related facts.
Relation Types
| Type | Description |
|---|---|
related_to | General relationship between related memories |
derived_from | Memory was derived/synthesized from another (e.g. consolidation) |
contradicts | Memories that conflict (useful for tracking corrections) |
supersedes | New memory replaces old one |
supports | Memory provides supporting evidence for another |
POST /v1/memories/:id/relations
Create a relationship from one memory to another.Path Parameters
Source memory UUID.
Request Body
Target memory UUID to link to.
One of:
related_to, derived_from, contradicts, supersedes, supports.Optional metadata for the relationship.
Example
curl -X POST https://api.memoclaw.com/v1/memories/550e8400-e29b-41d4-a716-446655440001/relations \
-H "Content-Type: application/json" \
-d '{
"target_id": "550e8400-e29b-41d4-a716-446655440002",
"relation_type": "supersedes",
"metadata": {
"reason": "User corrected their timezone preference"
}
}'
from memoclaw import MemoClaw
client = MemoClaw()
relation = client.create_relation(
"550e8400-e29b-41d4-a716-446655440001",
target_id="550e8400-e29b-41d4-a716-446655440002",
relation_type="supersedes",
metadata={"reason": "User corrected their timezone preference"},
)
Response
{
"id": "rel-123e4567-e89b-12d3-a456-426614174000",
"source_id": "550e8400-e29b-41d4-a716-446655440001",
"target_id": "550e8400-e29b-41d4-a716-446655440002",
"relation_type": "supersedes",
"metadata": {
"reason": "User corrected their timezone preference"
},
"created_at": "2024-02-11T10:45:00Z"
}
GET /v1/memories/:id/relations
List all relationships for a memory (both incoming and outgoing).Path Parameters
Memory UUID.
Example
curl
curl https://api.memoclaw.com/v1/memories/550e8400-e29b-41d4-a716-446655440001/relations
Response
{
"relations": [
{
"id": "rel-123e4567-e89b-12d3-a456-426614174000",
"source_id": "550e8400-e29b-41d4-a716-446655440001",
"target_id": "550e8400-e29b-41d4-a716-446655440002",
"relation_type": "supersedes",
"direction": "outgoing",
"created_at": "2024-02-11T10:45:00Z"
},
{
"id": "rel-223e4567-e89b-12d3-a456-426614174001",
"source_id": "550e8400-e29b-41d4-a716-446655440005",
"target_id": "550e8400-e29b-41d4-a716-446655440001",
"relation_type": "supports",
"direction": "incoming",
"created_at": "2024-02-10T08:30:00Z"
}
]
}
DELETE /v1/memories/:id/relations/:relationId
Remove a relationship.Path Parameters
Memory UUID.
Relation UUID to delete.
Example
curl
curl -X DELETE https://api.memoclaw.com/v1/memories/550e8400-e29b-41d4-a716-446655440001/relations/rel-123e4567-e89b-12d3-a456-426614174000
Response
{
"deleted": true
}
⌘I