Skip to content

Retrieve Audit Logs

Fetch audit logs from your Traccar server. Only administrators can access this endpoint.

Request

Use the ThingsTelemetry\Traccar\Facades\Audit::get(?CarbonImmutable $from = null, ?CarbonImmutable $to = null) method to retrieve audit logs.

php
use ThingsTelemetry\Traccar\Facades\Audit;
use Carbon\CarbonImmutable;

$from = CarbonImmutable::parse('2025-01-01');
$to = CarbonImmutable::parse('2025-01-02');

$auditLogs = Audit::get(from: $from, to: $to); // Illuminate\Support\Collection<int, ThingsTelemetry\Traccar\Dto\AuditData>

Parameters

ParameterTypeDescription
from?CarbonImmutableStart date for audit logs (optional).
to?CarbonImmutableEnd date for audit logs (optional).

Result

The response is a Collection of ThingsTelemetry\Traccar\Dto\AuditData instances.

php
foreach ($auditLogs as $log) {
    $id         = $log->id;
    $userId     = $log->userId;
    $userEmail  = $log->userEmail;
    $type       = $log->type;
    $actionTime = $log->actionTime; // CarbonImmutable
    $attributes = $log->attributes; // array
}

Released under the MIT License.