Concepts
Drafts & approval
Let agents write mail and have a person approve it before it goes out.
Set an inbox to approval and every send, reply or forward from it becomes a draft instead of an email:
await send0.inboxes.update(inbox.id, { send_policy: "approval" });
const result = await send0.messages.reply(msg.id, { text: "We accept your offer." });
// → 202, result.object === "draft", result.status === "pending"A draft.created event fires, so you can notify a person in Slack, a dashboard or by email.
Approve or reject
Approving needs an admin key, so an agent with a send key can't approve its own drafts. Members of your workspace can also approve, edit or reject drafts on the dashboard's Drafts page.
const message = await send0.drafts.send("drf_…"); // runs every sending rule, then sends
await send0.drafts.reject("drf_…");Edit before approving
A pending draft's subject and body can be changed. Whatever is approved is what goes out:
await send0.drafts.update("drf_…", { text: "We accept your offer for 40 units." });List drafts
// The approval queue across every inbox
for await (const d of await send0.drafts.listAll({ status: "pending" })) {
console.log(d.id, d.inbox_id, d.to, d.subject, d.text);
}
// One inbox
const page = await send0.drafts.list(inbox.id, { status: "pending" });Draft statuses: pending, sent, rejected. Each draft records who decided (decided_by) and when (decided_at).