All admin endpoints require authentication with an admin role. Users with the user role will receive a 403 Forbidden error.
Authentication
Admin endpoints require a valid Bearer token from a user with the admin role.
Authorization: Bearer YOUR_ADMIN_ACCESS_TOKEN
You can obtain an access token by logging in with admin credentials via the Login endpoint.
Dashboard Statistics
Get comprehensive statistics for the admin dashboard.
Endpoint
curl -X GET 'https://api.ceboelha.com/admin/dashboard/stats' \
-H 'Authorization: Bearer YOUR_ADMIN_TOKEN' \
-H 'Content-Type: application/json'
Response
Indicates if the request was successful
Dashboard statistics
User statistics
New users registered today
New users registered this week
Content statistics
Number of published articles
Total number of foods in database
Activity statistics
Total diary entries in system
Response Example
{
"success": true,
"data": {
"users": {
"total": 1543,
"active": 1421,
"new_today": 12,
"new_week": 87
},
"content": {
"total_articles": 145,
"published_articles": 132,
"total_foods": 5432
},
"activity": {
"meals_logged_today": 234,
"symptoms_logged_today": 156,
"total_diary_entries": 45678
}
}
}
Activity Log
Get paginated activity logs with optional filters.
Endpoint
curl -X GET 'https://api.ceboelha.com/admin/activity-log?page=1&limit=20&type=user' \
-H 'Authorization: Bearer YOUR_ADMIN_TOKEN' \
-H 'Content-Type: application/json'
Query Parameters
Page number for pagination
Number of logs per page (1-100)
Filter by activity type: user, content, food, admin, or all
Filter by specific user ID
Filter logs from this date (ISO 8601 format)
Filter logs until this date (ISO 8601 format)
Response
Indicates if the request was successful
Array of activity log objects
Pagination information (page, limit, total, totalPages, hasMore)
Response Example
{
"success": true,
"data": [
{
"id": "60d5ec49f1a4c3b6d8e9f0a1",
"type": "user",
"action": "user_created",
"details": "New user registered",
"userId": "60d5ec49f1a4c3b6d8e9f0a2",
"userName": "John Doe",
"userEmail": "[email protected]",
"ip_address": "192.168.1.1",
"user_agent": "Mozilla/5.0...",
"timestamp": "2024-03-01T10:30:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 543,
"totalPages": 28,
"hasMore": true
}
}
Analytics
Get analytics data for the specified period.
Endpoint
curl -X GET 'https://api.ceboelha.com/admin/analytics?period=week' \
-H 'Authorization: Bearer YOUR_ADMIN_TOKEN' \
-H 'Content-Type: application/json'
Query Parameters
Time period for analytics: day, week, or month
Response
Indicates if the request was successful
Analytics data including time series data for users, entries, and engagement metrics
Rate Limiting
Admin endpoints have enhanced rate limiting:
- Read operations (GET): 100 requests per minute
- Write operations (POST, PATCH, DELETE): 30 requests per minute
Error Responses
Unauthorized (401)
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Autenticação necessária"
}
}
Forbidden (403)
{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "Acesso restrito a administradores"
}
}
Available Admin Sections
The admin panel provides management for:
- Users - Create, update, delete, and manage users
- System Settings - Configure system-wide settings
- News Articles - Manage news and recipe content
- Foods - Manage food database
- Diary Entries - View and moderate user diary entries
- Problematic Foods - View user-reported problematic foods
- Achievements - Manage achievement definitions