Skip to main content
GET
/
v1
/
logs
curl -X GET "https://api.trusec.io/v1/logs?limit=50&events=user.login,user.logout" \
  -H "Authorization: Bearer trusec_sk_your_api_key"
{
  "data": [
    {
      "id": "log_abc123",
      "timestamp": "2024-01-20T15:30:00.000Z",
      "event": "user.login",
      "actor": {
        "id": "user_123",
        "email": "[email protected]",
        "type": "user"
      },
      "target": {
        "id": "session_xyz",
        "type": "session"
      },
      "context": {
        "ip": "192.168.1.100",
        "userAgent": "Mozilla/5.0...",
        "location": {
          "city": "San Francisco",
          "country": "US"
        }
      },
      "result": "success"
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "cur_def456"
  }
}

List Logs

Retrieve audit log entries.
limit
integer
default:"50"
Number of logs to return (1-1000)
cursor
string
Pagination cursor
from
string
Start timestamp (ISO 8601)
to
string
End timestamp (ISO 8601)
events
array
Filter by event types
actor
string
Filter by actor ID
result
string
Filter by result: success or failure
curl -X GET "https://api.trusec.io/v1/logs?limit=50&events=user.login,user.logout" \
  -H "Authorization: Bearer trusec_sk_your_api_key"
{
  "data": [
    {
      "id": "log_abc123",
      "timestamp": "2024-01-20T15:30:00.000Z",
      "event": "user.login",
      "actor": {
        "id": "user_123",
        "email": "[email protected]",
        "type": "user"
      },
      "target": {
        "id": "session_xyz",
        "type": "session"
      },
      "context": {
        "ip": "192.168.1.100",
        "userAgent": "Mozilla/5.0...",
        "location": {
          "city": "San Francisco",
          "country": "US"
        }
      },
      "result": "success"
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "cur_def456"
  }
}

Get Log

Retrieve a specific log entry by ID.
id
string
required
The log entry ID
curl -X GET "https://api.trusec.io/v1/logs/log_abc123" \
  -H "Authorization: Bearer trusec_sk_your_api_key"
{
  "data": {
    "id": "log_abc123",
    "timestamp": "2024-01-20T15:30:00.000Z",
    "event": "user.login",
    "actor": {
      "id": "user_123",
      "email": "[email protected]",
      "type": "user"
    },
    "target": {
      "id": "session_xyz",
      "type": "session"
    },
    "context": {
      "ip": "192.168.1.100",
      "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
      "location": {
        "city": "San Francisco",
        "region": "California",
        "country": "US",
        "coordinates": {
          "lat": 37.7749,
          "lng": -122.4194
        }
      }
    },
    "result": "success",
    "traceId": "trace_xyz789",
    "metadata": {
      "mfaUsed": true,
      "authMethod": "password"
    }
  }
}

Search Logs

Full-text search across log entries.
query
string
required
Search query string
from
string
Start timestamp (ISO 8601)
to
string
End timestamp (ISO 8601)
limit
integer
default:"50"
Number of results to return
curl -X POST "https://api.trusec.io/v1/logs/search" \
  -H "Authorization: Bearer trusec_sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "password reset failed",
    "from": "2024-01-01T00:00:00Z",
    "limit": 20
  }'
{
  "data": [
    {
      "id": "log_search123",
      "timestamp": "2024-01-15T10:00:00.000Z",
      "event": "user.password_reset.failed",
      "actor": {
        "email": "[email protected]",
        "type": "anonymous"
      },
      "result": "failure",
      "highlights": {
        "event": "<em>password</em> <em>reset</em> <em>failed</em>"
      }
    }
  ],
  "meta": {
    "totalHits": 5,
    "searchTimeMs": 12
  }
}

Export Logs

Export logs for compliance or analysis.
from
string
required
Start timestamp (ISO 8601)
to
string
required
End timestamp (ISO 8601)
format
string
default:"json"
Export format: json or csv
events
array
Filter by event types
includeMetadata
boolean
default:"true"
Include full metadata in export
curl -X POST "https://api.trusec.io/v1/logs/export" \
  -H "Authorization: Bearer trusec_sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "2024-01-01T00:00:00Z",
    "to": "2024-01-31T23:59:59Z",
    "format": "csv"
  }'
{
  "data": {
    "exportId": "exp_abc123",
    "status": "processing",
    "format": "csv",
    "estimatedRecords": 15000,
    "createdAt": "2024-01-20T16:00:00Z"
  }
}

Get Export Status

Check the status of a log export.
exportId
string
required
The export ID
curl -X GET "https://api.trusec.io/v1/logs/export/exp_abc123" \
  -H "Authorization: Bearer trusec_sk_your_api_key"
{
  "data": {
    "exportId": "exp_abc123",
    "status": "completed",
    "format": "csv",
    "totalRecords": 14892,
    "fileSizeBytes": 2458920,
    "downloadUrl": "https://exports.trusec.io/exp_abc123.csv?token=...",
    "expiresAt": "2024-01-21T16:00:00Z",
    "createdAt": "2024-01-20T16:00:00Z",
    "completedAt": "2024-01-20T16:02:30Z"
  }
}
Export download URLs expire after 24 hours. Generate a new export if the URL has expired.