Get audit statistics
GET
/api/v1/audit/stats
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”startDate
string
Example
2024-01-01T00:00:00ZStart date for statistics (ISO 8601 format)
endDate
string
Example
2024-12-31T23:59:59ZEnd date for statistics (ISO 8601 format)
Header Parameters
Section titled “Header Parameters”x-organization-id
string format: uuid
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
Media typeapplication/json
object
totalCount
required
Total number of audit entries
number
byAction
required
Count by action type
object
key
additional properties
number
byEntityType
required
Count by entity type
object
key
additional properties
number
byUser
required
Top users by activity
Array<object>
object
userId
required
User ID
string format: uuid
count
required
Number of audit entries
number
successRate
required
Success rate as a decimal (0-1)
number
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": 0.95}Unauthorized
Forbidden — caller lacks required permission