Skip to Content
MailroomMailroom home

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)

  1. Create a test key scoped to the agent (emails:send, inboxes:read, inboxes:write).
  2. Create the agent + inbox.
  3. Subscribe to inbound.received (webhook or SSE).
  4. On each event, fetch the thread, draft a reply in your model, then POST /threads/{id}/reply.
  5. New recipients sit in pending_approval until a human with approvals:decide acts.
  6. Poll GET /approvals/{id} or handle approval.* 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.

On this page