Skip to main content
GET
/
api
/
admin
/
users
/
limits
List All User Limits
curl --request GET \
  --url https://api.example.com/api/admin/users/limits
{
  "users": [
    {
      "user_id": 123,
      "username": "<string>",
      "email": "<string>",
      "max_files": 123,
      "max_storage": 123,
      "current_files": 123,
      "current_storage": 123,
      "remaining_files": 123,
      "remaining_storage": 123
    }
  ],
  "error": "<string>"
}
Fetch comprehensive limit and usage data for all users in the system. This admin endpoint returns maximum allowed limits, current usage, and remaining capacity for each user.

Endpoint

GET /api/admin/users/limits

Authentication

Requires authentication via JWT token in Authorization header. Currently uses standard AuthRequired() middleware. Admin-specific authorization is planned for future implementation.
Authorization: Bearer <jwt_token>
Source: routes/routes.go:58

Response

Success Response (200)

users
array
Array of user limit objects
user_id
integer
Unique identifier for the user
username
string
User’s username
email
string
User’s email address
max_files
integer
Maximum number of files allowed for this user
max_storage
integer
Maximum storage capacity in bytes for this user
current_files
integer
Current number of files uploaded by this user
current_storage
integer
Current storage used in bytes (sum of all file sizes)
remaining_files
integer
Number of additional files that can be uploaded (max_files - current_files)
remaining_storage
integer
Remaining storage capacity in bytes (max_storage - current_storage)

Example Response

{
  "users": [
    {
      "user_id": 1,
      "username": "alice",
      "email": "[email protected]",
      "max_files": 1000,
      "max_storage": 10737418240,
      "current_files": 245,
      "current_storage": 5368709120,
      "remaining_files": 755,
      "remaining_storage": 5368709120
    },
    {
      "user_id": 2,
      "username": "bob",
      "email": "[email protected]",
      "max_files": 500,
      "max_storage": 5368709120,
      "current_files": 12,
      "current_storage": 104857600,
      "remaining_files": 488,
      "remaining_storage": 5263851520
    }
  ]
}

Error Response (500)

error
string
Error message if database query fails
{
  "error": "Failed to get users"
}

Implementation Details

Data Aggregation

For each user, the endpoint performs two database queries:
  1. File Count: COUNT(*) on files table where user_id matches
  2. Storage Sum: COALESCE(SUM(size), 0) on files table where user_id matches
The COALESCE ensures users with no files return 0 instead of NULL. Source: controllers/user.go:206-212

Calculated Fields

  • remaining_files = max_files - current_files
  • remaining_storage = max_storage - current_storage
These are computed in-memory after fetching database values. Source: controllers/user.go:222-223
The endpoint returns all users without pagination. For systems with large numbers of users, consider implementing pagination in production.

Use Cases

  • Monitor system-wide storage allocation
  • Identify users approaching their limits
  • Audit capacity planning requirements
  • Generate usage reports for billing or compliance

Build docs developers (and LLMs) love