---
title: Concepts
description: The small set of primitives that make CodeSpar make sense — sessions, tools, projects, triggers, authentication. Read these once and the rest of the docs clicks into place.
---

import { Callout } from "fumadocs-ui/components/callout";

# Concepts

<VersionBadge pkg="@codespar/sdk" />

CodeSpar is built around a handful of primitives. Most of the API surface, every framework adapter, and every cookbook can be explained by reference to the concepts on this page. Read them in order the first time — you won't need to come back.

---

## Runtime primitives

The objects your code holds references to.

<NextStepsGrid items={[
  { label: "CONCEPT", title: "Sessions", description: "Scoped connections to MCP servers that manage tool access, authentication, and usage tracking. The thing every agent holds.", href: "/docs/concepts/sessions" },
  { label: "CONCEPT", title: "Tools & Meta-Tools", description: "14 meta-tools that abstract every connected server into a unified commerce interface: pay, charge, checkout, shop, invoice, ship, notify, wallet, and more.", href: "/docs/concepts/tools" },
  { label: "CONCEPT", title: "Tool Router", description: "How a call to codespar_pay becomes a real Stripe / Mercado Pago / Asaas request. Credentials injected server-side; your agent never sees them.", href: "/docs/concepts/tool-router" },
]} />

## Tenancy & isolation

How CodeSpar keeps your customers' data, credentials, and usage separate.

<NextStepsGrid items={[
  { label: "CONCEPT", title: "Projects", description: "The second level of CodeSpar's 2-level tenancy model — an isolation boundary inside an account for API keys, connections, triggers, sessions, and events.", href: "/docs/concepts/projects" },
  { label: "CONCEPT", title: "Authentication", description: "API key management, service authentication, key rotation, and security best practices.", href: "/docs/concepts/authentication" },
  { label: "CONCEPT", title: "Connect Links", description: "Hosted OAuth flow that lets your end users connect their own Stripe, Mercado Pago, Shopify, and other provider accounts.", href: "/docs/concepts/connect-links" },
]} />

## Events & economics

What happens after the request returns.

<NextStepsGrid items={[
  { label: "CONCEPT", title: "Triggers", description: "CodeSpar's outbound webhook subscriptions. Your app receives signed HTTP callbacks when async commerce events settle (payment confirmed, invoice authorized, shipment in transit, message delivered).", href: "/docs/concepts/triggers" },
  { label: "CONCEPT", title: "Billing", description: "Per-settled-transaction pricing, plans, usage tracking, and Stripe-powered billing.", href: "/docs/concepts/billing" },
]} />

---

## The mental model, in one paragraph

Your application holds a `CodeSpar` client. For each end user it creates a **Session** scoped to a set of servers. The session exposes 14 meta-tools (plus optional server-specific ones). When the agent calls a tool, the **Tool Router** on the CodeSpar backend picks the right provider, injects the credentials (from **Service Auth** for your own keys, or **Connect Links** for end-user OAuth), and runs the call. Successful settled transactions fire **Triggers** back to your app. **Projects** isolate one customer from another. **Billing** meters what settled.

That's the whole system. Everything else is framework-specific wiring or provider-specific fields.

<Callout type="info">
Read the concepts in the order above the first time — each one builds on the previous. Skim back in any order after that.
</Callout>

## Next steps

<NextStepsGrid items={[
  { label: "QUICKSTART", title: "5-minute quickstart", description: "Turn the mental model into a running session with the Claude adapter.", href: "/docs/quickstart" },
  { label: "REFERENCE", title: "SDK Reference", description: "Every method, type, and primitive formalized.", href: "/docs/api/sdk" },
  { label: "REFERENCE", title: "HTTP API", description: "The endpoints the SDK wraps — sessions, tools, connections, triggers.", href: "/docs/api/sessions" },
  { label: "GLOSSARY", title: "Glossary", description: "Every domain term used in the docs — Pix, NF-e, SPEI, CFDI, and the CodeSpar-specific terms too.", href: "/docs/glossary" },
]} />
