All API routes are located under src/app/api/. Authentication is handled via Auth.js JWT sessions.
Seller APIs
Membership & Dashboard
| Method | Endpoint | Description |
|---|
GET | /api/seller/membership | Get current user's organisation membership status |
GET | /api/seller/dashboard | Get dashboard stats (active orders, pending requests, earnings, rating) |
GET | /api/seller/requests | Get cake requests matching seller's organisation capabilities |
GET | /api/seller/orders | Get seller's orders (query: ?filter=all|active|completed|cancelled) |
Profile
| Method | Endpoint | Description |
|---|
GET | /api/profile | Get current user profile |
PATCH | /api/profile | Update profile (name, phone, imageUrl) |
Organisation APIs
| Method | Endpoint | Description |
|---|
POST | /api/organisations | Create new organisation |
GET | /api/organisations/{id} | Get organisation details |
GET | /api/organisations/{id}/full | Get organisation with portfolio count and setup status |
PATCH | /api/organisations/{id} | Update organisation settings or toggle active status |
GET | /api/organisations/search | Search organisations (query: ?q=searchTerm) |
Portfolio
| Method | Endpoint | Description |
|---|
GET | /api/organisations/{id}/portfolio | List portfolio items |
POST | /api/organisations/{id}/portfolio | Add portfolio item (imageUrl, caption) |
PUT | /api/organisations/{id}/portfolio | Reorder portfolio items |
DELETE | /api/organisations/{id}/portfolio/{itemId} | Delete portfolio item |
Members
| Method | Endpoint | Description |
|---|
GET | /api/organisations/{id}/members | List organisation members |
POST | /api/organisations/{id}/members | Request to join organisation |
PATCH | /api/organisations/{id}/members/{userId} | Member action: approve, reject, remove, transfer_admin |
Offer APIs
| Method | Endpoint | Description |
|---|
POST | /api/offers | Create offer for a request |
PATCH | /api/offers/{id}/withdraw | Withdraw a pending offer |
Order APIs
| Method | Endpoint | Description |
|---|
PATCH | /api/orders/{id}/status | Update order status (ready, delivered — in_progress is set automatically by the start-work cron) |
PATCH | /api/orders/{id}/mark-paid-offline | Mark balance paid offline (body: { method: 'cash' | 'card_at_pickup' }) |
PATCH | /api/orders/{id}/cancel | Cancel order (body: { reason: string }) |
Payment APIs
| Method | Endpoint | Description |
|---|
GET | /api/payments/org/{id}/earnings | Get earnings summary (this month, last month, all time, pending) |
GET | /api/payments/org/{id}/history | Get payment history (query: ?type=all|deposit|balance|refund) |
POST | /api/payments/stripe-connect/onboard | Start Stripe Connect onboarding (returns redirect URL) |
Message APIs
| Method | Endpoint | Description |
|---|
GET | /api/messages/order/{orderId} | Get messages for an order |
GET | /api/messages/offer/{offerId} | Get messages for an offer |
POST | /api/messages | Send a message |
Review APIs
| Method | Endpoint | Description |
|---|
POST | /api/reviews | Create a review (rating + comment) |
Image APIs
| Method | Endpoint | Description |
|---|
POST | /api/images/generate-seller | Generate AI cake images for seller offers |
Guest APIs
| Method | Endpoint | Description |
|---|
POST | /api/guest/convert | Convert guest session to full user account |
Admin APIs
| Method | Endpoint | Description |
|---|
GET | /api/admin/stats | Get platform-wide statistics |
GET | /api/admin/orders | Get all orders (filterable) |
Cron Endpoints
These should be called periodically by an external scheduler:
| Method | Endpoint | Frequency | Description |
|---|
POST | /api/requests/expire | Every few minutes | Expire active requests past 24 hours |
POST | /api/offers/expire-holds | Every few minutes | Clear expired 10-minute hold timers |
POST | /api/orders/start-work | Hourly | Move deposit_paid orders to in_progress 3 days before the desired date; notify buyer and seller |
POST | /api/orders/escrow-release | Every few minutes | Auto-release escrow after 3 days |