Skip to main content

Get Tenant Statistics

Get tenant statistics. This endpoint retrieves usage statistics and metrics for a specific tenant. Tenant admins can view their own tenant's statistics.


Endpoint

Method: GET URL: {{base_url}}/api/v1/admin/tenants/{tenantId}/stats


Authentication

This endpoint uses Bearer Token authentication via a JWT (JSON Web Token). The token must be included in the Authorization header.


Headers

HeaderDescriptionRequired
AuthorizationBearer token (JWT) for authenticationYes
acceptSpecifies acceptable response formats (application/json)Yes
x-tenantidUUID identifying the tenant/organizationYes
realmnameThe authentication realm nameNo

Path Parameters

ParameterTypeDescriptionRequired
tenantIdstring (UUID)The unique identifier of the tenantYes

Query Parameters

None.


Request Body Schema

Not applicable — this is a GET request with no request body.


Example cURL

curl --request GET \
--url '{{base_url}}/api/v1/admin/tenants/3fa85f64-5717-4562-b3fc-2c963f66afa6/stats' \
--header 'accept: application/json' \
--header 'authorization: Bearer {{access_token}}' \
--header 'x-tenantid: {{tenant_id}}'

Success Response Example

Status Code: 200 OK

{
"success": true,
"message": "Tenant statistics retrieved successfully",
"data": {
"tenantId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"tenantName": "Acme Corporation",
"users": {
"total": 150,
"active": 142,
"inactive": 8,
"admins": 5
},
"credentials": {
"total": 25,
"active": 23,
"expired": 2
},
"apiKeys": {
"total": 10,
"active": 9,
"revoked": 1
},
"oauthClients": {
"total": 5,
"active": 5
},
"usage": {
"apiCallsThisMonth": 125000,
"apiCallsLastMonth": 118000,
"storageUsedMB": 2500,
"storageQuotaMB": 10000
},
"lastActivity": "2025-07-10T14:30:00.000Z",
"generatedAt": "2025-07-10T14:40:00.000Z"
},
"timestamp": "2025-07-10T14:40:00.000Z"
}

Error Responses

Status CodeErrorDescription
400 Bad RequestInvalid tenant IDThe tenantId is not a valid UUID
401 UnauthorizedAuthentication failedBearer token is missing, expired, or invalid
403 ForbiddenInsufficient permissionsUser lacks permission to view this tenant's stats
404 Not FoundTenant not foundNo tenant exists with the specified ID
500 Internal Server ErrorServer errorUnexpected server-side error

Notes

  1. Self-Access: Tenant admins can view their own tenant statistics.

  2. Real-Time: Statistics are generated in real-time and reflect current state.

  3. Usage Tracking: API call counts and storage usage help monitor resource consumption.

  4. Required Roles: Requires tenant_admin or super_admin role.