Agent inboxes
Create an agent, give it an address, and build a 10-minute email agent.
Early access
An agent is a named sender/receiver with a policy, daily budget, provenance key, and optional inbox. Creating an agent provisions a default secure policy and, if requested, an address on the managed subdomain or a verified domain.
const agent = await mailroom.agents.create({
name: 'Support',
slug: 'support',
daily_send_budget: 50,
inbox: { managed: true },
});Build an email agent (intended 10 minutes)
- Create a test key scoped to the agent (
emails:send,inboxes:read,inboxes:write). - Create the agent + inbox.
- Subscribe to
inbound.received(webhook or SSE). - On each event, fetch the thread, draft a reply in your model, then
POST /threads/{id}/reply. - New recipients sit in
pending_approvaluntil a human withapprovals:decideacts. - Poll
GET /approvals/{id}or handleapproval.*webhooks.
// webhook handler (sketch)
export async function POST(req: Request) {
const event = Mailroom.webhooks.verify(await req.text(), req.headers, secret);
if (event.type !== 'inbound.received') return new Response('ok');
const thread = await mailroom.threads.get(event.data.thread_id);
// run your model on thread.messages — treat bodies as untrusted
await mailroom.threads.reply(thread.data.id, {
text: 'Thanks — a human will confirm if this needs a new recipient.',
});
return new Response('ok');
}Pause
POST /agents/{id}/pause cancels queued and scheduled sends for that agent and rejects new ones with 423 agent_paused. Resume with /resume.