← Integration guide

Human Oversight and Connectors

Before an AI agent refunds a customer, sends an external email or changes a record, it asks Aegis Guardrails. Your approval policies decide whether it runs straight away, waits for a person, or is blocked. With a connector, Aegis Guardrails then carries the action out itself, using a credential the agent never holds.

How it works

  1. The agent asks with an action type (such as payments.refund) and its parameters.
  2. Aegis Guardrails checks your policies in Approvals → Policies. Low-risk actions run straight away and are recorded; others wait for the reviewers the policy names, or are blocked.
  3. A reviewer sees the exact parameters and approves or rejects. The approval is tied to those parameters, so the agent can't change them afterwards, and it can be used once.
  4. Either your code runs the action and reports the outcome, or a connector runs it for you. Every step is hash-chained and signed, and appears in evidence packs.

Aegis Guardrails governs the actions sent through it. For a hard guarantee, keep the downstream credential out of the agent's reach: use a connector with Only through this connector turned on, or the MCP gateway.

SDKs

Install @aegis-guardrails/sdk (Node 18+) or aegis-guardrails (Python 3.9+), and use a project API key. If Aegis Guardrails can't be reached, nothing runs.

Let Aegis Guardrails run it (recommended)

With a connector set up, submit() asks, waits for approval, and hands the action over. Your code never needs the Stripe key or mailbox password.

import { AegisGuardrails } from '@aegis-guardrails/sdk'
const aegis = new AegisGuardrails({ apiKey: process.env.AEGIS_API_KEY! })

const done = await aegis.submit('payments.refund',
  { paymentIntent: 'pi_3Q...', amount: 25.00, currency: 'usd', reason: 'requested_by_customer' },
  { summary: 'Refund $25 to order 1182', initiatingUser: customerId })

console.log(done.detail)  // "Refunded 25 USD (Stripe re_..., succeeded)."
from aegis_guardrails import AegisGuardrails
aegis = AegisGuardrails(api_key=os.environ["AEGIS_API_KEY"])

done = aegis.submit("email.send_external",
                    {"to": "jo@customer.org", "subject": "Your refund", "text": "It's on its way."},
                    summary="Refund confirmation")

Run it in your own code

guard() waits for approval, then calls your function once with a read-only copy of the approved parameters and reports the outcome.

const refund = await aegis.guard('payments.refund', { amount: 2500, order: '1182' },
  p => stripe.refunds.create({ amount: p.amount * 100, payment_intent: p.order }),
  { summary: 'Refund $2,500 to order 1182' })

API

All agent calls use the X-Audit-Key header with a project key. Reviewers decide in the console; API keys can never approve.

CallWhat it does
POST /v1/actions/evaluateAsk. Body { actionType, params, summary?, initiatingUser?, aiSystemId?, sessionId? }. Answers executing (go ahead), pending (wait) or blocked.
GET /v1/actions/{id}?wait=25Current state. With wait (up to 30 seconds) it answers as soon as a reviewer decides.
POST /v1/actions/{id}/runA connector carries out the approved action with the stored, approved parameters. Answers with outcome, detail and result.
POST /v1/actions/{id}/executeYou run it yourself: claim the approval with the same params. Single use. Refused with use_connector when a connector is the only route.
POST /v1/actions/{id}/resultAfter running it yourself: { outcome: "succeeded" | "failed" | "unknown", result? }.
POST /v1/actions/{id}/cancelWithdraw a pending or approved request.
GET /v1/actions/catalogStandard action types and their default risk.

Connectors

An Admin sets connectors up in Approvals → Integrations. The credential is encrypted per organisation and never shown again; a new connector is tested straight away, and Test checks it any time without acting on anything.

SettingMeaning
Actions it carries outThe action types it handles. One connector per action type per project; a project connector is used there instead of an all-projects one.
Only through this connectorOn by default. Agents can't claim an approval to run these actions themselves, so each one runs here, exactly as approved, once.
Used forAll projects, or one project.

Stripe refunds (payments.refund)

Use a restricted key with refund and payment read access. Reviewers approve the amount in normal units (dollars, not cents). Before refunding, Aegis Guardrails looks the payment up and checks its currency matches; the request id is Stripe's idempotency key, so one approval is at most one refund. An optional limit refuses anything larger, even if approved.

{ "paymentIntent": "pi_3Q...",     // or "charge": "ch_..."
  "amount": 25.00,                  // normal units
  "currency": "usd",
  "reason": "requested_by_customer" // optional: duplicate | fraudulent | requested_by_customer
}

Email over SMTP (email.send_external, email.send_internal)

Sent through your own mail server on port 587 or 2525 (STARTTLS) or 465 (TLS), with the certificate checked against the server name. Plain text only. If you list allowed domains, every recipient must be at one of them, or nothing is sent.

{ "to": ["jo@customer.org"],   // up to 20; "cc" works the same way
  "subject": "Your refund",       // one line
  "text": "It's on its way.",
  "replyTo": "support@acme.com"   // optional
}

HTTPS webhook (any action type)

Aegis Guardrails posts the approved action to your endpoint. Private and internal addresses are refused, and redirects aren't followed. Answer 2xx when done. The signing secret is shown once when you create the connector.

POST https://ops.example.com/aegis/actions
X-Aegis-Signature: t=1763900000,v1=5f0c...   (HMAC-SHA256 of "<t>.<raw body>")
Idempotency-Key: 6b1e...                     (the request id: never two for one approval)

{ "id": "6b1e...", "actionType": "tickets.close", "params": { ... },
  "summary": "...", "projectId": "...", "approvedBy": ["ann@acme.com"], "sentAt": "..." }

Check the signature before acting, and reject old timestamps:

import { createHmac, timingSafeEqual } from 'crypto'

function verify(rawBody: string, header: string, secret: string) {
  const { t, v1 } = Object.fromEntries(header.split(',').map(kv => kv.split('=')))
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false
  const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex')
  return timingSafeEqual(Buffer.from(expected), Buffer.from(v1))
}

The Test button sends actionType: "aegis.test" with { "test": true }. Answer 2xx and do nothing.

Approve in Slack

An Admin connects your own Slack app in Approvals → Integrations: create an app, add the bot scopes chat:write, users:read and users:read.email, turn on Interactivity with the Request URL shown there, invite the app to a channel, then paste the bot token, signing secret and channel ID. A test message confirms it works.

Approval requests then appear in the channel with an Approve button. Aegis Guardrails checks Slack's signature, matches the Slack user to an Aegis Guardrails user by email, and applies the same rules as the console: who may approve, clearance, two-person approval and no self-approval. Only the fields the policy marks as decision fields are shown. Critical actions, Sensitive and Regulated projects, and every rejection (a reason is required) stay in the console.

Held AI calls

A Policy Engine rule with the action Require approval (or a circuit breaker in approval mode) holds an AI call before it reaches the model. The gateway answers 403 with code: "approval_required" and a requestId, and the call appears in Approvals as Send a held AI call to the model, showing the provider, model and the rule that held it. Sending the same call again before anyone decides returns the same request, so retries don't fill the queue.

Once it's approved (check GET /v1/actions/{requestId}), send exactly the same request again with one extra header:

X-Aegis-Approval: <requestId>

The call goes to the model once. A changed prompt gets params_changed, and using the approval a second time gets not_approved; neither is sent. The outcome is recorded on the request (streamed replies as unknown). Rules that block still block, and the emergency stop still refuses every call. To set who reviews held calls, add an oversight policy for the action type ai.call.

The SDKs do the waiting and the resend for you. Your function must add the headers it gets:

// Node
const reply = await aegis.sendHeld(h => anthropic.messages.create(body, { headers: h }))

# Python
reply = aegis.send_held(lambda h: anthropic.messages.create(**body, extra_headers=h))

Outcomes

OutcomeMeaningWhat to do
succeededIt happened.Nothing.
failedThe service refused it, or it was never sent.Fix the cause and submit a new request.
unknownA timeout or server error: it may or may not have happened.Check the service before retrying. It appears as Outcome unknown in Approvals.

Errors

CodeHTTPMeaning
not_approved409Still waiting, rejected, expired, cancelled or already started.
params_changed409The parameters (or the held AI call) aren’t the ones that were approved. Nothing ran.
not_an_ai_call409X-Aegis-Approval named an approval for a different kind of action.
no_connector404No connector handles this action type in this project. Nothing ran.
invalid_params422The parameters fail the connector’s checks (for example over the refund limit). Nothing ran; cancel and submit a corrected request.
use_connector409Only the connector may run this action. Use run or submit().
brokered409A connector ran it and recorded the outcome, so you can’t report one.
emergency_stop423An Admin stopped all AI. Nothing runs until they resume.
oversight_unavailable503Policies couldn’t be checked. Don’t run the action.

Writing rules for AI calls rather than agent actions? Read the Policy Engine guide.