Get audit statistics
const url = 'http://localhost:3000/api/v1/audit/stats?startDate=2024-01-01T00%3A00%3A00Z&endDate=2024-12-31T23%3A59%3A59Z';const options = {method: 'GET', headers: {'X-API-Key': '<X-API-Key>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'http://localhost:3000/api/v1/audit/stats?startDate=2024-01-01T00%3A00%3A00Z&endDate=2024-12-31T23%3A59%3A59Z' \ --header 'X-API-Key: <X-API-Key>'Retrieves audit log statistics for the organization.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Example
2024-01-01T00:00:00ZStart of the period (ISO 8601)
Example
2024-12-31T23:59:59ZEnd of the period (ISO 8601); not before startDate
Header Parameters
Section titled “Header Parameters”UUID of the organization (tenant) the request acts in. It selects the tenant and grants nothing: the server checks membership or an open tenant switch. Not needed for global operations. A malformed value returns 400. API keys are fixed to their own organization; another organization returns 403. The x-organization-source header grants nothing.
Responses
Section titled “Responses”Audit statistics retrieved successfully
object
Total number of audit entries
Count by action type
object
Count by entity type
object
Top users by activity
object
User ID
Number of audit entries
Share of successful entries in percent (0-100)
Example
{ "totalCount": 1500, "byAction": { "CREATE": 500, "UPDATE": 800, "DELETE": 200 }, "byEntityType": { "Device": 900, "User": 400, "Organization": 200 }, "byUser": [ { "userId": "550e8400-e29b-41d4-a716-446655440000", "count": 42 } ], "successRate": 95}Malformed date, or startDate after endDate
Unauthorized
Forbidden — caller lacks required permission