Booking Base URL

http://localhost:8000/api/booking

All routes below are prefixed with this base URL.

Create Booking

POST /create (Protected - Customer JWT Required)

Description

Create a new scrap pickup booking. Maximum 3 active bookings allowed per customer.

Headers

Authorization: Bearer <customer_token> Content-Type: application/json

Request Body

{ "category": [ { "categoryId": "paper", "name": "Paper", "estimatedWeight": 13, "subcategories": [ { "subCategoryId": "newspaper", "name": "Newspaper" } ] } ], "scrapImages": [ { "imageUrl": "/upload/file/file1.jpg", "size": 204800, "type": "image/jpeg" } ], "pickupLocation": { "doorNo": "12A", "flat": "3rd Floor", "area": "MG Road", "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": { "_id": "bookingId", "status": "requested", "type": "online", "estimatedPrice": 195, "createdAt": "timestamp" } }

Error Responses

400 At least one category is required 400 Valid pickup location is required 400 Estimated price must be a number 400 Only 3 active pickup bookings are allowed 401 Unauthorized

Customer Active Bookings

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

Description

Returns current active bookings (max 3).

Headers

Authorization: Bearer <customer_token>

Success Response

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

Empty Response

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

Customer Booking History

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

Description

Returns completed bookings of the customer.

Headers

Authorization: Bearer <customer_token>

Success Response

{ "success": true, "bookings": [ { "_id": "bookingId", "status": "completed", "estimatedPrice": 220, "createdAt": "timestamp" } ] }

Vendor Active Bookings

GET /vendor-active-booking (Protected - Vendor JWT Required)

Description

Returns active bookings assigned to vendor.

Headers

Authorization: Bearer <vendor_token>

Success Response

{ "success": true, "bookings": [ { "_id": "bookingId", "status": "requested", "estimatedPrice": 195 } ] }

Vendor Booking History

GET /vendor-booking-history (Protected - Vendor JWT Required)

Description

Returns all bookings handled by vendor.

Headers

Authorization: Bearer <vendor_token>

Success Response

{ "success": true, "bookings": [ { "_id": "bookingId", "status": "completed", "estimatedPrice": 220 } ] }

Notes