Skip to main content

Overview

The profile endpoint returns a pre-formatted context string for session start injection. It assembles user preferences, guidelines, recent memories, gate rules, and project-specific context into a ready-to-use prompt section.

Endpoint

method
string
GET
path
string
/api/memory/profile
authentication
string
API Key required

Query Parameters

project
string
Project identifier for project-specific context (e.g., org/repo)
token_budget
integer
default:"2500"
Maximum token budget for the context. Content is truncated if exceeded (~4 chars per token).

Response

success
boolean
Indicates if the operation was successful
context
string
Pre-formatted context string with markdown sections ready for injection into the session prompt
components
object
Count of each component type included in the context:
components.preferences
integer
Number of user preferences included
components.foundation_guidelines
integer
Number of foundational principles included (tagged with foundation or constitution)
components.guidelines
integer
Total guidelines included (foundation + regular)
components.recent_memories
integer
Number of recent memories from last 24 hours
components.gate_rules_count
integer
Total number of active gate rules (summary only, not full rules)
components.project_context
integer
Number of project-specific memories included
token_estimate
integer
Estimated token count for the context string (~4 chars per token)

Context Structure

The context string includes the following sections (when available):
  1. Your Preferences - Up to 5 user preferences from the preferences category
  2. Foundational Principles - Up to 5 foundation guidelines (tagged foundation or constitution)
  3. Guidelines - Up to 5 regular guidelines (non-foundational)
  4. Gate Rules - Count summary with note that rules are checked automatically on tool use
  5. Recent Context (last 24h) - Up to 5 recent memories excluding preferences, guidelines, and gate-rules
  6. Project Context - Up to 3 project-specific memories (if project parameter provided)
  7. Memory Conflicts Detected - Up to 3 unresolved conflicts (if any exist)

Foundation Guidelines

Guidelines are considered foundational when:
  • Tagged with foundation or constitution, OR
  • Source ref starts with foundation:constitution
Foundation guidelines are prioritized in the profile context.
curl -X GET "https://api.cems.dev/api/memory/profile?project=acme/webapp&token_budget=2500" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "success": true,
  "context": "## Your Preferences\n- Use TypeScript for all new code\n- Prefer functional programming patterns\n\n## Foundational Principles\n- Always prioritize user privacy and data security\n- Write clear, self-documenting code\n\n## Guidelines\n- Run tests before committing\n- Use semantic commit messages\n\n## Gate Rules\n4 gate rules active (checked automatically on tool use)\n\n## Recent Context (last 24h)\n- [testing] Added integration tests for authentication flow\n- [documentation] Updated API documentation for new endpoints",
  "components": {
    "preferences": 2,
    "foundation_guidelines": 2,
    "guidelines": 4,
    "recent_memories": 2,
    "gate_rules_count": 4,
    "project_context": 0
  },
  "token_estimate": 185
}

Build docs developers (and LLMs) love