# Owner approvals: a human in the loop for agents that post, spend and file

> Human-in-the-loop approvals keep AI agents productive while preventing accidental live charges, unauthorized filings, and unwanted public posts.

**A human in the loop for AI agents works by restricting agent keys to development tasks and generating direct approval links whenever an agent attempts to spend money, publish live content, or file legal documents.** thelastapi gives agents a sandbox where they can build, deploy preview code, and draft marketing materials without human intervention. When an agent attempts an irreversible live action, the API halts execution with an actionable `403 owner_only` error that provides the human owner with a direct approval link.

Giving an autonomous agent unattended access to terminal commands or API endpoints carries real operational risk. Without clear structural boundaries, a misaligned prompt or hallucinated instruction could trigger unintended financial payouts, modify production databases, or publish draft copy to public channels. Implementing human approvals creates a safe boundary: agents can draft, analyze, and test autonomously, but final execution on consequential actions stays with the human owner.

## What agents can do freely versus what needs approval

thelastapi separates capabilities between what an agent can perform on its own and what requires explicit owner sign-off. When you connect an agent through the Model Context Protocol (MCP) or the CLI, you choose between **Full access** and a **Limited** key. A Limited key keeps the agent focused on development and drafting while reserving high-stakes operations for human approval.

| Action category | What an agent can do freely | What requires owner approval |
| --- | --- | --- |
| **Hosting & Code** | Create projects, deploy to preview and production, read deployment code | Connect external hosts, delete production domains |
| **Database** | Read and write the development database branch | Read production database rows, sign out live app users |
| **Payments** | Create products, generate prices, test simulated checkouts and refunds | Issue live refunds, process live bank withdrawals, cancel subscriptions |
| **Social & Ads** | Draft social updates, create test campaigns, run sandbox actions | Publish live social updates, activate ad campaigns, modify live budgets |
| **Email** | Draft newsletters, build automations, send test messages to the owner | Send live broadcasts (beyond monthly allowance), update legal postal address |
| **Company** | Draft company documents, simulate filings in sandbox mode | Submit real legal filings, sign tax forms (SS-4, 8821), pay filing fees |
| **API Connectors** | Query safe endpoints, test APIs in development mode | Call sensitive operations, modify production connector secrets |

To learn more about protecting customer records during development runs, see [why agents should never touch production rows](https://thelastapi.dev/blog/agents-never-touch-production-rows).

## How approval errors work: structured 403 responses

Traditional APIs fail silently or return a generic `403 Forbidden` string when a permission is missing. An agent reading that response usually retries the exact same call until it runs out of tokens or loops indefinitely.

thelastapi returns structured JSON designed specifically for autonomous workflows. When an agent using a Limited key hits an action restricted to the account owner, the API returns `403 forbidden` with `details.reason: "owner_only"`. The response tells the agent exactly which permission was missing, where the owner can review it, and what instruction to display in the conversation:

```json
{
  "error": {
    "code": "forbidden",
    "message": "This action requires owner permission.",
    "details": {
      "reason": "owner_only",
      "permission": "payments.live:write",
      "key_id": "key_agent_123",
      "grant_url": "https://thelastapi.dev/keys/key_agent_123/allow?permission=payments.live:write",
      "console_url": "https://thelastapi.dev/projects/prj_123/payments",
      "key_url": "https://thelastapi.dev/keys?key=key_agent_123",
      "next_step": "Give the human operator the grant_url so they can authorize payments.live:write for this key."
    }
  }
}
```

Because the error contains `grant_url` and `next_step`, the agent pauses cleanly and prints the link in the terminal or chat interface. You open the link, review the request, and grant the permission or reject it. Once authorized, the agent retries the call and succeeds. For a detailed breakdown of this design, read [agent-friendly APIs: errors that say what to do next](https://thelastapi.dev/blog/agent-friendly-api-errors).

## Human approval in practice: social, spending, and company filings

Human-in-the-loop controls function across three primary areas: content publishing, payments, and legal filings.

### 1. Social updates and advertising spend
An agent managing your marketing can draft posts, compile competitor ads using `vibiz ads`, and prepare Google Ads campaigns. However, pushing copy live or spending money on advertising requires human confirmation:

- **Social posts:** When a Limited key runs `vibiz social post`, the post is created in a pending state. It is not published until an owner approves it:
  ```bash
  vibiz social posts --status pending
  vibiz social approve post_123
  ```
- **Ad budgets:** When an agent creates a search campaign using `vibiz social campaigns create`, the campaign is created paused. Activating it or raising a daily budget requires owner confirmation:
  ```bash
  vibiz social resume camp_456
  vibiz social budget camp_456 --budget 5000
  ```

### 2. Live payments and bank withdrawals
Agents can generate checkout links and test payment flows in development mode without restrictions. In production, an agent cannot initiate live balance withdrawals or trigger customer refunds. 

If an agent attempts a withdrawal, the system halts. An owner must execute or confirm the withdrawal directly using a full-access key:

```bash
vibiz payments withdraw --amount 25000
# Displays the target bank and dollar amount, asking you to explicitly confirm.
```

### 3. Business registration and legal documents
Agents can research entity requirements and assemble drafts using `vibiz company draft --file company.json`. In development mode, the agent can call `vibiz company simulate formation` to verify downstream app logic. 

When moving to production, an agent cannot file the company on its own. Calling `vibiz company submit` in production requires human confirmation: the CLI displays the actual state filing fees and forces the owner to type the company name manually. Sensitive paperwork like tax authorizations must be signed directly by the human owner via a private link generated by `vibiz company sign ss4`.

## Granting granular permissions without full access

You do not need to promote an agent to full owner access just to let it perform one routine production task. On the API keys page or through the CLI, you can attach specific granular permissions (`grants`) to a Limited key.

```bash
# Check existing permissions on an agent key
vibiz keys access key_agent_123

# Allow the agent to read the production database without write or payment access
vibiz keys access key_agent_123 allow database.production:read

# Allow the agent to manage live social posts
vibiz keys access key_agent_123 allow social.live:write
```

You can also use HTTP requests to assign specific grants directly:

```bash
curl -X PATCH https://thelastapi.dev/v1/api-keys/key_agent_123 \
  -H "Authorization: Bearer $OWNER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"grants": ["social.live:write", "database.production:read"]}'
```

If an agent needs broad read-only visibility into logs, settings, and metrics without the risk of mutating live data, set its preset to `read_all` (`vibiz keys access key_agent_123 read`). This gives the agent read access to production databases and payment summaries while blocking refunds, cancellations, and live file uploads. You can read more about key security in [one API key for an AI agent: hosting, database, email, payments and models](https://thelastapi.dev/blog/one-api-key-for-ai-agent).

## Secrets without leaking: console links instead of chats

A frequent failure point in agent workflows is secret handling. When an app needs a third-party token or database password, an agent often asks the user to paste the key directly into the chat prompt. This exposes the secret to model training logs, context history, and prompt caching.

thelastapi resolves this with dedicated secret links. The agent calls the tool `vibiz_request_secret` or runs the CLI command:

```bash
vibiz env link THIRD_PARTY_KEY --dev
```

This returns a secure one-time URL:
```text
https://thelastapi.dev/projects/prj_123/secrets/new?name=THIRD_PARTY_KEY&env=production&kind=env
```

The agent displays this link in the chat. You open the page, paste your API token securely into the web console, and save it. The key goes directly to the application environment without ever touching the LLM context window.

To explore setup guides for MCP clients like Claude Code, Codex, and Cursor, read the [Agents documentation](https://thelastapi.dev/docs/agents) or review the [Keys and environments reference](https://thelastapi.dev/docs/keys). You can create your account at [thelastapi.dev/start](https://thelastapi.dev/start).

## Frequently asked questions

### What happens if an agent tries to spend money without owner approval?

The API rejects the call with a `403 forbidden` status and `details.reason: "owner_only"`. It returns a `grant_url` that the agent presents to the human owner to review and authorize the specific permission.

### Can an AI agent file a real company without me seeing it?

No. In production, `vibiz company submit` displays the state fees and requires the human owner to type the business name to confirm the filing, and tax forms must be signed by the human via a personal link.

### How do I let an agent draft social media posts without letting it publish them immediately?

Assign the agent a Limited key. When a Limited key calls `vibiz social post`, the content is saved in a pending state until an owner reviews and approves it using `vibiz social approve <post_id>`.

### Can I approve permissions on a temporary or per-task basis?

Yes. You can open the `grant_url` returned in an error to approve a single missing permission for that key, or revoke grants at any time using `vibiz keys access <key_id> limited`.

---

Published 2026-11-15 · https://thelastapi.dev/blog/human-in-the-loop-agent-approvals
