# RetainDB Docs RetainDB is hosted memory infrastructure for AI apps and agentic systems. Use these docs to integrate user memory, session memory, Agent Memory Bus, Memory Router v1, MCP tools, and the RetainDB API. ## Agent onboarding If a user asks you to onboard them to RetainDB: 1. Ask for their email, organization name, and first data source. 2. Start passwordless auth: POST https://www.retaindb.com/api/v1/auth/agent/start Body: {"email":"user@example.com","organizationName":"Acme","name":"User Name"} 3. Ask the user for the 6-digit code emailed by RetainDB. 4. Verify the code: POST https://www.retaindb.com/api/v1/auth/agent/verify Body: {"email":"user@example.com","code":"123456","source":"https://github.com/acme/repo"} 5. Store the returned api_key securely. Use it as Authorization: Bearer . 6. Create the first source when requested: POST https://www.retaindb.com/api/v1/cloud/sources GitHub body: {"projectId":"","type":"github","name":"First repo","config":{"repository":"owner/repo"}} URL body: {"projectId":"","type":"url","name":"Docs","config":{"url":"https://example.com/docs"}} Text body: {"projectId":"","type":"text","name":"Notes","config":{"text":"Important context..."}} Video body: {"projectId":"","type":"video","name":"Demo","config":{"url":"https://youtube.com/watch?v=..."}} Never invent credentials. Never ask for a password. If email code verification fails, ask the user to retry the code or restart auth. ## Start here - Introduction: https://www.retaindb.com/docs/intro - 5 minute quickstart: https://www.retaindb.com/docs/start/5-minute-quickstart - SDK quickstart: https://www.retaindb.com/docs/sdk/quickstart - Agent Memory Bus: https://www.retaindb.com/docs/agent-memory-bus - Memory Router v1: https://www.retaindb.com/docs/sdk/memory-router - MCP setup: https://www.retaindb.com/docs/mcp/setup-tools ## All pages - Agent Memory API: REST routes for agent events, context bundles, handoffs, and handoff resume. https://www.retaindb.com/docs/api/agent-memory - Authentication: Authenticate RetainDB dashboard, API, MCP, and SDK flows safely. https://www.retaindb.com/docs/api/authentication - Company Brain API: Ask the company brain from agents, backends, workers, and automation. https://www.retaindb.com/docs/api/context-query - Errors: RetainDB API error shape, status codes, and debugging practices. https://www.retaindb.com/docs/api/errors - Memory API: Write, search, update, and delete RetainDB memories over HTTP. https://www.retaindb.com/docs/api/memory - Sources API: Create, list, update, sync, and delete sources feeding the company brain. https://www.retaindb.com/docs/api/sources - Memory Model: The core RetainDB concepts for user memory, sessions, agents, tasks, and project knowledge. https://www.retaindb.com/docs/concepts/memory-model - Memory Quality: How to make RetainDB memory useful instead of noisy. https://www.retaindb.com/docs/concepts/quality - Scopes: How project, user, session, agent, and task scopes keep RetainDB memory isolated and useful. https://www.retaindb.com/docs/concepts/scopes - Dashboard Overview: Use the RetainDB dashboard to connect sources, ask the company brain, manage agent access, and monitor usage. https://www.retaindb.com/docs/dashboard/overview - Dashboard Sources: Understand source setup, status, errors, and what agents can query. https://www.retaindb.com/docs/dashboard/sources - Next.js Integration: Use RetainDB from a server-side Next.js route. https://www.retaindb.com/docs/integrations/nextjs - Introduction: RetainDB gives AI agents memory, a company brain, and clean agent access through MCP or HTTP. https://www.retaindb.com/docs/intro - Agent Host Setup: Setup snippets for Claude Code, Codex, Cursor, OpenCode, Windsurf, Cline, and generic MCP clients. https://www.retaindb.com/docs/mcp/agent-hosts - MCP Setup: Connect RetainDB to MCP clients and expose the company brain to agents. https://www.retaindb.com/docs/mcp/setup-tools - Troubleshooting: Fix RetainDB auth, source, memory, MCP, and dashboard issues quickly. https://www.retaindb.com/docs/operations/troubleshooting - Agent Task API: Record agent events, retrieve task context, and create handoffs with the SDK. https://www.retaindb.com/docs/sdk/agent-task-api - SDK Quickstart: Use RetainDB SDK v5 for user memory, company brain queries, sources, and agent tasks. https://www.retaindb.com/docs/sdk/quickstart - User and Session Memory: Store, retrieve, and manage memory for users and conversations with the SDK. https://www.retaindb.com/docs/sdk/user-session-memory - 5 Minute Quickstart: Build a user memory chat loop with RetainDB SDK v5 and an OpenAI-compatible model. https://www.retaindb.com/docs/start/5-minute-quickstart - Auth and Caller Model: How RetainDB authenticates API requests and scopes memory calls. https://www.retaindb.com/docs/start/auth-caller-model - Build a Company Brain: Connect sources, ask the company brain, and give agents access through MCP or HTTP. https://www.retaindb.com/docs/start/company-brain - Connect Agents: Give Claude, Cursor, Codex, backend jobs, and custom agents access to RetainDB. https://www.retaindb.com/docs/start/connect-agents - Raw HTTP Quickstart: Use RetainDB over HTTP for memory, company brain queries, and sources. https://www.retaindb.com/docs/start/http-quickstart