API Reference

AgentAudit Docs

Everything you need to integrate audit logging, guardrails, and compliance monitoring into your agent stack.

Base URL: /api/v1 (same origin) — or https://your-domain.com/api/v1 Version: v1 Interactive Swagger UI ↗
01 — Getting started

Quickstart

Get your first audit log into AgentAudit in under two minutes.

1. Create an account & get an API key

Sign up at agentaudit.online, then go to Dashboard → API Keys → Create Key. Your key starts with aa_.

2. Send your first log

curl -X POST https://your-domain.com/api/v1/audit-logs \
  -H "X-API-Key: aa_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "llm_call",
    "prompt": "Summarise the latest sales report",
    "response": "Q1 revenue was $2.4M...",
    "metadata": { "model": "gpt-4o", "tokens": 340 }
  }'
from agentaudit import AgentAuditClient

client = AgentAuditClient(api_key="aa_your_key_here")

client.log(
    action="llm_call",
    prompt="Summarise the latest sales report",
    response="Q1 revenue was $2.4M...",
    metadata={"model": "gpt-4o", "tokens": 340}
)
import { AgentAuditClient } from 'agentaudit-client';

const client = new AgentAuditClient({ apiKey: 'aa_your_key_here' });

await client.log({
  action: 'llm_call',
  prompt: 'Summarise the latest sales report',
  response: 'Q1 revenue was $2.4M...',
  metadata: { model: 'gpt-4o', tokens: 340 },
});

3. Check your dashboard

Your log will appear in Dashboard → Recent Audit Logs within seconds. Any compliance violations will surface as alerts automatically.

Tip: Pass a traceId on every log in a single agent run to link them together. You can then replay the full chain in the Trace Visualizer.
02 — Authentication

Authentication

Two methods are supported depending on context.

MethodHeaderUse case
API Key X-API-Key: aa_... Agent-to-service logging from SDKs or direct HTTP
JWT Bearer Authorization: Bearer <token> Dashboard access, profile & billing management

Obtain a JWT

POST /api/v1/auth/login

{
  "email": "you@example.com",
  "password": "your_password"
}

// Response
{
  "accessToken": "eyJ...",
  "organization": { "id": "...", "email": "...", "plan": "free", "name": "Acme Corp" }
}

Create an API key

POST /api/v1/auth/api-keys
Authorization: Bearer <jwt>

{ "name": "production-agent" }

// Response
{
  "key": "aa_live_xxxxxxxxxxxxxxxx",  // shown once — save it
  "id": "key_...",
  "name": "production-agent"
}
Important: API keys are shown only once at creation time. Store them securely in an environment variable — they cannot be retrieved afterwards.
03 — Core API

Audit Logs

The core primitive. Log any agent action — LLM calls, tool use, decisions, guardrail checks — with a flexible schema.

Log a single event

POST /api/v1/audit-logs Auth: API Key
FieldTypeDescription
actionstringrequiredEvent type, e.g. llm_call, tool_use, guardrail_block
promptstringoptionalInput sent to the model or tool
responsestringoptionalOutput from the model or tool
agentIdstringoptionalStable identifier for the agent
traceIdstringoptionalGroups related events into a single trace
parentSpanIdstringoptionalID of a parent log entry (for nested spans)
metadataobjectoptionalAny JSON — model name, token count, latency, etc.
// Example — guardrail check with trace context
{
  "action": "guardrail_check",
  "agentId": "writer-agent-1",
  "traceId": "run-1749300000000",
  "parentSpanId": "log_abc123",
  "prompt": "Draft email containing SSN: 123-45-6789",
  "response": "BLOCKED: PII detected",
  "metadata": {
    "rule": "pii_detection",
    "model": "gpt-4o",
    "latency_ms": 42
  }
}

Retrieve logs

GET /api/v1/audit-logs Auth: JWT or API Key

Supports query params: limit, offset, agentId, action, traceId.

04 — Batch logging

Batch Logging

Submit up to 50 log entries in a single request. Ideal for high-throughput agents or flushing a local buffer at the end of a run.

POST /api/v1/audit-logs/batch Auth: API Key
curl -X POST https://your-domain.com/api/v1/audit-logs/batch \
  -H "X-API-Key: aa_your_key_here" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "action": "llm_start",
      "traceId": "run-1749300000000",
      "prompt": "Analyse Q1 data",
      "metadata": { "model": "gpt-4o" }
    },
    {
      "action": "tool_use",
      "traceId": "run-1749300000000",
      "parentSpanId": "<id of llm_start log>",
      "metadata": { "tool": "code_interpreter" }
    },
    {
      "action": "llm_end",
      "traceId": "run-1749300000000",
      "response": "Q1 revenue grew 18% YoY",
      "metadata": { "tokens": 820 }
    }
  ]'
The batch endpoint returns an array of created log IDs in the same order as the input. Use these IDs as parentSpanId values in subsequent requests to build a nested trace.
05 — Distributed tracing

Distributed Tracing

Link every log in an agent run with a shared traceId. Use parentSpanId to express parent–child relationships between spans. The Trace Visualizer reconstructs the full tree from these fields.

Fetch a trace

GET /api/v1/audit-logs/trace/:traceId Returns all logs with this traceId

Get parent chain

GET /api/v1/audit-logs/:id/chain Walk parentSpanId chain upwards
// Suggested traceId pattern — stable, sortable
const traceId = `run-${Date.now()}`;           // "run-1749300000000"
const traceId = `run-${crypto.randomUUID()}`;  // "run-550e8400-e29b..."

// Python
import time
trace_id = f"run-{int(time.time() * 1000)}"

Find your trace IDs in Dashboard → Recent Audit Logs, then paste them into the Trace Visualizer to replay the full agent chain.

06 — Compliance rules

Compliance Rules

Rules are evaluated automatically against every incoming log. Violations trigger alerts and optionally fire webhook or email notifications.

GET /api/v1/compliance-rules List all rules for your org
POST /api/v1/compliance-rules Create a custom rule
POST /api/v1/compliance-rules/packs Install a pre-built compliance pack

Install a compliance pack

Packs are curated rule sets for common frameworks. Available pack IDs:

  • hipaa — Healthcare (HIPAA-aligned PII & PHI detection)
  • finance — Financial services (PCI-DSS, sensitive data)
  • gdpr — GDPR / EU data protection
POST /api/v1/compliance-rules/packs
Authorization: Bearer <jwt>

{ "packId": "gdpr" }
07 — Alerts

Alerts

Alerts are created automatically when a compliance rule fires. You can list, filter, and resolve them via API or from the dashboard.

GET /api/v1/alerts List alerts — supports ?resolved=false
PATCH /api/v1/alerts/:id/resolve Mark an alert as resolved
08 — Agents

Agents

Register named agents so you can filter audit logs and alerts by agent, and attach policies directly to individual agents.

GET /api/v1/agents List all agents for your org
POST /api/v1/agents Register a new agent
GET /api/v1/agents/:id Get a single agent
PATCH /api/v1/agents/:id Update agent name / metadata
DELETE /api/v1/agents/:id Remove an agent

Create an agent

POST /api/v1/agents
Authorization: Bearer <jwt>

{
  "name": "writer-agent",
  "metadata": { "version": "1.0", "team": "content" }
}

// Response
{
  "id": "agent_...",
  "name": "writer-agent",
  "organizationId": "org_...",
  "metadata": { "version": "1.0", "team": "content" },
  "createdAt": "2026-01-15T10:00:00.000Z"
}

Once an agent is registered, pass its id as agentId in any audit log to link the log to that agent.

09 — Policies

Policies

Policies are named, versioned bundles of compliance rules. Attach a policy to an agent and every log from that agent is evaluated against it automatically.

GET /api/v1/policies List all policies
POST /api/v1/policies Create a policy
POST /api/v1/policies/clone-pack Clone a compliance pack into a policy
GET /api/v1/policies/analytics Org-wide policy analytics
GET /api/v1/policies/:id Get a single policy
GET /api/v1/policies/:id/analytics Per-policy analytics
POST /api/v1/policies/:id/versions Create a new version
GET /api/v1/policies/:id/versions List versions
GET /api/v1/policies/:id/versions/:versionId Get a specific version
POST /api/v1/policies/:id/versions/:versionId/restore Restore an older version
PATCH /api/v1/policies/:id Update a policy
DELETE /api/v1/policies/:id Delete a policy
POST /api/v1/policies/:id/agents Attach policy to an agent
DELETE /api/v1/policies/:id/agents Detach policy from an agent

Attach a policy to an agent

POST /api/v1/policies/:id/agents
Authorization: Bearer <jwt>

{ "agentId": "agent_..." }

Clone a compliance pack into a policy

Available pack IDs: hipaa, gdpr, finance

POST /api/v1/policies/clone-pack
Authorization: Bearer <jwt>

{ "packId": "hipaa", "name": "HIPAA Policy v1" }
10 — Reports

Reports

Generate downloadable compliance and audit reports for any time window. Reports are created asynchronously — poll GET /api/v1/reports/:id until status is ready, then call the download endpoint.

GET /api/v1/reports List all reports for your org
POST /api/v1/reports Request a new report
GET /api/v1/reports/:id Check report status
GET /api/v1/reports/:id/download Download the generated file
DELETE /api/v1/reports/:id Delete a report

Request a report

POST /api/v1/reports
Authorization: Bearer <jwt>

{
  "type": "compliance_summary",
  "from": "2026-01-01T00:00:00Z",
  "to": "2026-03-31T23:59:59Z"
}

// Response
{
  "id": "report_...",
  "status": "pending",
  "type": "compliance_summary",
  "createdAt": "2026-04-01T09:00:00.000Z"
}
Tip: Once status becomes ready, call GET /api/v1/reports/:id/download to receive the file. The response includes the correct Content-Type and Content-Disposition headers for direct browser download.
11 — Billing

Billing

Billing is managed through Stripe. Use the checkout endpoint to start a paid subscription and the portal endpoint to let users manage or cancel it.

Get available plan prices

Public endpoint — no authentication required. Returns the Stripe price IDs currently configured for each paid plan. Use these IDs when creating a checkout session.

GET/api/v1/billing/prices
// Response
{
  "pro":      "price_...",
  "business": "price_..."
}

Create a checkout session

Requires JWT authentication. Redirects the user to Stripe Checkout to subscribe to the chosen plan.

POST/api/v1/billing/checkout-session
// Request
{
  "priceId": "price_..."
}

// Response
{
  "sessionId": "cs_...",
  "url": "https://checkout.stripe.com/..."
}

Get subscription status

Requires JWT authentication. Returns the current plan and subscription details for your organisation.

GET/api/v1/billing/subscription

Open the billing portal

Requires JWT authentication. Returns a short-lived Stripe Customer Portal URL where the user can update payment methods, change plans, or cancel.

POST/api/v1/billing/portal-session
12 — Reference

All Endpoints

Auth

POST/api/v1/auth/register
POST/api/v1/auth/login
GET/api/v1/auth/me
PATCH/api/v1/auth/meUpdate profile & notification prefs
POST/api/v1/auth/api-keys
GET/api/v1/auth/api-keys
DELETE/api/v1/auth/api-keys/:id

Audit Logs

POST/api/v1/audit-logs
POST/api/v1/audit-logs/batch
GET/api/v1/audit-logs
GET/api/v1/audit-logs/exportExport logs as CSV or JSON
GET/api/v1/audit-logs/:id
GET/api/v1/audit-logs/trace/:traceId
GET/api/v1/audit-logs/:id/chain

Compliance

GET/api/v1/compliance-rules
POST/api/v1/compliance-rules
GET/api/v1/compliance-rules/:id
PATCH/api/v1/compliance-rules/:id
DELETE/api/v1/compliance-rules/:id
GET/api/v1/compliance-rules/packsList available packs
GET/api/v1/compliance-rules/packs/installedList installed packs
POST/api/v1/compliance-rules/packs
DELETE/api/v1/compliance-rules/packs/:packId

Alerts

GET/api/v1/alerts
GET/api/v1/alerts/:id
PATCH/api/v1/alerts/:id/resolve

Agents

GET/api/v1/agents
POST/api/v1/agents
GET/api/v1/agents/:id
PATCH/api/v1/agents/:id
DELETE/api/v1/agents/:id

Policies

GET/api/v1/policies
POST/api/v1/policies
POST/api/v1/policies/clone-pack
GET/api/v1/policies/analytics
GET/api/v1/policies/:id
GET/api/v1/policies/:id/analytics
POST/api/v1/policies/:id/versions
GET/api/v1/policies/:id/versions
GET/api/v1/policies/:id/versions/:versionId
POST/api/v1/policies/:id/versions/:versionId/restore
PATCH/api/v1/policies/:id
DELETE/api/v1/policies/:id
POST/api/v1/policies/:id/agents
DELETE/api/v1/policies/:id/agents

Reports

GET/api/v1/reports
POST/api/v1/reports
GET/api/v1/reports/:id
GET/api/v1/reports/:id/download
DELETE/api/v1/reports/:id

Billing

GET/api/v1/billing/pricesPublic — returns configured plan price IDs
POST/api/v1/billing/checkout-sessionCreate a Stripe checkout session
GET/api/v1/billing/subscriptionGet current subscription status & plan
POST/api/v1/billing/portal-sessionCreate a Stripe customer portal session
POST/api/v1/billing/webhookStripe webhook receiver (Stripe signature required)
13 — Errors

Errors

All errors return JSON with a consistent shape:

{
  "error": "Human-readable message",
  "status": 400
}
CodeMeaning
400Validation error — check your request body
401Missing or invalid API key / JWT
403Valid credentials but not authorised for this resource
404Resource not found
429Rate limit exceeded — back off and retry
500Server error — contact support if it persists