Skip to main content

Your First Event

After BatAudit is running, you need an API key to start sending events.


1. Create an API key

  1. Open the dashboard at http://localhost:8082/app
  2. Go to Settings → API Keys
  3. Click Generate new key
  4. Copy the key — it's only shown once
warning

Store the API key immediately. BatAudit stores a SHA-256 hash of the key, not the key itself, so it cannot be retrieved later.


2. Send an event via curl

curl -X POST http://localhost:8081/v1/audit \
-H "X-API-Key: bat_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"path": "/api/users",
"method": "GET",
"status_code": 200,
"response_time": 45,
"identifier": "user-123",
"service_name": "my-api",
"environment": "production"
}'

A successful response returns 202 Accepted.


3. View the event in the dashboard

Open the dashboard and navigate to Events. Your event should appear immediately (the Worker processes the queue in real-time).


Event fields reference

FieldTypeRequiredDescription
pathstringRequest path (max 255 chars)
methodstringHTTP method: GET, POST, PUT, DELETE
status_codeintHTTP status code (100–599)
response_timeintResponse time in milliseconds
identifierstringUser or client ID (max 100 chars)
service_namestringName of the service sending the event
environmentstringproduction, staging, development
user_emailstringUser email address
user_namestringUser display name
user_rolesarrayArray of role strings
user_typestringe.g. admin, viewer
tenant_idstringOrganization/tenant ID for multi-tenant apps
ipstringClient IP address
user_agentstringUser-Agent header
request_idstringTrace/correlation ID
query_paramsobjectURL query parameters
path_paramsobjectURL path parameters
request_bodyobjectRequest body (opt-in via SDK)
error_messagestringError description for failed requests
session_idstringExplicit session ID for session tracking
sourcestringbackend (default) or browser

Sensitive data masking

BatAudit automatically masks the following patterns in request_body and query_params before storing:

  • Credit card numbers → ************1234
  • Fields named password, secret, pwd"password":"********"
  • API keys and tokens → "token":"********"

This runs server-side — you don't need to sanitize before sending.


Next steps