Skip to content

Audit Trails

Vettly maintains a complete, immutable history of all decisions. This audit trail can be exported, filtered, and analyzed for compliance, legal, and operational needs.

Querying Decisions

Basic Queries

typescript
// Get all decisions for a time period
const decisions = await vettly.listDecisions({
  from: '2024-01-01',
  to: '2024-01-31'
})

// Filter by action
const blocked = await vettly.listDecisions({
  from: '2024-01-01',
  to: '2024-01-31',
  action: 'block'
})

// Filter by category
const harassment = await vettly.listDecisions({
  from: '2024-01-01',
  to: '2024-01-31',
  category: 'harassment'
})

User-Specific Queries

typescript
// All decisions for a specific user
const userDecisions = await vettly.listDecisions({
  userId: 'user_123'
})

// Blocked content for a user
const userBlocked = await vettly.listDecisions({
  userId: 'user_123',
  action: 'block'
})

Policy-Specific Queries

typescript
// Decisions made under a specific policy version
const v2Decisions = await vettly.listDecisions({
  policyId: 'community-safe',
  policyVersion: '2.3.1'
})

Exporting Data

CSV Export

typescript
const csv = await vettly.exportDecisions({
  from: '2024-01-01',
  to: '2024-01-31',
  format: 'csv'
})

// Returns CSV with columns:
// decision_id, timestamp, action, category, score, threshold, user_id, policy_version

JSON Export

typescript
const json = await vettly.exportDecisions({
  from: '2024-01-01',
  to: '2024-01-31',
  format: 'json'
})

// Returns array of full decision objects

Scheduled Exports

Set up recurring exports for compliance:

typescript
await vettly.createScheduledExport({
  name: 'monthly-compliance',
  schedule: '0 0 1 * *', // First of each month
  format: 'csv',
  filters: {
    action: ['flag', 'block']
  },
  destination: {
    type: 's3',
    bucket: 'compliance-exports',
    prefix: 'moderation/'
  }
})

Analytics

Decision Counts

typescript
const stats = await vettly.getDecisionStats({
  from: '2024-01-01',
  to: '2024-01-31'
})

// Returns:
{
  total: 150000,
  byAction: {
    allow: 142000,
    warn: 3500,
    flag: 3000,
    block: 1500
  },
  byCategory: {
    harassment: 2500,
    hate_speech: 1200,
    violence: 800,
    // ...
  }
}

Trend Analysis

typescript
const trends = await vettly.getDecisionTrends({
  from: '2024-01-01',
  to: '2024-01-31',
  granularity: 'day'
})

// Returns daily counts for charting
[
  { date: '2024-01-01', allow: 4500, warn: 120, flag: 100, block: 50 },
  { date: '2024-01-02', allow: 4600, warn: 115, flag: 95, block: 48 },
  // ...
]

Policy Effectiveness

typescript
const effectiveness = await vettly.getPolicyEffectiveness({
  policyId: 'community-safe',
  from: '2024-01-01',
  to: '2024-01-31'
})

// Returns:
{
  totalDecisions: 150000,
  appealed: 450,
  appealedOverturned: 45,
  falsePositiveRate: 0.0003, // 0.03%
  byCategory: {
    harassment: {
      decisions: 2500,
      appealed: 125,
      overturned: 12
    },
    // ...
  }
}

Compliance Reports

DSA Transparency Report

Generate reports required by the Digital Services Act:

typescript
const dsaReport = await vettly.generateDSAReport({
  period: '2024-Q1'
})

// Returns structured data for DSA Article 24 reporting:
{
  period: '2024-Q1',
  totalDecisions: 450000,
  contentRemovals: 4500,
  accountSuspensions: 150,
  byCategory: { /* ... */ },
  appealStats: { /* ... */ },
  averageProcessingTime: '< 24 hours',
  automatedDecisionPercentage: 98.5
}

Custom Compliance Reports

typescript
const report = await vettly.generateComplianceReport({
  template: 'internal-audit',
  period: '2024-01',
  includeDecisionSamples: true,
  sampleSize: 100
})

Retention and Archival

Retention Policies

Configure how long decisions are retained:

typescript
await vettly.setRetentionPolicy({
  default: '90d',
  byAction: {
    block: '365d', // Keep blocked decisions longer
    flag: '180d'
  },
  legalHold: 'indefinite'
})

Archival

Move old decisions to cold storage:

typescript
await vettly.archiveDecisions({
  olderThan: '180d',
  destination: {
    type: 's3',
    bucket: 'moderation-archive',
    storageClass: 'GLACIER'
  }
})

Deletion

For GDPR compliance:

typescript
// Delete all decisions for a user
await vettly.deleteDecisions({
  userId: 'user_123',
  reason: 'GDPR erasure request',
  retainAnonymizedStats: true // Keep aggregate stats
})

Access Control

Audit Log Access

typescript
await vettly.setAuditAccess({
  role: 'compliance-team',
  permissions: [
    'listDecisions',
    'exportDecisions',
    'generateReports'
  ],
  filters: {
    // Can only see decisions, not content
    excludeFields: ['input.content']
  }
})

External Auditor Access

typescript
const auditorToken = await vettly.createAuditorAccess({
  name: 'Q1 2024 External Audit',
  permissions: ['read'],
  dateRange: {
    from: '2024-01-01',
    to: '2024-03-31'
  },
  expiresAt: '2024-05-01'
})

Next Steps