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)

Authentication

All endpoints require:

  • Authorization: Basic base64(clientId:clientSecret) header

Optional:

  • X-Org-ID header — Scopes results to a specific tenant

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-Org-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 8601NoStart of time range
end_timeISO 8601NoEnd 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):

{
"entries": [
{
"id": "audit_001",
"request_id": "req_abc123",
"timestamp": "2025-01-02T14:30:00Z",
"user_id": 123,
"user_email": "[email protected]",
"user_role": "analyst",
"client_id": "app_456",
"tenant_id": "my-tenant",
"request_type": "llm_request",
"query": "Summarize the quarterly report",
"query_hash": "a1b2c3d4e5f6",
"policy_decision": "allowed",
"policy_details": {
"evaluated": ["governance.rate_limit", "compliance.pii_check"],
"risk_score": 0.1
},
"provider": "openai",
"model": "gpt-4o",
"response_time_ms": 1234,
"tokens_used": 600,
"cost": 0.012,
"redacted_fields": [],
"response_sample": "The quarterly report shows...",
"compliance_flags": [],
"security_metrics": {}
}
],
"total": 1,
"limit": 100,
"offset": 0
}

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-Org-ID: admin-tenant"

Path Parameters:

ParameterTypeDescription
tenant_idstringTarget tenant ID

Query Parameters:

ParameterTypeDescription
limitintegerMax results (default: 50, max: 1000)

Response (200 OK):

{
"entries": [
{
"id": "audit_001",
"request_id": "req_abc123",
"timestamp": "2025-01-02T14:30:00Z",
"user_id": 123,
"user_email": "[email protected]",
"user_role": "analyst",
"client_id": "app_456",
"tenant_id": "my-tenant",
"request_type": "llm_request",
"query": "Summarize the quarterly report",
"policy_decision": "allowed",
"provider": "openai",
"model": "gpt-4o",
"response_time_ms": 1234,
"tokens_used": 600,
"cost": 0.012
}
],
"total": 50,
"limit": 50,
"offset": 0
}

Error Responses (POST /api/v1/audit/search):

HTTP StatusScenario
400{"error": {"code": "INVALID_REQUEST", "message": "Invalid JSON in request body"}}
400{"error": {"code": "INVALID_TIME_RANGE", "message": "start_time must be before end_time"}}
401{"error": {"code": "UNAUTHORIZED", "message": "Missing authentication"}}

Error Responses (GET /api/v1/audit/tenant/{tenant_id}):

HTTP StatusScenario
401{"error": {"code": "UNAUTHORIZED", "message": "Missing authentication"}}
403{"error": {"code": "FORBIDDEN", "message": "Access denied to tenant 'other-tenant'"}}

Event Types

ValueDescription
llm_requestLLM completion requests routed through the agent
policy_evaluationPolicy check results (block, allow, redact)
mcp_queryMCP connector query executions
mcp_executeMCP connector tool executions
workflow_executionWorkflow and multi-agent plan runs
api_callGeneral API calls (CRUD operations)
auth_eventAuthentication and authorization events
config_changeConfiguration changes (provider, policy, connector)

Policy Decision Values

ValueDescription
allowedRequest passed all policy checks
blockedRequest was blocked by a policy
redactedRequest was allowed but sensitive fields were redacted

Audit Entry Fields

FieldTypeDescription
idstringUnique audit log ID
request_idstringRequest correlation ID
timestampISO 8601When the event occurred
user_idintegerUser ID
user_emailstringUser email address
user_rolestringUser role
client_idstringClient application ID
tenant_idstringTenant identifier
request_typestringType of request (freeform string)
querystringUser's query
query_hashstringHash of the query for deduplication
policy_decisionstringallowed, blocked, or redacted
policy_detailsobjectDetails of policy evaluation
providerstringLLM provider used
modelstringLLM model used
response_time_msintegerRequest latency in milliseconds
tokens_usedintegerTotal tokens consumed
costnumberEstimated cost in USD
redacted_fieldsarrayFields that were redacted
error_messagestringError message (omitted if empty)
response_samplestringTruncated response sample
compliance_flagsarrayCompliance flags triggered
security_metricsobjectSecurity-related metrics

policy_details Object

FieldTypeDescription
evaluatedstring[]List of policy names that were evaluated
risk_scorenumberCalculated risk score (0.0 - 1.0)
matched_policiesstring[]Policies that matched and triggered actions
evaluation_time_msnumberTime spent evaluating policies

security_metrics Object

FieldTypeDescription
threat_levelstringDetected threat level: none, low, medium, high, critical
patterns_matchedintegerNumber of security patterns matched
exfiltration_riskbooleanWhether data exfiltration risk was detected

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 '.entries[] | select(.policy_decision == "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