Skip to main content

Audit Search API

Search and retrieve audit logs for compliance, debugging, and analytics through the Orchestrator API.

Overview

The Audit API provides:

  • Search Capabilities: Filter logs by user, client, time range, and request type
  • Tenant Isolation: Access audit logs scoped to specific tenants
  • Compliance Support: Full audit trail for regulatory requirements

Base URL: http://localhost:8081 (Orchestrator)


Endpoints

POST /api/v1/audit/search

Search audit logs with flexible filtering criteria.

Request:

curl -X POST http://localhost:8081/api/v1/audit/search \
-H "Content-Type: application/json" \
-H "X-Tenant-ID: my-tenant" \
-d '{
"user_email": "[email protected]",
"start_time": "2025-01-01T00:00:00Z",
"end_time": "2025-01-02T23:59:59Z",
"request_type": "llm_request",
"limit": 100
}'

Request Body:

FieldTypeRequiredDescription
user_emailstringNoFilter by user email
client_idstringNoFilter by client/application ID
start_timeISO 8601YesStart of time range
end_timeISO 8601YesEnd of time range
request_typestringNoFilter by request type
limitintegerNoMax results (default: 100, max: 1000)

Request Types:

TypeDescription
llm_requestLLM completion requests
policy_evaluationPolicy check results
mcp_queryMCP connector queries
workflow_executionWorkflow runs
api_callGeneral API calls

Response (200 OK):

{
"logs": [
{
"id": "audit_001",
"timestamp": "2025-01-02T14:30:00Z",
"tenant_id": "my-tenant",
"user": {
"id": "user_123",
"email": "[email protected]"
},
"client_id": "app_456",
"request_type": "llm_request",
"request": {
"query": "Summarize the quarterly report",
"model": "gpt-4o",
"provider": "openai"
},
"response": {
"status": "success",
"latency_ms": 1234,
"tokens": {
"prompt": 150,
"completion": 450,
"total": 600
}
},
"policies_evaluated": ["governance.rate_limit", "compliance.pii_check"],
"policies_triggered": [],
"metadata": {
"ip_address": "192.168.1.1",
"user_agent": "AxonFlow-SDK/1.0"
}
}
],
"total": 1,
"has_more": false
}

GET /api/v1/audit/tenant/{tenant_id}

Get recent audit logs for a specific tenant. Useful for admin dashboards.

Request:

curl http://localhost:8081/api/v1/audit/tenant/my-tenant \
-H "X-Tenant-ID: admin-tenant"

Path Parameters:

ParameterTypeDescription
tenant_idstringTarget tenant ID

Response (200 OK):

{
"tenant_id": "my-tenant",
"logs": [
{
"id": "audit_001",
"timestamp": "2025-01-02T14:30:00Z",
"user": {
"id": "user_123",
"email": "[email protected]"
},
"request_type": "llm_request",
"request": {
"query": "Summarize the quarterly report",
"model": "gpt-4o"
},
"response": {
"status": "success",
"latency_ms": 1234
}
}
],
"count": 50,
"limit": 50
}

Audit Log Structure

Core Fields

FieldTypeDescription
idstringUnique audit log ID
timestampISO 8601When the event occurred
tenant_idstringTenant identifier
userobjectUser who initiated the request
client_idstringClient application ID
request_typestringType of request

Request Object

FieldTypeDescription
querystringUser's query (may be truncated)
modelstringLLM model used
providerstringLLM provider
connectorstringMCP connector (if applicable)

Response Object

FieldTypeDescription
statusstringsuccess, error, blocked
latency_msintegerRequest latency in milliseconds
tokensobjectToken usage (prompt, completion, total)
errorstringError message (if status is error)
blocked_bystringPolicy that blocked (if status is blocked)

Policy Fields

FieldTypeDescription
policies_evaluatedarrayPolicies that were checked
policies_triggeredarrayPolicies that matched/blocked

Use Cases

Compliance Reporting

Generate audit reports for specific time periods:

curl -X POST http://localhost:8081/api/v1/audit/search \
-H "Content-Type: application/json" \
-d '{
"start_time": "2025-01-01T00:00:00Z",
"end_time": "2025-01-31T23:59:59Z",
"request_type": "policy_evaluation",
"limit": 1000
}'

User Activity Analysis

Track specific user's activity:

curl -X POST http://localhost:8081/api/v1/audit/search \
-H "Content-Type: application/json" \
-d '{
"user_email": "[email protected]",
"start_time": "2025-01-02T00:00:00Z",
"end_time": "2025-01-02T23:59:59Z",
"limit": 500
}'

Security Incident Investigation

Find blocked requests:

curl -X POST http://localhost:8081/api/v1/audit/search \
-H "Content-Type: application/json" \
-d '{
"start_time": "2025-01-02T00:00:00Z",
"end_time": "2025-01-02T23:59:59Z",
"limit": 100
}' | jq '.logs[] | select(.response.status == "blocked")'

Data Retention

TierRetention Period
Community7 days
Professional30 days
Enterprise365 days
note

For compliance requirements (RBI, SEBI, EU AI Act), see the enterprise compliance modules for extended retention and regulatory exports.


Error Responses

HTTP StatusError CodeDescription
400INVALID_REQUESTInvalid request body or parameters
400INVALID_TIME_RANGEInvalid time range specified
401UNAUTHORIZEDMissing authentication
403FORBIDDENAccess denied to tenant
500INTERNAL_ERRORAudit search failed

Next Steps