# AI agents

A Bonga agent is a non-human identity that owns one inbox address, one sending policy and one budget. It is not a user, a member or a seat. You create it directly, with no invitation, and issue a key that works only for it.

> **Note.** Agents cannot approve themselves. An agent key can read its inbox, reply, send, and check a hold. It can never approve or reject, manage members or keys, or read another inbox. A person always decides a held message.


![Bonga agents directory with agent identities, status, sending budgets and approval modes](/images/docs/bonga-agents-directory.png)

## What an agent gets

| Setting | Meaning |
| --- | --- |
| Address | The inbound address the agent owns, for example `support@yourdomain.com` |
| Approval mode | `new_recipients`, `every_email` or `never` |
| History scope | `own` inbox or the whole workspace's inbound history |
| Daily and minute budgets | Hard send caps, enforced transactionally |
| Watch words and amount threshold | Extra reasons to hold a message |
| Dry run | Evaluate policy without handoff |
| Keys | Reveal-once, scoped, expiring, revocable |

## Create an agent

Open **Dashboard → Agents → New agent**. Choose a name and slug, bind an existing inbox or provision a new address on a verified receiving domain, then set the policy and budgets.

The same operation is available on the dashboard API:

```bash
curl -X POST 'https://api.bonga.africa/api/workspace/agents' \
  -H "Authorization: Bearer $DASHBOARD_JWT" \
  -H 'X-Workspace-ID: workspace:abc123' \
  -H 'Content-Type: application/json' \
  --data '{
    "name": "Support",
    "slug": "support",
    "approval_mode": "new_recipients",
    "inbox": { "provision": true, "domain": "example.com", "local_part": "support" }
  }'
```

Provisioning requires inbound email, a paid workspace and a verified receiving domain. If any condition fails, creation fails and no agent is written.

## Issue a key

Keys are shown once. Give each integration its own key and only the scopes it needs:

| Scope | Allows |
| --- | --- |
| `inbox.read` | Read the agent inbox and threads |
| `email.send` | Send new email |
| `email.reply` | Reply in a captured thread |
| `approvals.read` | Read the agent's own holds |

Create a key from the agent page or `POST /api/workspace/agents/{id}/keys`. Revoke it at any time; deleting the agent revokes every key and cancels pending holds.

## Policy

A send is evaluated in this order:

1. Agent paused or budget exhausted → blocked and paused.
2. Watch word in the subject or body → hold.
3. Amount over the configured threshold → hold.
4. Reply address outside the captured thread → hold.
5. Explicit approval request → hold.
6. `every_email` → hold every send and reply.
7. `new_recipients` → allow a reply to the thread recipient; allow a recipient with trusted inbound history or a prior approved send; otherwise hold.
8. `never` → allow, with suppression, blocklists and contact eligibility still applied.
9. Default → hold.

A hold expires after 72 hours and is never sent. A decision rechecks the agent, inbox, policy, recipient, suppression, contact eligibility, sender blocklist, billing and the exact fingerprint before submission. An approved send is idempotent, and a recorded delivery failure is reported rather than shown as success.

## Sending with an agent key

```bash
curl -X POST 'https://api.bonga.africa/api/v1/agent/emails' \
  -H "Authorization: Bearer $BONGA_AGENT_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: ticket-4821' \
  --data '{
    "to": "customer@example.com",
    "subject": "Re: Your refund",
    "text": "We have processed the refund."
  }'
```

A held send returns `202` with `status: pending_approval`, an `approval_id` and a `held_reason`. The message has not been sent. Read it later with `GET /api/v1/agent/approvals/{id}`.

To reply in a thread, first list the inbox, then post to `/api/v1/agent/threads/{thread}/reply`.

## Connect an assistant

- **[MCP](/docs/agents-mcp)** — connect Claude Code, Codex or Cursor to `/api/mcp` with the agent key.
- **REST** — call the routes above from your own orchestration code. See the [agent API guide](/guides/email-agent-with-human-approval).
- **Dashboard** — people review holds in **Agents → Approvals**.

## Next

- [Approvals and policy](/docs/agents-approvals)
- [Agent MCP](/docs/agents-mcp)
- [Build an email agent with human approval](/guides/email-agent-with-human-approval)
