MemorySync
API Reference

Create Memory Relation

Explicitly link two memories with a typed, directional edge. Both endpoints must belong to the authenticated principal and share the same environment + project. Self-loops are rejected. Re-creating an existing (from, to, type) triple is a no-op and returns the existing edge.
POST/memory/{memory_id}/relations

Authentication

Accepts a JWT bearer token (Authorization: Bearer eyJ…) or an API key (X-API-Key: ms_live_…). API-key callers should send X-Project-ID unless the key is project-locked. Cross-tenant operators must send X-Tenant-ID.

Path parameters

FieldTypeRequiredDescription
memory_idintegerrequiredSource memory id (from side of the edge).

Request body

FieldTypeRequiredDescription
to_memory_idintegerrequiredTarget memory id. Must differ from path id.
relationship_typestringrequiredOne of similar, derived_from, continuation, contradiction, summary_of, detail_of, caused_by, references, supports, extends.
confidencenumberoptionalCaller confidence in [0.0, 1.0]. Defaults to 1.0.
metadataobjectoptionalFree-form metadata bag stored alongside the edge.
request.json
{
"to_memory_id": 184214,
"relationship_type": "continuation",
"confidence": 0.9
}

Response

Returns 200 OK with the following body.

FieldTypeRequiredDescription
idintegeroptionalEdge id.
from_memory_idintegeroptionalSource memory id.
to_memory_idintegeroptionalTarget memory id.
relationship_typestringoptionalEdge type (one of the whitelisted values).
confidencenumberoptionalCaller-supplied confidence.
metadataobjectoptionalFree-form metadata, may be null.
created_atstringoptionalRFC 3339 UTC.
200.json
{
"id": 4501,
"from_memory_id": 184213,
"to_memory_id": 184214,
"relationship_type": "continuation",
"confidence": 0.9,
"metadata": null,
"created_at": "2026-05-04T12:31:00Z"
}

Errors

StatusCodeDescription
400validation_errorBody or query failed schema validation. The error includes the offending field name.
401unauthenticatedMissing or invalid bearer token / API key.
403forbiddenAuthenticated principal lacks the required scope, role, or project access.
404not_foundTarget resource does not exist or is not visible to the calling tenant.
429rate_limitedPer-IP or per-route limit exceeded. Respect the Retry-After header.
500internal_errorUnhandled server error. Quote the request_id when contacting support.

Examples

cURL
curl -X POST https://api.memorysync.io/memory/EXAMPLE_ID/relations \
-H "Authorization: Bearer $MEMORYSYNC_KEY" \
-H "Content-Type: application/json" \
-d '{
"to_memory_id": 184214,
"relationship_type": "continuation",
"confidence": 0.9
}'
javascript
import { MemorySync } from 'memorysync'
const client = new MemorySync({ apiKey: process.env.MEMORYSYNC_KEY })
const result = await client.request({
method: 'POST',
path: '/memory/EXAMPLE_ID/relations',
body: {
"to_memory_id": 184214,
"relationship_type": "continuation",
"confidence": 0.9
},
})
console.log(result)
python
from memorysync import Client
client = Client(api_key=os.environ["MEMORYSYNC_KEY"])
result = client.request(
method="POST",
path="/memory/EXAMPLE_ID/relations",
json={
"to_memory_id": 184214,
"relationship_type": "continuation",
"confidence": 0.9
},
)
print(result)

Behavior & notes

HTTP status on creation is 201 Created. Required scope: memories:write. Both endpoints are looked up under the calling principal — 404 means the id does not exist, is not owned by the caller, or lives in a different environment/project. Any unsupported relationship_type produces 422.