Sync Endpoints
Endpoints for synchronizing memory between local and cloud storage.
Sync Architecture
Kernle uses a local-first sync model:
- All changes write to local SQLite first
- Changes queue for sync
- Push sends queued changes to cloud
- Pull retrieves remote changes
Conflict Resolution: Last-write-wins based on local_updated_at timestamp.
Get Sync Status
Check sync status and pending operations.
Authorization: Bearer sk-your-api-key
Query Parameters
| Parameter | Type | Description |
|---|
agent_id | string | Required. Agent identifier |
Response
{
"success": true,
"data": {
"agent_id": "claire",
"pending_operations": 5,
"last_push": "2024-01-15T10:30:00Z",
"last_pull": "2024-01-15T10:25:00Z",
"remote_changes_available": 3,
"status": "connected"
}
}
CLI Equivalent
kernle -a claire sync status
Push Changes
Push local changes to cloud.
Authorization: Bearer sk-your-api-key
Content-Type: application/json
Request Body
{
"agent_id": "claire",
"operations": [
{
"table": "episodes",
"record_id": "ep_abc123",
"operation": "upsert",
"data": {
"objective": "Debugged API issue",
"outcome": "success",
"outcome_type": "success",
"lessons": ["Check logs first"],
"created_at": "2024-01-15T10:30:00Z",
"local_updated_at": "2024-01-15T10:30:00Z"
}
}
],
"limit": 100
}
Response
{
"success": true,
"data": {
"pushed": 5,
"failed": 0,
"remaining": 0,
"results": [
{
"record_id": "ep_abc123",
"status": "synced",
"remote_id": "cloud_ep_abc123"
}
]
}
}
CLI Equivalent
kernle -a claire sync push
Pull Changes
Pull remote changes to local.
Authorization: Bearer sk-your-api-key
Content-Type: application/json
Request Body
{
"agent_id": "claire",
"since": "2024-01-15T00:00:00Z",
"full": false
}
| Field | Type | Description |
|---|
agent_id | string | Required. Agent identifier |
since | ISO timestamp | Pull changes after this time (default: last pull time) |
full | boolean | If true, pull all records regardless of timestamp |
Response
{
"success": true,
"data": {
"pulled": 12,
"tables": {
"episodes": 5,
"beliefs": 3,
"notes": 4
},
"last_sync": "2024-01-15T10:30:00Z"
}
}
CLI Equivalent
# Incremental pull
kernle -a claire sync pull
# Full pull
kernle -a claire sync pull --full
Full Sync
Perform bidirectional sync (pull then push).
Authorization: Bearer sk-your-api-key
Content-Type: application/json
Request Body
Response
{
"success": true,
"data": {
"pull": {
"records": 8,
"tables": ["episodes", "beliefs"]
},
"push": {
"records": 3,
"tables": ["notes", "raw_entries"]
},
"conflicts_resolved": 0,
"sync_completed_at": "2024-01-15T10:30:00Z"
}
}
CLI Equivalent
kernle -a claire sync full
Supported Tables
The sync API supports these memory tables:
| Table | Description |
|---|
episodes | Autobiographical experiences |
beliefs | Semantic knowledge with confidence |
notes | Quick captures (decisions, insights) |
agent_values | Core principles |
goals | Active objectives |
drives | Intrinsic motivations |
relationships | Models of other entities |
playbooks | Procedural memory |
raw_entries | Unprocessed captures |
checkpoints | Saved state |
Webhook Notifications (Coming Soon)
Configure webhooks to receive notifications when sync events occur:
{
"webhook_url": "https://your-app.com/kernle-webhook",
"events": ["sync.completed", "memory.created", "conflict.detected"]
}