Authentication
All Admin API endpoints require JWT authentication using the Bearer token scheme.How Authentication Works
- Login: Obtain a JWT token via
/api/admin/login - Authorization Header: Include the token in all subsequent requests:
- Token Validation: The server validates the JWT signature using
JWT_SECRETenvironment variable - Token Expiry: Tokens expire after 24 hours
Login Endpoint
POST /api/admin/login
Authenticate admin users and obtain JWT token
Request Body
Admin email address (used as username)
Admin account password (bcrypt hashed in database)
Response
Indicates authentication success
JWT token valid for 24 hours
Example Request
Example Response
Implementation Details
Fromlogin.js:33-47:
Role-Based Access Control
The Admin API supports three user roles:ADMIN
Full system access
WAREHOUSE
Inventory and fulfillment
SUPPORT
Customer service operations
Role validation is handled by the frontend
ProtectedRoute component. All authenticated users with valid JWT tokens can access Admin API endpoints.Error Responses
All endpoints return consistent error formats:API Endpoints
Orders
Manage customer orders, confirmations, and shipping
Inventory
Product catalog and stock management
Knowledge Base
RAG content for AI assistant
Dashboard Stats
Business metrics and analytics