API documentation

Guardian is the enforcement point between your agents and the actions they attempt. Submit activity, receive a decision, and stream the outcome to your SOC.

Overview
An agent lifecycle with Guardian in the loop.
  1. 1. Register the agent — Guardian issues an identity with an authorization scope, data-access ceiling and trust score.
  2. 2. Submit the action — before your agent executes something consequential, send the action to Guardian.
  3. 3. Act on the decision — allowed proceeds, alert proceeds with a recorded warning, blocked must not run.

Base URL

https://theaiguardians.com/functions

Authentication
Every request carries an API key created in this console.

Send the key as a bearer token. Keys are scoped — ingest requires events:write and guard mode requires guard:write.

http
Authorization: Bearer gd_live_9f2c41d08b7a4e5c9a1b3d6f2e8c0a74

Production keys are prefixed gd_live_ and sandbox keys gd_test_. Revoke a key at any time from the API keys page; revocations apply immediately.

Official SDKs
Guard an action in five lines. Zero dependencies, zero config beyond your API key.

Both SDKs wrap the endpoints below — guard() before an action executes, report() for batches of completed actions — with timeouts, typed errors and friendly field names. On a network failure they throw, so you choose whether to fail open or closed.

npm — JavaScript / TypeScript

javascript
npm install @theaiguardians/sdk

import { Guardian } from "@theaiguardians/sdk";

const guardian = new Guardian(process.env.GUARDIAN_API_KEY);

// Before your agent runs anything consequential:
const decision = await guardian.guard({
  agentId: "agt_5d21aa91",
  action: "Charge customer card via Stripe",
  target: "stripe.charges.create",
  dataClassification: "confidential",
});

if (!decision.execute) return; // blocked by policy — do not run the action

pip — Python

python
pip install ai-guardian

import os
from guardian import Guardian

guardian = Guardian(os.environ["GUARDIAN_API_KEY"])

# Before your agent runs anything consequential:
decision = guardian.guard(
    agent_id="agt_5d21aa91",
    action="Charge customer card via Stripe",
    target="stripe.charges.create",
    data_classification="confidential",
)

if not decision["execute"]:
    ...  # blocked by policy — do not run the action

Both read GUARDIAN_API_KEY from the environment (or take the key directly), and honor GUARDIAN_BASE_URL to point at another environment. The npm package ships its own TypeScript types; the pip package is a single module with no third-party dependencies.

Platform compatibility

Guardian runs anywhere Node.js or Python runs — Windows, macOS and Linux (Ubuntu, Debian, RHEL and derivatives). The console is a web app and works in any modern browser, on any operating system. On Ubuntu or Debian:

bash
# Ubuntu / Debian
sudo apt update && sudo apt install -y python3-pip nodejs npm
pip install ai-guardian        # Python SDK
npm install @theaiguardians/sdk  # JavaScript / TypeScript SDK
export GUARDIAN_API_KEY="gd_live_..."   # Windows: set GUARDIAN_API_KEY=gd_live_...
POST
/guardianIngest
Submit up to 25 actions per request and receive Guardian's decision for each.

Request body

  • events[].agent_id — required, the registered agent that attempted the action.
  • events[].event_type — one of the documented event types.
  • events[].action — short description of what the agent tried to do.
  • events[].target / destination — resource touched, or host and URL called.
  • events[].data_classification — public, internal, confidential or restricted.
  • events[].authorized — false when the action falls outside the agent's granted scope.
  • events[].volume — records or rows touched, for anomaly scoring.
  • events[].summary / evidence — human-readable context and the raw evidence string.
bash
curl -X POST "https://theaiguardians.com/functions/guardianIngest" \
  -H "Authorization: Bearer gd_live_9f2c41d08b7a4e5c9a1b3d6f2e8c0a74" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [{
      "agent_id": "AGENT_ID",
      "event_type": "data_transfer",
      "action": "Upload CRM export to personal storage",
      "destination": "https://drive.user-content.xyz/upload",
      "data_classification": "restricted",
      "authorized": false,
      "volume": 12480,
      "summary": "Agent uploaded a restricted export outside the managed estate.",
      "evidence": "bytes_out=41200000 host=user-content.xyz"
    }]
  }'

Response

json
{
  "received": 1,
  "event_ids": ["evt_8c21f4a9"],
  "threats_raised": 1,
  "results": [{
    "index": 0,
    "decision": "blocked",
    "risk_score": 100,
    "matched_policies": [
      "Restricted data egress",
      "Unsanctioned external destination"
    ],
    "risk_factors": [
      "Restricted data in scope",
      "Egress to a destination outside the corporate domain",
      "Action outside the agent authorization scope"
    ]
  }]
}
POST
/guardianGuard
Inline guard mode: authorize one action before your agent executes it, in the same tick.

Call the guard the moment your agent is about to run something consequential. Guardian scores the action, applies your enabled policies, records the decision and answers synchronously — blocked means the action must not run; execute carries the same signal for the loop in your runtime.

Requires a key with the guard:write scope and the Developer plan or above. Every guard call counts toward your monthly event quota, exactly like an ingested event, so the audit trail stays complete.

bash
curl -X POST "https://theaiguardians.com/functions/guardianGuard" \
  -H "Authorization: Bearer gd_live_9f2c41d08b7a4e5c9a1b3d6f2e8c0a74" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "AGENT_ID",
    "event_type": "tool_call",
    "action": "Charge customer card via Stripe",
    "target": "stripe.charges.create",
    "data_classification": "confidential",
    "summary": "Agent attempted to charge a card from the CRM thread."
  }'

Response

json
{
  "decision": "blocked",
  "execute": false,
  "risk_score": 74,
  "risk_factors": [
    "Confidential data in scope",
    "Block payment actions"
  ],
  "matched_policies": ["Block payment actions"],
  "agent_id": "agt_5d21aa91",
  "event_id": "evt_8c21f4a9",
  "quota": { "tier": "starter", "monthly_limit": 50000, "used": 1204 }
}
Decision model
Deterministic, explainable and replayable — the same action always scores the same way.

Guardian scores every action 0–100 from its event type, data classification, destination, authorization scope, agent autonomy and trust score, and the volume of data involved. Then your enabled policies are evaluated.

allowedRisk below 38 with no alerting policy matched, or an allow policy suppressing a score-driven alert. The action proceeds and is recorded.
alertRisk of 38 or above, or an alerting policy matched. The action proceeds with a recorded warning for review.
blockedRisk of 70 or above, or any block policy matched. The action must not execute.

A matched block policy always wins and cannot be downgraded. Each policy carries a score floor — the minimum score recorded when it matches — so the score, the matched policies and the decision always agree.

Event types
tool_callThe agent invoked a tool, function or integration.
data_accessThe agent read a record, file or dataset.
data_transferThe agent moved data somewhere — internal or external.
network_requestThe agent called an HTTP endpoint.
credential_accessThe agent touched secrets, keys or a credential store.
privilege_changeThe agent requested or granted a new scope or role.
model_outputThe agent produced output that may carry injected instructions.
authenticationThe agent authenticated or minted a token.
config_changeThe agent changed configuration, including security controls.
Webhook signatures
Every delivery carries a HMAC-SHA256 signature over the raw body.

Verify the X-Guardian-Signature header against the endpoint secret before acting on any payload.

javascript
import crypto from 'node:crypto';

const expected = 'sha256=' + crypto
  .createHmac('sha256', process.env.GUARDIAN_WEBHOOK_SECRET)
  .update(rawBody)
  .digest('hex');

const received = req.headers['x-guardian-signature'] || '';

if (expected.length === received.length &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(received))) {
  // authentic delivery — safe to act on
}

Subscribed event names: guardian.event.blocked, guardian.event.alert, guardian.threat.opened, guardian.threat.resolved, guardian.agent.quarantined, guardian.usage.threshold.

Errors and limits
400Malformed request, unknown agent_id or an empty events array.
401Missing, invalid or revoked API key.
403The key is valid but lacks the required scope (events:write, or guard:write for guard mode).
403Guard mode on the Free plan — upgrade to Developer or above to authorize inline.
429Rate limit exceeded for this key — back off and retry.

Limits: 25 events per request, 60 requests per minute per key, and a maximum body of 512 KB. Events older than 30 days cannot be backfilled.