API Reference

RESTful API for integrating Memory into your applications. All endpoints require authentication via JWT bearer token.

Base URL

https://ai.senuamedia.com/api

Authentication

POST /auth/login

Authenticate and receive a JWT access token.

Request Body

FieldTypeDescription
username_or_email requiredstringUsername or email address
password requiredstringAccount password
mfa_codestringTOTP code if MFA enabled

Response

{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "bearer",
"expires_in": 86400,
"user": {
"id": "545ebe7c-d75f-4f8f-aca5-fc1da58c8d5c",
"username": "admin",
"email": "user@example.com",
"role": "admin"
}
}

Chat & Queries

POST /chat

Send a message and receive an AI response with personal context.

Headers

HeaderValue
AuthorizationBearer {access_token}
Content-Typeapplication/json

Request Body

FieldTypeDescription
message requiredstringUser message/query
conversation_idstringContinue existing conversation
modelstringOverride default model
include_memorybooleanInclude memory context (default: true)
streambooleanStream response tokens

Response

{
"id": "msg_abc123",
"conversation_id": "conv_xyz789",
"response": "Based on your recent work...",
"model": "mistral:7b",
"memory_used": {
"short_term": 5,
"long_term": 12,
"sources": ["email", "github"]
},
"tokens": {
"prompt": 1250,
"completion": 380
}
}

Memory Management

GET /memory/search

Search your memory using semantic similarity.

Query Parameters

ParameterTypeDescription
q requiredstringSearch query
limitintegerMax results (default: 10)
sourcestringFilter by source type
from_datestringISO date filter
to_datestringISO date filter

Response

{
"results": [
{
"id": "mem_123",
"content": "Meeting notes from...",
"source": "notion",
"similarity": 0.89,
"timestamp": "2025-01-15T10:30:00Z"
}
],
"total": 47
}
GET /memory/stats

Get memory statistics and usage metrics.

Response

{
"total_memories": 15420,
"short_term": 48,
"long_term": 15372,
"by_source": {
"email": 5200,
"github": 3100,
"notion": 2400,
"slack": 4720
},
"last_sync": "2025-01-15T14:30:00Z"
}

Data Sources

GET /sources

List all connected data sources and their status.

POST /sources/{source_type}/connect

Connect a new data source. Returns OAuth URL for cloud services.

POST /sources/{source_id}/sync

Trigger a sync for a connected data source.

Model Configuration

GET /models

List available LLM models.

Response

{
"models": [
{
"id": "mistral:7b",
"provider": "ollama",
"size": "4.1GB",
"status": "ready"
},
{
"id": "claude-3-sonnet",
"provider": "anthropic",
"status": "available"
}
],
"default": "mistral:7b"
}

Error Responses

All errors follow a consistent format:

{
"error": {
"code": "unauthorized",
"message": "Invalid or expired token",
"details": {}
}
}
Status CodeError CodeDescription
400bad_requestInvalid request parameters
401unauthorizedMissing or invalid authentication
403forbiddenInsufficient permissions
404not_foundResource not found
429rate_limitedToo many requests
500internal_errorServer error

Rate Limits

API requests are rate limited to protect the service:

  • Chat endpoints: 60 requests/minute
  • Memory search: 120 requests/minute
  • Sync operations: 10 requests/minute

OpenAPI Specification

Full OpenAPI 3.0 spec available at /api/openapi.json. Interactive docs at /api/docs (Swagger UI).