Skip to main content

🔐 Admin API Documentation

Administrative API endpoints for managing users, content, and platform operations. These endpoints require elevated permissions and are restricted to authorized administrators.

🛡️ Authentication & Authorization

Required Permissions

All admin endpoints require:

  • Valid JWT token with admin privileges
  • Admin role assigned to the user account
  • Specific permissions for each endpoint category

Admin Token Format

Authorization: Bearer ADMIN_JWT_TOKEN_HERE

Permission Levels

PermissionDescriptionEndpoints
admin:readView admin dataGET endpoints
admin:writeModify admin dataPOST, PUT, PATCH endpoints
admin:deleteDelete admin dataDELETE endpoints
admin:superFull admin accessAll admin endpoints

👥 User Management

List All Users

GET /api/v1/admin/users

Retrieve a paginated list of all platform users.

Query Parameters

ParameterTypeDefaultDescription
limitnumber50Maximum users per page
offsetnumber0Number of users to skip
statusstringallFilter by status: active, inactive, banned
rolestringallFilter by role: user, admin, moderator
searchstring-Search by username or email
sortstringcreated_atSort field
orderstringdescSort order: asc, desc

Example Request

curl -X GET "https://api.idling.app/api/v1/admin/users?limit=20&status=active" \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Accept: application/json"

Response

{
"success": true,
"data": [
{
"id": "user_123",
"username": "johndoe",
"email": "john@example.com",
"status": "active",
"role": "user",
"createdAt": "2024-01-01T00:00:00.000Z",
"lastLoginAt": "2024-01-15T10:30:00.000Z",
"postCount": 25,
"isVerified": true
}
],
"meta": {
"pagination": {
"total": 1000,
"limit": 20,
"offset": 0,
"hasMore": true
}
}
}

Get User Details

GET /api/v1/admin/users/{userId}

Retrieve detailed information about a specific user.

Path Parameters

ParameterTypeDescription
userIdstringUser ID to retrieve

Example Request

curl -X GET "https://api.idling.app/api/v1/admin/users/user_123" \
-H "Authorization: Bearer ADMIN_TOKEN"

Update User

PUT /api/v1/admin/users/{userId}

Update user information and settings.

Request Body

{
"status": "active",
"role": "moderator",
"isVerified": true,
"notes": "Promoted to moderator"
}

Ban/Unban User

POST /api/v1/admin/users/{userId}/ban

Ban or unban a user account.

Request Body

{
"action": "ban",
"reason": "Violation of community guidelines",
"duration": "7d",
"notes": "Temporary ban for spam"
}

📝 Content Management

List All Posts

GET /api/v1/admin/posts

Retrieve all posts across the platform with admin metadata.

Query Parameters

ParameterTypeDefaultDescription
limitnumber50Maximum posts per page
offsetnumber0Number of posts to skip
statusstringallFilter by status: published, draft, hidden, flagged
authorstring-Filter by author user ID
reportedboolean-Show only reported posts
sortstringcreated_atSort field
orderstringdescSort order

Example Request

curl -X GET "https://api.idling.app/api/v1/admin/posts?reported=true&limit=10" \
-H "Authorization: Bearer ADMIN_TOKEN"

Response

{
"success": true,
"data": [
{
"id": "post_456",
"title": "Example Post",
"content": "Post content...",
"author": {
"id": "user_123",
"username": "johndoe"
},
"status": "flagged",
"reportCount": 3,
"reports": [
{
"reason": "spam",
"reportedBy": "user_789",
"reportedAt": "2024-01-15T09:00:00.000Z"
}
],
"createdAt": "2024-01-14T15:30:00.000Z",
"updatedAt": "2024-01-15T09:00:00.000Z"
}
],
"meta": {
"pagination": {
"total": 150,
"limit": 10,
"offset": 0,
"hasMore": true
}
}
}

Moderate Post

POST /api/v1/admin/posts/{postId}/moderate

Take moderation action on a post.

Request Body

{
"action": "hide",
"reason": "Inappropriate content",
"notes": "Hidden pending review",
"notifyAuthor": true
}

Available Actions

  • approve - Approve flagged post
  • hide - Hide post from public view
  • delete - Permanently delete post
  • flag - Flag for further review

📊 Analytics & Reports

Platform Analytics

GET /api/v1/admin/analytics

Retrieve platform-wide analytics and metrics.

Query Parameters

ParameterTypeDefaultDescription
periodstring7dTime period: 1d, 7d, 30d, 90d, 1y
metricsstring[]allSpecific metrics to include

Example Request

curl -X GET "https://api.idling.app/api/v1/admin/analytics?period=30d" \
-H "Authorization: Bearer ADMIN_TOKEN"

Response

{
"success": true,
"data": {
"period": "30d",
"users": {
"total": 10000,
"active": 7500,
"new": 250,
"growth": "+2.5%"
},
"content": {
"totalPosts": 50000,
"newPosts": 1200,
"moderatedPosts": 45,
"flaggedPosts": 23
},
"engagement": {
"avgSessionDuration": "15m 30s",
"dailyActiveUsers": 2500,
"postsPerUser": 6.7
},
"moderation": {
"reportsReceived": 67,
"reportsResolved": 62,
"averageResolutionTime": "2h 15m"
}
}
}

User Activity Report

GET /api/v1/admin/reports/user-activity

Generate detailed user activity reports.

Query Parameters

ParameterTypeDescription
userIdstringSpecific user ID (optional)
startDatestringStart date (ISO format)
endDatestringEnd date (ISO format)
includeDetailsbooleanInclude detailed activity logs

Content Moderation Report

GET /api/v1/admin/reports/moderation

Generate content moderation reports and statistics.

🔧 Administrative Actions

System Maintenance

POST /api/v1/admin/system/maintenance

Trigger system maintenance tasks.

Request Body

{
"action": "cache_clear",
"scope": "all",
"notify": true
}

Available Actions

  • cache_clear - Clear application cache
  • rebuild_search - Rebuild search indexes
  • cleanup_uploads - Clean up orphaned files
  • backup_database - Trigger database backup

Send Platform Notification

POST /api/v1/admin/notifications/broadcast

Send platform-wide notifications to users.

Request Body

{
"title": "Platform Update",
"message": "We've released new features!",
"type": "info",
"targets": ["all"],
"schedule": "immediate"
}

Feature Flags

GET /api/v1/admin/feature-flags

Manage platform feature flags and toggles.

PUT /api/v1/admin/feature-flags/{flagName}

Update feature flag settings.

🚦 Rate Limiting

Admin Rate Limits

  • General Admin: 5000 requests per hour
  • Super Admin: 10000 requests per hour
  • System Actions: 100 requests per hour

Rate Limit Headers

X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
X-RateLimit-Reset: 1640995200
X-Admin-Tier: general

🔍 Audit Logging

All admin actions are automatically logged with:

  • Timestamp - When the action occurred
  • Admin User - Who performed the action
  • Action Type - What was done
  • Target - What was affected
  • IP Address - Where the action originated
  • User Agent - Client information

View Audit Logs

GET /api/v1/admin/audit-logs

Retrieve admin action audit logs.

Query Parameters

ParameterTypeDescription
adminIdstringFilter by admin user
actionstringFilter by action type
startDatestringStart date filter
endDatestringEnd date filter
limitnumberResults per page
offsetnumberResults offset

🚨 Error Handling

Admin-Specific Errors

403 Insufficient Permissions

{
"success": false,
"error": {
"code": "INSUFFICIENT_ADMIN_PERMISSIONS",
"message": "This action requires super admin privileges",
"requiredPermission": "admin:super"
}
}

423 Resource Locked

{
"success": false,
"error": {
"code": "RESOURCE_LOCKED",
"message": "This resource is currently being modified by another admin",
"lockedBy": "admin_user_456",
"lockedAt": "2024-01-15T10:30:00.000Z"
}
}

💡 Best Practices

1. Audit Trail

Always include meaningful notes when taking moderation actions:

{
"action": "ban",
"reason": "Spam violation",
"notes": "User posted 50+ promotional links in 1 hour"
}

2. Batch Operations

Use batch endpoints for bulk operations when available:

POST /api/v1/admin/users/bulk-update

3. Monitoring

Monitor admin actions and set up alerts for:

  • High-frequency admin actions
  • Failed admin requests
  • Unusual admin activity patterns

4. Security

  • Use dedicated admin accounts
  • Enable 2FA for admin accounts
  • Regularly rotate admin tokens
  • Monitor admin access logs

📞 Admin Support

Emergency Contacts

Admin Resources

  • Admin Dashboard: admin.idling.app
  • Admin Documentation: Internal admin wiki
  • Admin Training: Quarterly training sessions

Last Updated: January 28, 2025 Admin API Version: v1.0.0

⚠️ Security Notice: Admin endpoints are logged and monitored. All actions are subject to audit and review.