Preview: NEW_FRONTEND_ENDPOINTS.md
Size: 5.12 KB
/home/byroehnu/easepaybiz.easetack.com/NEW_FRONTEND_ENDPOINTS.md
# 🚀 EasePay Backend API Endpoints (For Frontend Developer)
**Base URL for local testing:** `http://localhost:5004`
**Note for Frontend dev:** Most routes require the JWT token to be sent in the header:
`Authorization: Bearer <your_token>`
---
## 🔐 1. Authentication & Security Endpoints
**Check User Status (First step of login/signup)**
- `POST /api/auth/check-user-status`
- **Body:** `{ "phone": "+234..." }`
- **Notes:** Tells the frontend if the user is new, needs an OTP, or can log in instantly without a password.
**Send OTP**
- `POST /api/auth/send-otp`
- **Body:** `{ "phone": "+234...", "method": "sms" }`
**Verify OTP**
- `POST /api/auth/verify-otp`
- **Body:** `{ "phone": "+234...", "otp": "123456", "verificationId": "..." }`
- **Returns:** JWT Token `token`
**Password Login (For returning users with passwords)**
- `POST /api/auth/signin`
- **Body:** `{ "identifier": "+234...", "password": "..." }`
**Setup/Create Password**
- `POST /api/auth/setup-password`
- **Headers:** `Authorization: Bearer <token>`
- **Body:** `{ "password": "...", "confirmPassword": "..." }`
**Setup PIN (4-6 digit quick login)**
- `POST /api/auth/setup-pin`
- **Headers:** `Authorization: Bearer <token>`
- **Body:** `{ "pin": "1234", "confirmPin": "1234" }`
**PIN Login**
- `POST /api/auth/login-pin`
- **Body:** `{ "phone": "+234...", "pin": "1234" }`
**Enable Biometric Login**
- `POST /api/auth/enable-biometric`
- **Headers:** `Authorization: Bearer <token>`
- **Body:** `{ "deviceId": "...", "deviceType": "ios/android", "publicKey": "..." }`
**Biometric Login**
- `POST /api/auth/login-biometric`
- **Body:** `{ "phone": "+234...", "deviceId": "...", "biometricSignature": "..." }`
**Complete Initial Onboarding**
- `POST /api/auth/complete-onboarding`
- **Headers:** `Authorization: Bearer <token>`
- **Body Requirements:** `phone`, `businessName`, and `businessType` are **strictly required**.
- **Important:** `businessType` MUST EXACTLY match one of these valid values: `"RETAIL"`, `"SERVICE"`, `"MANUFACTURING"`, `"TECHNOLOGY"`, `"CONSULTING"`, `"RESTAURANT"`, `"HEALTHCARE"`, `"EDUCATION"`, `"REAL_ESTATE"`, `"OTHER"`.
- **Body:** `{ "phone": "+234...", "businessName": "...", "businessType": "RETAIL", ... }`
**Get Current User Profile**
- `GET /api/auth/me`
- **Headers:** `Authorization: Bearer <token>`
---
## 🏢 2. Business Management
**Get Business Profile**
- `GET /api/business-profiles/me`
**Update Business Profile**
- `PUT /api/business-profiles/me`
- **Body:** `{ "businessName": "...", "address": "...", "taxId": "...", "logo": "..." }`
**Get Team Members**
- `GET /api/businesses/team`
**Invite Team Member**
- `POST /api/businesses/team/invite`
- **Body:** `{ "email": "...", "role": "admin/manager/staff" }`
**Remove Team Member**
- `DELETE /api/businesses/team/:userId`
---
## 📊 3. Dashboard Endpoints
**Get Main Dashboard Metrics (Cards)**
- `GET /api/dashboard/metrics?period=month`
- **Returns:** Revenue, sales count, unpaid invoices, products run out.
**Get Revenue Chart Data**
- `GET /api/dashboard/revenue-chart?period=year`
- **Returns:** Formatted arrays for the graph/chart in the app.
---
## 🧾 4. Invoice & Income Management
**Create Invoice**
- `POST /api/invoices`
- **Body:** `{ "customerName": "...", "items": [{...}], "dueDate": "...", "subtotal": ... }`
**Get All Invoices (With Pagination/Filters)**
- `GET /api/invoices?status=PENDING&page=1&limit=10`
**Get Single Invoice Details**
- `GET /api/invoices/:id`
**Update Invoice Status (Mark as Paid)**
- `PUT /api/invoices/:id/status`
- **Body:** `{ "status": "PAID" }`
**Send Invoice to Customer (Email)**
- `POST /api/invoices/:id/send`
**Generate Public Invoice Link / PDF**
- `GET /api/invoices/:id/download-link`
**Record a Direct Sale (No Invoice)**
- `POST /api/sales`
- **Body:** `{ "amount": ..., "paymentMethod": "CASH/CARD/TRANSFER", "items": [{...}] }`
**Get Sales History**
- `GET /api/sales`
---
## 💸 5. Expense Management
**Log New Expense**
- `POST /api/expenses`
- **Body:** `{ "amount": ..., "category": "Equipment", "description": "...", "date": "..." }`
**Get All Expenses**
- `GET /api/expenses?category=Equipment`
**Get Expense Categories List**
- `GET /api/expenses/categories`
---
## 📦 6. Inventory & Product Management
**Create Product**
- `POST /api/inventory`
- **Body:** `{ "name": "...", "price": 1500, "quantity": 50, "sku": "...", "category": "..." }`
**Get All Inventory Items**
- `GET /api/inventory`
**Update Product Details**
- `PUT /api/inventory/:id`
**Adjust Stock Level**
- `PATCH /api/inventory/:id/stock`
- **Body:** `{ "quantityChange": -5, "reason": "sale" }`
**Delete Product**
- `DELETE /api/inventory/:id`
---
## ⚙️ 7. Settings & Configuration
**Get User Settings**
- `GET /api/settings`
**Update General Settings**
- `PUT /api/settings`
- **Body:** `{ "currency": "NGN", "language": "en", "notificationsEnabled": true }`
**Update Security Settings**
- `PUT /api/auth/security-settings`
- **Body:** `{ "requireOTPForLogin": true, "autoLoginEnabled": true }`
Directory Contents
Dirs: 14 × Files: 19