Booking Base URL

http://localhost:8000/api/booking

All routes below are prefixed with this base URL.

1️⃣ Create Booking

POST /create 🔒 (Protected - JWT Required)

Request Body

{ "category": [ { "categoryId": "paper", "name": "Paper", "estimatedWeight": 13, "subcategories": [ { "subCategoryId": "newspaper", "name": "Newspaper" }, { "subCategoryId": "cardboard", "name": "Cardboard" } ] } ], "scrapImages": [ { "imageUrl": "https://example.com/uploads/scrap1.jpg", "size": 204800, "type": "image/jpeg" }, { "imageUrl": "https://example.com/uploads/scrap2.jpg", "size": 305000, "type": "image/png" } ], "pickupLocation": { "doorNo": "12A", "flat": "3rd Floor", "area": "MG Road", "landmark": "Near Metro Station", "city": "Bangalore", "state": "Karnataka", "pincode": "560001", "coordinates": { "lat": 12.9716, "lng": 77.5946 } }, "estimatedPrice": 195 }

Success Response (201)

{ "success": true, "message": "Booking created successfully", "data": createdBooking }

Error Responses

400 → All Fields required - (category, scrapImages, pickupLocation, estimatedPrice)
400 → Only 3 active pickup bookings are allowed

2️⃣ Active Bookings

GET /active-booking 🔒 (Protected - JWT Required)

Description

Returns maximum 3 active bookings for the logged-in customer.

Headers

Authorization: Bearer <your_token>

Success Response (200)

{ "success": true, "bookings": [ { "_id": "bookingId1", "status": "requested", "estimatedPrice": 195, "pickupLocation": {...} } ] }

Empty Response

{ "success": true, "bookings": [], "message": "No active bookings found" }

Error

401 → Unauthorized (Invalid / Missing Token)

3️⃣ Booking History

GET /booking-history 🔒 (Protected - JWT Required)

Description

Returns all completed bookings of the customer.

Headers

Authorization: Bearer <your_token>

Success Response (200)

{ "success": true, "bookings": [ { "_id": "bookingId1", "status": "completed", "estimatedPrice": 220, "pickupLocation": {...} } ] }

Empty Response

{ "success": true, "bookings": [], "message": "No active bookings found" }

Error

401 → Unauthorized