Base: https://api.sajilosport.com/api

Bookings

Base path: /api/bookings

All booking endpoints require authentication.


Booking Statuses

StatusDescription
pendingCreated but not yet paid
confirmedPayment received
playingSession in progress (set by staff)
completedSession finished
cancelledCancelled by customer or staff
no_showCustomer did not show up

Booking Types

TypeDescription
onlineBooked through the mobile app
offlineBooked in person by staff
walkinWalk-in session registered by staff

Endpoints

GET /api/bookings [Auth required]

List all bookings for the authenticated user.

Response 200:

{
  "data": [
    {
      "id": 42,
      "booking_number": "BK-2025-0042",
      "type": "online",
      "status": "confirmed",
      "date": "2025-06-15",
      "start_time": "08:00",
      "end_time": "09:00",
      "duration_hours": "1.00",
      "base_amount": "800.00",
      "discount_amount": "100.00",
      "total_amount": "700.00",
      "paid_amount": "700.00",
      "balance_due": "0.00",
      "is_paid": true,
      "extras_total": null,
      "customer_name": "Jane Doe",
      "customer_phone": "9800000000",
      "notes": null,
      "cancel_reason": null,
      "cancelled_at": null,
      "court_id": 1,
      "court": { "id": 1, "name": "Court A", ... },
      "user": { ... },
      "payments": [],
      "charges": [],
      "coupon_usage": null,
      "review": null,
      "created_at": "2025-06-10 09:00:00"
    }
  ]
}

POST /api/bookings [Auth required]

Create a new online booking.

Request body:

{
  "court_id": 1,
  "date": "2025-06-15",
  "start_time": "08:00",
  "end_time": "09:00",
  "coupon_code": "SUMMER20",
  "notes": "Extra balls needed",
  "payment_method": "esewa"
}
FieldTypeRequiredDescription
court_idintegerYesID of the court to book
datedateYesYYYY-MM-DD, must be today or future
start_timetimeYesHH:mm (24-hour)
end_timetimeYesHH:mm, must be after start_time
coupon_codestringNoDiscount coupon code
notesstringNoOptional note for staff
payment_methodstringNoesewa, khalti, fonepay, wallet, cash

Response 201:

{
  "data": { ...BookingResource... }
}

Response 409 — slot taken:

{ "message": "The court is not available for the selected time slot." }

GET /api/bookings/{booking} [Auth required]

Get details of a specific booking. Only the booking owner can access it.

Response 200:

{
  "data": { ...BookingResource with court, user, payments, charges... }
}

PATCH /api/bookings/{booking}/cancel [Auth required]

Cancel a booking.

Request body:

{
  "reason": "Change of plans"
}
FieldTypeRequiredDescription
reasonstringNoCancellation reason

Response 200:

{
  "data": { ...BookingResource with status: "cancelled"... }
}

Response 403 — cannot cancel (wrong ownership or booking already completed):

{ "message": "This action is unauthorized." }

BookingResource — Field Reference

FieldTypeNotes
idinteger
booking_numberstringHuman-readable reference e.g. BK-2025-0042
typestringonline, offline, walkin
statusstringSee statuses table above
datedate stringYYYY-MM-DD
start_timestringHH:mm
end_timestringHH:mm
duration_hoursdecimal stringe.g. "1.50"
base_amountdecimal stringPrice before discount
discount_amountdecimal stringDiscount applied
total_amountdecimal stringAmount due
paid_amountdecimal stringAmount already paid
balance_duedecimal stringRemaining amount owed
is_paidbooleantrue when fully paid
extras_totaldecimal or nullSum of session charges (drinks, equipment, etc.)
customer_namestring
customer_phonestring or null
notesstring or null
cancel_reasonstring or null
cancelled_atdatetime or null
court_idinteger
courtobjectLoaded on show
userobjectLoaded on show
paymentsarrayPayment history
chargesarrayExtra session charges
coupon_usageobject or nullCoupon that was applied
reviewobject or nullReview left for this booking
created_atdatetime string

End-to-End Booking Flow

1. GET  /api/venues/nearby?lat=...&lng=...      → pick venue
2. GET  /api/courts/{court}/availability?date=... → pick slot
3. POST /api/coupons/validate                   → (optional) apply coupon
4. POST /api/bookings                           → create booking
5. POST /api/payments/initiate                  → initiate payment
6. (user pays via gateway)
7. POST /api/payments/{gateway}/callback        → gateway posts back
8. GET  /api/bookings/{id}                      → show confirmation