API Reference

Primer REST API

All API endpoints live at https://www.getprimer.cloud/api/v1. Authenticate with Authorization: Bearer pk_live_...

✦ The session pattern — always follow this
1. GET /brief — load context at session start
2. POST /policy/check — before any risky action
3. POST /memory — store facts as you learn them
4. POST /handoff — save summary at session end (always)

Rate Limits

Free
30 req/min
Pro
120 req/min
Startup
300 req/min

Endpoints

GET/api/v1/briefNEWSession start — load all context in one call. Returns pinned facts, recent handoffs, active rules, and workspace info. Call this at the start of every agent session.
Parameters
session_idstring (optional)Your session UUID. Auto-generated if omitted.
agentstring (optional)Agent name for audit logging.
factsnumber (optional)Max pinned facts to return. Default 20.
handoffsnumber (optional)Max recent handoffs. Default 5.
Example
curl "https://www.getprimer.cloud/api/v1/brief?session_id=abc123" \
  -H "Authorization: Bearer pk_live_..."
Response
{
  "session_id": "uuid",
  "workspace": { "name": "my-workspace", "plan": "pro" },
  "pinned_facts": [ { "content": "...", "pt_score": 0.95 } ],
  "recent_handoffs": [ { "from_agent": "...", "summary": "...", "next_steps": "..." } ],
  "active_rules": [ { "pattern": "delete_*", "severity": "block" } ],
  "context_summary": "Last session by gpt-4o: ...",
  "_meta": { "tip": "Call POST /handoff at session end." }
}
POST/api/v1/memoryStore a trusted fact. Every fact is scored with trust score (source × recency × confidence). Pinned facts always surface first in recall.
Parameters
contentstring (required)The fact to store. Max 10,000 chars.
type"fact" | "rule" | "preference" | "context"Semantic type.
source_trust"human" | "agent" | "system"Higher trust = higher recall rank.
pinnedbooleanPinned facts always appear in /brief.
confidencenumber 0–1Initial confidence. Default 0.9 for human, 0.7 for agent.
Example
curl -X POST https://www.getprimer.cloud/api/v1/memory \
  -H "Authorization: Bearer pk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"content":"Customer on enterprise plan","type":"fact","source_trust":"human","pinned":true}'
Response
{
  "fact": {
    "id": "uuid",
    "content": "...",
    "pt_score": 0.94,
    "confidence": 0.9,
    "pinned": true,
    "created_at": "2026-07-02T..."
  }
}
GET/api/v1/memoryRetrieve trusted facts, ranked by trust score. Supports semantic search via TF-IDF re-ranking.
Parameters
querystring (optional)Semantic search query. Re-ranks by relevance × trust score.
typestring (optional)Filter by type.
pinnedboolean (optional)Only return pinned facts.
limitnumber (optional)Max results. Default 20, max 100.
Example
curl "https://www.getprimer.cloud/api/v1/memory?query=enterprise+plan&pinned=true" \
  -H "Authorization: Bearer pk_live_..."
Response
{
  "facts": [ { "id": "uuid", "content": "...", "pt_score": 0.94, "pinned": true } ],
  "count": 1
}
POST/api/v1/policy/checkSafety gate. Check if an action is permitted before executing it. Matches against workspace and org-level rules. Fires webhook on block.
Parameters
actionstring (required)The action to check. e.g. "delete_customer_data"
agentstring (optional)Agent name for audit logging.
session_idstring (optional)Session ID for grouping.
Example
curl -X POST https://www.getprimer.cloud/api/v1/policy/check \
  -H "Authorization: Bearer pk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"action":"delete_customer_data","agent":"cleanup-bot"}'
Response
{
  "allowed": false,
  "action": "delete_customer_data",
  "rule": { "pattern": "delete_*", "reason": "No deletion without approval", "severity": "block" },
  "message": "Blocked: No deletion without approval",
  "audit_logged": true
}
POST/api/v1/handoffSession end — save context for the next agent. Always call this when a session ends. This is how continuity works across sessions.
Parameters
summarystring (required)What happened this session. Max 20,000 chars.
next_stepsstring (optional)What the next agent should do.
session_idstring (optional)Your session UUID.
from_agentstring (optional)Agent name handing off.
Example
curl -X POST https://www.getprimer.cloud/api/v1/handoff \
  -H "Authorization: Bearer pk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"summary":"Updated Acme Corp status.","next_steps":"Follow up on ticket.","session_id":"abc123"}'
Response
{
  "handoff": { "id": "uuid", "from_agent": "gpt-4o", "session_id": "...", "created_at": "..." }
}
GET/api/v1/workspaceWorkspace info — plan, limits, usage. Use to check remaining fact quota.
Example
curl https://www.getprimer.cloud/api/v1/workspace \
  -H "Authorization: Bearer pk_live_..."
Response
{
  "workspace": { "name": "my-workspace", "plan": "pro" },
  "limits": { "facts": null, "api_keys": 10, "rules": 50 },
  "usage": { "facts": 47, "api_keys": 3 }
}

Session Limit (Free plan)

Free accounts get 20 sessions/month. When the limit is reached, GET /api/v1/brief returns HTTP 402. The message field is safe to display directly to the user.

{
  "error": "session_limit",
  "message": "⚠️ Primer: You've used all 20 free sessions this month.\nYour memory is safe.\n▸ Upgrade: https://getprimer.cloud/pricing",
  "upgrade_url": "https://getprimer.cloud/pricing",
  "resets_at": "2026-08-01T00:00:00Z",
  "sessions_used": 20,
  "sessions_limit": 20
}
Integration

Four ways to connect

Same memory, same session gate, same audit trail — regardless of how you connect.

Recommended

IDE / MCP — Cursor, Claude Code, Windsurf, Zed

Fully autonomous. Run primer init once and Primer writes AGENTS.md / GEMINI.md / CLAUDE.md to your repo. Your IDE reads those files at startup and calls primer_agent_brief automatically — no code changes anywhere.

npm install -g getprimer
primer init    # writes instruction files → IDE auto-loads context
primer start   # starts MCP daemon

Python / LangChain

Zero-dependency client. Works with OpenAI, Anthropic, Ollama, Gemini. LangChain callback handler for fully autonomous injection.

pip install getprimer

from getprimer import Primer
p = Primer()  # reads PRIMER_API_KEY env var

ctx = p.brief(agent="my-bot")           # call at session start
p.learn("User prefers async", pinned=True, source_trust="human")
p.check("delete_records")              # True = allowed
p.handoff("Done. Next: add tests.")

Autonomous — no explicit calls (LangChain):

from getprimer.langchain import PrimerCallbackHandler
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(callbacks=[PrimerCallbackHandler()])
# Primer context injected automatically on every chain — no brief() needed

Claude.ai · GPT Actions · n8n · Zapier

Point any platform that supports custom actions / OpenAPI at this URL. Primer tools are auto-generated. No install, no code.

Claude.ai
Settings → Integrations → Add → paste URL
GPT Actions
GPT Editor → Add action → Import from URL
n8n
HTTP Request node → Import OpenAPI → paste URL
Zapier AI
Agents → Add capability → OpenAPI → paste URL
https://getprimer.cloud/openapi.json

Proxy mode — fully autonomous, any stack

The proxy sits between your code and the LLM. Every call gets Primer context injected automatically. Zero code changes. Works with OpenAI, Groq, Together, Ollama, LiteLLM.

primer proxy start   # runs alongside your app

export OPENAI_BASE_URL=http://localhost:3848   # point to proxy
# Your code is unchanged. Every LLM call now has Primer context.

Authentication

All requests require a Bearer token. Generate API keys in your dashboard.

Authorization: Bearer pk_live_<your_key>
Generate API Key →