Skip to content

Admin

Admin Login

Endpoint: POST /admin/login

Description: Authenticate admin or super_admin user and return JWT tokens. Only users with role='admin' or role='super_admin' can login.

Request Body:

{
    "email": "admin@example.com",
    "password": "password123"
}

Response: 200 OK

{
    "access_token": "<ACCESS_TOKEN>",
    "refresh_token": "<REFRESH_TOKEN>",
    "user": {
        "id": "admin_uuid",
        "full_name": "Admin User",
        "email": "admin@example.com",
        "role": "admin"
    }
}

Register Admin

Endpoint: POST /admin/register

Description: Register a new admin. (Super Admin only)

Request Body:

{
    "full_name": "Admin User",
    "email": "admin@example.com",
    "password": "password123",
    "phone": "+1234567890",
    "role": "admin"
}

Response: 201 Created

{
    "status": "success",
    "message": "Admin account created successfully.",
    "data": {
        "admin": {
            "id": "admin_uuid",
            "full_name": "Admin User",
            "email": "admin@example.com",
            "phone": "+1234567890",
            "role": "admin",
            "is_active": true
        }
    }
}

Delete Admin Account

Endpoint: DELETE /admin/{admin_id}

Description: Delete an admin account. (Super Admin only)

Response: 200 OK

{
    "status": "success",
    "message": "Admin account deleted successfully.",
    "data": {}
}

Get Overview Summary

Endpoint: GET /admin/overview/summary

Description: Get summary cards for the overview dashboard: Total Users, Active Users, Total Posts, Banned Users.

Query Parameters: - period (string): Time period: last_week, last_month, last_year. Default: last_month.

Response: 200 OK

{
    "total_users": {
        "value": "1,234",
        "change_percent": 15.0,
        "change_label": "15% more than last month"
    },
    "active_users": {
        "value": "567",
        "change_percent": -5.2,
        "change_label": "5% less than last month"
    },
    "total_posts": {
        "value": "8,901",
        "change_percent": 20.0,
        "change_label": "20% more than last month"
    },
    "banned_users": {
        "value": "12",
        "change_percent": 50.0,
        "change_label": "50% more than last month"
    }
}

Get Post and Engagement Chart

Endpoint: GET /admin/overview/charts/post-engagement

Description: Get line chart data for "Post and Engagement". Returns time series data showing posts and engagement metrics over time.

Query Parameters: - period (string): Time period: last_7_days, last_month, last_year. Default: last_7_days.

Response: 200 OK

{
    "period": "Last 7 Days",
    "data": [
        {
            "date": "Jan 01",
            "value": 120
        },
        {
            "date": "Jan 02",
            "value": 150
        }
    ]
}

Get Recent Posts

Endpoint: GET /admin/overview/recent-posts

Description: Get paginated recent posts for the overview table. Returns posts with user info, reactions, comments, and status.

Query Parameters: - page (integer): Page number. Default: 1. - page_size (integer): Items per page. Default: 10. - search (string, optional): Search posts by title or content.

Response: 200 OK

{
    "posts": [
        {
            "post_id": "post_uuid",
            "user": {
                "id": "user_uuid",
                "full_name": "Jane Doe",
                "avatar_url": "https://example.com/avatar.jpg",
                "online_status": "Online"
            },
            "post_preview": "This is a preview of the post content...",
            "reactions_count": 10,
            "comments_count": 5,
            "date_posted": "2026-01-05T19:01:38.123Z",
            "user_status": "Active",
            "actions": ["view", "edit", "delete"]
        }
    ],
    "total": 1,
    "page": 1,
    "page_size": 10,
    "total_pages": 1
}