PHP 8.2.30
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

Name Size Perms Modified Actions
.adminjs DIR
- drwxr-xr-x 2026-03-14 01:49:04
Edit Download
config DIR
- drwxr-xr-x 2026-03-14 01:49:04
Edit Download
- drwxr-xr-x 2026-03-14 01:49:12
Edit Download
- drwxr-xr-x 2026-03-14 01:49:04
Edit Download
- drwxr-xr-x 2026-03-14 01:49:04
Edit Download
images DIR
- drwxr-xr-x 2026-03-21 09:47:23
Edit Download
- drwxr-xr-x 2026-03-22 12:37:17
Edit Download
- drwxr-xr-x 2026-03-14 01:49:04
Edit Download
prisma DIR
- drwxr-xr-x 2026-03-14 01:49:04
Edit Download
routes DIR
- drwxr-xr-x 2026-03-20 23:25:48
Edit Download
scripts DIR
- drwxr-xr-x 2026-03-20 00:05:44
Edit Download
services DIR
- drwxr-xr-x 2026-03-20 11:35:27
Edit Download
tmp DIR
- drwxr-xr-x 2026-03-22 07:35:33
Edit Download
utils DIR
- drwxr-xr-x 2026-03-14 01:49:04
Edit Download
1.87 KB lrw-r--r-- 2026-03-02 07:23:00
Edit Download
3.02 KB lrw-r--r-- 2026-02-26 16:27:46
Edit Download
54 B lrw-r--r-- 2026-03-03 05:21:52
Edit Download
1.99 KB lrw-r--r-- 2026-03-02 04:00:46
Edit Download
1.99 KB lr--r--r-- 2026-03-14 01:40:10
Edit Download
21.77 KB lrw-r--r-- 2026-03-04 23:41:22
Edit Download
95.99 MB lrw-r--r-- 2026-03-04 23:40:43
Edit Download
23.32 KB lr--r--r-- 2026-03-14 00:49:43
Edit Download
5.12 KB lrw-r--r-- 2026-03-02 08:04:38
Edit Download
360.34 KB lrw-r--r-- 2026-02-28 13:42:20
Edit Download
1.94 KB lrw-r--r-- 2026-03-05 15:13:41
Edit Download
33.05 KB lrw-r--r-- 2026-02-28 12:52:54
Edit Download
374 B lrw-r--r-- 2026-01-26 22:49:38
Edit Download
37.08 KB lrw-r--r-- 2026-02-26 16:27:46
Edit Download
88 B lrw-r--r-- 2026-03-14 00:49:44
Edit Download
7.04 KB lrw-r--r-- 2026-03-04 23:57:24
Edit Download
331.20 KB lrw-r--r-- 2026-03-12 06:51:30
Edit Download
6.32 KB lrw-r--r-- 2026-02-26 16:27:46
Edit Download
6.11 KB lr--r--r-- 2026-03-14 01:40:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).