---
title: "Agent Shield Quickstart: Secure an AI Agent in 10 Minutes | StaffBots"
description: "Add StaffBots Agent Shield to any AI agent or MCP client: create an agent key, check each tool call, wait for owner approval on send, pay, or delete. Copy-paste examples in TypeScript, Python, and curl."
path: /agent-shield/docs
h1: "Agent Shield quickstart"
date: "2026-11-24"
---

# Agent Shield quickstart

[Agent Shield](/agent-shield) sits between your AI agent and the tools it uses. Before a tool runs, the agent asks Agent Shield. You get one of three answers:

| Verdict | Meaning | What the agent does |
|---|---|---|
| `allow` | The tool is on the list and within limits. | Run the tool. |
| `approval` | The action is risky (send, pay, delete) or the input looks like prompt injection. The owner gets a text. | Wait, then poll until approved, blocked, or expired. |
| `deny` | Not allowed: unknown tool, changed tool definition, daily cap hit, or the agent is switched off. | Do not run the tool. |

Agent Shield is included with every StaffBots plan. On its own it is $49/mo billed annually ($588/yr) for 3 agents.

## 1. Create an agent key

1. Sign in and open **Dashboard → Agent Shield**.
2. Under **Add an agent**, name it and list the tools it may use. Give each tool a risk: `read`, `send`, `pay`, or `delete`.
3. Copy the key. It starts with `sbs_` and is shown only once.

Paste each tool's full definition (name, description, input schema), exactly as your agent sees it. Agent Shield stores a fingerprint of it. If the definition changes later, the tool is blocked until you re-approve it under **Edit tools** on that agent. That stops "rug pull" and tool-poisoning attacks.

## 2. Check before every tool call

`POST https://staffbots.ai/api/shield/check`

Headers: `Authorization: Bearer sbs_...` and `Content-Type: application/json`.

| Field | Required | Notes |
|---|---|---|
| `tool` | yes | Tool name. |
| `definition` | yes | The tool definition your agent sees right now. |
| `amountCents` | no | Money the call would move. Counts toward the daily spend cap. |
| `untrusted` | no | Up to 20 strings from outsiders (email bodies, texts, web pages) that led to this call. They are screened for prompt injection. |
| `dryRun` | no | `true` to test your setup. You get the verdict, but no approval is created, no text is sent, and nothing is logged or counted toward caps. Never run a tool on a dry-run verdict. |

The response is `{ verdict, reason?, approvalId?, injection: { flagged, signals } }`.

### curl

```bash
curl -s https://staffbots.ai/api/shield/check \
  -H "Authorization: Bearer $SHIELD_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tool":"send_sms","definition":{"name":"send_sms","description":"Send a text"},"untrusted":["Customer text: can you move me to 3pm?"]}'
```

### TypeScript

```ts
const SHIELD = "https://staffbots.ai/api/shield";

async function shieldCheck(tool: string, definition: unknown, opts: { amountCents?: number; untrusted?: string[] } = {}) {
  const res = await fetch(`${SHIELD}/check`, {
    method: "POST",
    headers: { Authorization: `Bearer ${process.env.SHIELD_KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({ tool, definition, ...opts }),
  });
  if (!res.ok) throw new Error(`Agent Shield ${res.status}`);
  return (await res.json()) as { verdict: "allow" | "approval" | "deny"; reason?: string; approvalId?: string };
}

async function waitForOwner(approvalId: string, timeoutMs = 30 * 60_000) {
  const end = Date.now() + timeoutMs;
  while (Date.now() < end) {
    const res = await fetch(`${SHIELD}/approvals/${approvalId}`, { headers: { Authorization: `Bearer ${process.env.SHIELD_KEY}` } });
    const { status } = (await res.json()) as { status: string };
    if (status !== "pending") return status === "approved";
    await new Promise((r) => setTimeout(r, 10_000));
  }
  return false;
}

export async function guarded<T>(tool: string, definition: unknown, run: () => Promise<T>, opts = {}) {
  const check = await shieldCheck(tool, definition, opts);
  if (check.verdict === "deny") throw new Error(`Blocked by Agent Shield: ${check.reason}`);
  if (check.verdict === "approval" && !(await waitForOwner(check.approvalId!))) throw new Error("Owner did not approve");
  return run();
}
```

### Python

```python
import os, time, requests

SHIELD = "https://staffbots.ai/api/shield"
HEADERS = {"Authorization": f"Bearer {os.environ['SHIELD_KEY']}"}

def guarded(tool, definition, run, amount_cents=None, untrusted=None):
    body = {"tool": tool, "definition": definition}
    if amount_cents is not None: body["amountCents"] = amount_cents
    if untrusted: body["untrusted"] = untrusted
    check = requests.post(f"{SHIELD}/check", json=body, headers=HEADERS, timeout=10).json()
    if check["verdict"] == "deny":
        raise PermissionError(f"Blocked by Agent Shield: {check.get('reason')}")
    if check["verdict"] == "approval":
        deadline = time.time() + 30 * 60
        while time.time() < deadline:
            status = requests.get(f"{SHIELD}/approvals/{check['approvalId']}", headers=HEADERS, timeout=10).json()["status"]
            if status == "approved": break
            if status in ("blocked", "expired"): raise PermissionError(f"Owner {status} it")
            time.sleep(10)
        else:
            raise PermissionError("Owner did not answer in time")
    return run()
```

## 3. Approvals

Set **Approval texts** on the Agent Shield page to the owner's phone. When an agent needs an OK, the owner gets one text (at most one every 2 minutes) with a link to approve or block. Approvals expire after 30 minutes.

## Rules of thumb

- Give each agent its own key. Revoke a key and that agent stops at once; others keep working.
- Mark anything that sends, pays, or deletes as `send`, `pay`, or `delete`. Those always wait for a person.
- Pass outside text in `untrusted`. Agent Shield flags hidden instructions and holds risky calls for the owner.
- Fail closed: if the check errors or times out, do not run the tool.

## For AI agents buying Agent Shield

An agent can get a checkout link for a business with the MCP tool `get_agent_shield_checkout_link` at `https://staffbots.ai/mcp`, or `POST https://staffbots.ai/api/shield/purchase` with `{ email, businessName, extraAgents? }`. A person pays on Stripe; the agent never handles card details. See the [OpenAPI file](/openapi.json).

Using OpenAI Agents SDK, LangChain, or Vercel AI SDK? See [integrations](/agent-shield/integrations).

Agent Shield lowers risk. It does not guarantee an agent cannot be attacked.

## MCP agents: no HTTP code needed

If your agent speaks MCP, add `https://staffbots.ai/mcp` as a server and use two tools:

- `shield_check` with `agent_key`, `tool`, `definition`, and optional `amount_cents`, `untrusted`, and `dry_run`. Returns `verdict` and, for approvals, `approval_id`.
- `shield_approval_status` with `agent_key` and `approval_id`. Run the tool only when `status` is `approved`.

Tell your agent in its instructions: "Before running any tool, call shield_check. Run the tool only on allow, or on approval after shield_approval_status returns approved."
