POST
/reservations
Auth Required
Create Reservation
Create a new booking reservation.
Request/Response Examples
Create a new booking.
JSON
{
"reservation_no": "RES-2025-0001",
"guest_id": 123,
"check_in_date": "2025-02-01",
"check_out_date": "2025-02-05",
"number_of_adults": 2,
"room_type_id": 2,
"rate_per_night": 12000
}
Reservation created.
JSON
{
"status": "success",
"data": {
"id": 456,
"reservation_no": "RES-2025-0001",
"total_amount": 48000,
"status": "confirmed"
},
"code": 201
}
Code Examples
PHP - Create Reservation
PHP example for creating a reservation
<?php
$api_url = "https://hotel.webninjaafrica.com/api";
$token = "YOUR_JWT_TOKEN_HERE";
$reservation_data = array(
"reservation_no" => "RES-" . date("Ymd") . "-" . rand(1000, 9999),
"guest_id" => 123,
"booking_source" => "direct",
"check_in_date" => date("Y-m-d", strtotime("+7 days")),
"check_out_date" => date("Y-m-d", strtotime("+10 days")),
"number_of_adults" => 2,
"room_type_id" => 2,
"rate_per_night" => 12000
);
$ch = curl_init($api_url . "/reservations");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($reservation_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer " . $token,
"Content-Type: application/json"
));
$response = curl_exec($ch);
$result = json_decode($response, true);
curl_close($ch);
if ($result["status"] === "success") {
echo "Reservation created with ID: " . $result["data"]["id"];
}
?>
Python - Create Reservation
Python example for creating a reservation
import requests
import random
from datetime import datetime, timedelta
token = "YOUR_JWT_TOKEN_HERE"
url = "https://hotel.webninjaafrica.com/api/reservations"
reservation_data = {
"reservation_no": "RES-" + datetime.now().strftime("%Y%m%d") + "-" + str(random.randint(1000,9999)),
"guest_id": 123,
"booking_source": "direct",
"check_in_date": (datetime.now() + timedelta(days=7)).strftime("%Y-%m-%d"),
"check_out_date": (datetime.now() + timedelta(days=10)).strftime("%Y-%m-%d"),
"number_of_adults": 2,
"room_type_id": 2,
"rate_per_night": 12000
}
headers = {
"Authorization": "Bearer " + token,
"Content-Type": "application/json"
}
response = requests.post(url, json=reservation_data, headers=headers)
data = response.json()
if data["status"] == "success":
print("Reservation created with ID: " + str(data["data"]["id"]))
else:
print("Error: " + data["message"])
cURL - Create Reservation
cURL example for creating a reservation
curl -X POST https://hotel.webninjaafrica.com/api/reservations \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"reservation_no": "RES-2025-0001",
"guest_id": 123,
"check_in_date": "2025-02-01",
"check_out_date": "2025-02-05",
"number_of_adults": 2,
"room_type_id": 2,
"rate_per_night": 12000
}'