Core Concepts
The mental model behind Tinbox, from inboxes and threads to the git archive, audiences, campaigns, the send ledger, capability tokens, and the agent-first design.
Tinbox is a self-contained email stack you deploy to your own Cloudflare account: an inbox, a transactional sending API, and newsletters, with no third-party relay in the path. This page is the orientation map. Each concept is a short paragraph; the guides it links to go deeper.
Inboxes and routing
An inbox is an address that receives mail. Mail arrives through Cloudflare Email Routing, hits the ingest worker, and lands in the inbox whose address it was sent to. Routing is structural: which addresses exist and where mail lands is git-checked config, compiled into the worker bundle, changed by a pull request and a deploy. Granting a teammate access to an existing inbox is operational: that happens at runtime, instantly, through the API. The two are deliberately separate systems.
Threads and messages
A message is a single received or sent email. Tinbox groups messages into
threads by owning the Message-ID, so replies stitch into a conversation
deterministically. Threads carry shared-inbox workflow state (open / closed,
assignment, unread) on top of the raw messages. Internal notes are a message
kind that never leaves the app. Read a thread with
tinbox thread <id> or the
get_thread tool; list them with
tinbox threads.
The git archive
Received and sent messages are immutable facts, so Tinbox projects them to a git
repository: an append-only archive/. The sync only ever appends new files, so
it cannot drift from the live state. Agents read mail history as plain files with
ripgrep, no credentials needed. The other direction, outbox/, is a one-way
authoring lane: PR-authored drafts and newsletters are born there and consumed
into the database on merge. Git is never a two-way mirror of live state. The
git-sync worker is an optional module.
Audiences, contacts, and members
An audience is a mailing list (the Mailchimp-style "list" concept). A contact is
a person; a member is that contact's membership in one audience, with a status
(subscribed, pending, unsubscribed, transactional) and per-audience merge
fields. You populate audiences by importing existing
lists or by capturing leads through hosted forms. Segments are saved
multi-condition filters over an audience. See
tinbox audiences and the
list_audiences tool.
Campaigns vs. transactional sending
Two different jobs share one sending substrate. Transactional email is one-to-one, sent by your other apps through the sending API: receipts, password resets, alerts. Campaigns (newsletters) are one-to-many: authored, reviewed, then fanned out to an audience. Campaigns carry a review gate, analytics, and one-click unsubscribe that transactional sends do not. See Send a newsletter.
The send ledger and idempotency
Every send, a single transactional message or a 4,000-recipient campaign, writes
a row to a ledger keyed by a stable idempotency key before dispatch, and
checks the ledger before each send. Queues retry, merges can fire twice, CI
re-runs; the ledger is what turns "retry-safe" into a guarantee instead of a
hope. The sending API mints an idempotency key for you (or you pass your own);
campaign fan-out keys one row per (campaign, recipient), so a re-run only
enqueues un-sent rows. It never double-sends.
For transactional SDK sends, a caller-supplied key is trimmed and stored as the
logical send id. A retry with the same key short-circuits a sent or pending
row, but can reclaim a failed or canceled row. There is no client-side
dedupe window: the ledger is the durable source of truth until rows are
intentionally pruned by operations.
Capability tokens and roles
Every API call, from the app, the CLI, or an MCP agent, funnels through one
authorize(caller, inbox, action) check. Access is two axes. Roles per
inbox: viewer (read), agent (read + draft + reply), admin (+ grant others
on that inbox). Capabilities granted explicitly on top: newsletter:send,
api:send, import. A token (tbx_…) carries a role and coarse scopes; it gets
no special powers over the human who minted it.
Choose the credential for the actor and purpose:
| Token | Created with | Grants access to |
|---|---|---|
| Account CLI credential | tinbox login --api-url https://mail.example.com --browser and browser approval | the current signed-in account’s mailbox and administration authority; changes to that account take effect on every request |
| Inbox agent token | tinbox tokens create --inbox … | inbox mail: read threads, draft replies, send replies, MCP/agent workflows |
| Sending API key | Settings → API keys, or tinbox tokens create-send-key | transactional sending through tinbox/sdk, scoped to an identity, domain, or account |
Use an account credential to connect your own tooling and bootstrap restricted workers. The CLI prints a URL and comparison code. Open the URL in an already signed-in browser, compare the code, then approve the displayed account, deployment, permissions and duration. Approval expires after ten minutes; the credential lasts one hour, one day (the default), or thirty days. Denying, cancelling, or timing out does not create a credential. The CLI stores the result privately; browser cookies and passwords are never copied to the CLI.
An account credential follows current account membership, team grants, inbox
roles and capabilities. It does not copy them into permanent token grants and
cannot enroll a removed account again. Revoking it with tinbox logout stops
future use. To disconnect a lost or another device, open Settings → Security →
CLI connections in the signed-in web app; this does not require organization
admin rights or a verified sending domain. Account access includes writes and administration where that account
already permits them. Browser-only confirmations still require an interactive
session. Login does not grant a new sending scope or capability, change an
existing key, or dispatch any mail.
Give an unattended worker its own inbox token instead of your account credential:
tinbox tokens create --inbox social@example.com --role viewer --ttl 30d --json.
This requires current inbox-admin authority and returns the secret once. That
worker can read the selected inbox’s threads and bodies but cannot reply or
create a more privileged key. Its explicit delegation is independently revocable;
removing the issuer’s account role does not silently revoke unrelated service
credentials. Use a sending API key when application code should send new
transactional email. Domain and account choices on sending keys select From
addresses, not readable inboxes.
Agent-first: every capability is a tool
Tinbox is built agent-first, human-supervised. Every capability is exposed as a
tool in one shared manifest, consumed by three surfaces: the in-app chat
assistant, the MCP server, and the
tinbox CLI. Read-only tools (search, summarize, list)
run freely; destructive ones (sending) are flagged so the client confirms first.
Irreversible structure stays human-gated; reversible actions stay
permission-gated. Browse them all in the tool reference.
Extend & automate
Tinbox is meant to be programmed. Past reading and sending mail, you teach a deployment new behavior with a small set of extension points. The rule of thumb: a skill annotates or acts on one resource (a message, a thread); a plugin is a bundle that adds a whole surface (routes, cron, send-hooks, its own tables).
| I want to… | Use | Where |
|---|---|---|
| Tag/annotate/draft on inbound mail | a reactive-mail skill | config.skills |
| Give the AI assistant a new tool | an agentic skill (agenticSkill()) | config.skills |
| Add a button to a thread | a command skill (commandSkill()) | config.skills |
| Customize the interactive chat assistant | config.assistant | tinbox.config.ts |
| Work the inbox on a schedule | autopilot | config.autopilot + Settings → Autopilot |
| Run a dedicated autonomous agent on one inbox | defineAgents | config.agents |
| Add routes / cron / send-hooks / own tables | a plugin | config.plugins |
| Wire a credential | a secret (requiresEnv) | Settings → Secrets |
The four AI surfaces are deliberately distinct: the assistant (config.assistant)
is the interactive chat/MCP agent; autopilot (config.autopilot) is that
assistant put on a cron with standing orders; agents (config.agents,
defineAgents) are dedicated autonomous agents each bound to one inbox; and agentic
skills are the tools all of them call. See Working with agents
for the full breakdown. (Note: config.agents is a declaration only today — the agent
itself is an agents row you create via onboarding or agents.create; see
Working with agents. Tracked in TBX-87.)
Next steps
- Send transactional email with the
tinbox/sdkclient. - Send a newsletter to an audience.
- Automation & agents — the four AI surfaces, plus chat, MCP, and the CLI.
- Import existing mail and lists.