Skip to main content

Audit Logs

Overview

The Audit Log API provides a complete history of all user actions in the system. Every create, update, and delete operation is logged with user details, timestamps, and change details.

List Audit Logs

GET /api/audit
Cookie: sAccessToken=...; sRefreshToken=...

Roles: ADMIN

Query Parameters

ParameterTypeDescription
userIdstringFilter by user ID
userEmailstringFilter by user email
actionstringFilter by action type
entityTypestringFilter by entity type (Bid, Scope, Client, etc.)
entityIdstringFilter by specific entity ID
bidIdstringFilter by bid ID
startDateISO 8601Filter logs after this date
endDateISO 8601Filter logs before this date
limitnumberResults per page (default: 50, max: 200)
offsetnumberPagination offset (default: 0)

Action Types

Bid Actions

  • BID_CREATED - New bid created
  • BID_UPDATED - Bid modified
  • BID_DELETED - Bid deleted
  • BID_DUPLICATED - Bid duplicated
  • BID_SHARED - Share code generated
  • BID_IMPORTED - Bid imported from share code
  • BID_EXPORTED - PDF/Excel export
  • BID_STATUS_CHANGED - Status updated (DRAFT → SUBMITTED, etc.)

Scope Actions

  • SCOPE_CREATED - New scope created
  • SCOPE_UPDATED - Scope modified
  • SCOPE_DELETED - Scope deleted

Item Actions

  • CONCRETE_ITEM_CREATED - Concrete item added
  • CONCRETE_ITEM_UPDATED - Concrete item modified
  • CONCRETE_ITEM_DELETED - Concrete item deleted
  • LABOR_ITEM_CREATED - Labor item added
  • LABOR_ITEM_UPDATED - Labor item modified
  • LABOR_ITEM_DELETED - Labor item deleted
  • (Similar for Equipment, Materials, Subcontractor, Misc)

User Actions

  • USER_CREATED - New user created
  • USER_UPDATED - User profile updated
  • USER_ROLE_CHANGED - User role changed
  • USER_STATUS_CHANGED - User status changed (ACTIVE/INACTIVE)
  • USER_DELETED - User deleted

Admin Actions

  • PRICING_UPDATED - Pricing catalog modified
  • VARIABLE_UPDATED - Global variable modified
  • TEMPLATE_CREATED - Exclusion template created
  • TEMPLATE_UPDATED - Exclusion template modified

Example Queries

Get all actions by a user

GET /api/audit?userEmail=john@precisionsiteservices.com&limit=100

Get all changes to a specific bid

GET /api/audit?bidId=uuid&limit=100

Get all bid deletions in the last 30 days

GET /api/audit?action=BID_DELETED&startDate=2025-01-01T00:00:00Z

Get all admin actions

GET /api/audit?action=PRICING_UPDATED,VARIABLE_UPDATED,USER_ROLE_CHANGED

Data Model

interface AuditLog {
id: string
userId: string // User who performed the action
userEmail: string // User email
action: AuditAction // Action type (see above)
entityType: string // Entity affected (Bid, Scope, User, etc.)
entityId: string // ID of affected entity
bidId?: string // Bid ID (if action relates to a bid)
details: object // Action-specific details
ipAddress: string // User's IP address
userAgent?: string // Browser user agent
timestamp: DateTime // When action occurred
}

enum AuditAction {
BID_CREATED
BID_UPDATED
BID_DELETED
// ... (see Action Types above)
}

Details Object Structure

The details field contains action-specific information:

Create Actions

{
"bidNumber": "BID-2025-001",
"jobName": "Shopping Center Foundation",
"clientId": "uuid"
}

Update Actions

{
"changes": {
"status": { "old": "DRAFT", "new": "SUBMITTED" },
"overheadPercentage": { "old": 10, "new": 12 }
}
}

Delete Actions

{
"deletedEntity": {
"id": "uuid",
"name": "Foundation Slab",
"type": "Scope"
}
}

Import Actions

{
"shareCode": "BID-X7K9M2P4",
"sourceBidId": "uuid",
"sourceUserId": "uuid",
"newBidName": "Imported Shopping Center"
}

Use Cases

1. Compliance & Auditing

Track who made changes to bids for regulatory compliance and internal audits.

2. Debugging

Investigate issues by reviewing the sequence of actions that led to a problem.

3. User Activity Monitoring

Monitor user behavior and identify suspicious activity.

4. Change History

Provide a detailed history of changes to bids for client transparency.

  • Admin Panel - Admin user management
  • Bids - Bid operations that generate audit logs