Overview
Creates a new parking reservation from the public website. This endpoint handles customer registration, vehicle registration, and reservation creation in a single atomic transaction.
This endpoint is public and does not require authentication.
Authentication
No authentication required.
Request Body
Full name of the customer making the reservation.
Customer’s phone number. Used as the unique identifier for the customer.If a customer with this phone number already exists, the existing customer record will be used.
Customer’s email address (optional).
Vehicle license plate number. Used as the unique identifier for the vehicle.If a vehicle with this license plate already exists, the existing vehicle record will be used.
brand
string
default:"Desconocida"
Vehicle brand/manufacturer.
model
string
default:"Desconocido"
Vehicle model.
Type of vehicle (e.g., COCHE, MOTO, FURGONETA, SUV).
Reservation entry date in ISO 8601 format (e.g., 2026-03-10T10:00:00.000Z).
Reservation exit date in ISO 8601 format (e.g., 2026-03-15T10:00:00.000Z).
ID of the main parking service selected.
Array of additional service IDs (integers) to include in the reservation.Example: [1, 3, 5]
Response
Indicates whether the reservation was created successfully.
Success or error message.
Reservation summary object (only present on success).Unique ID of the newly created reservation.
Final calculated price for the reservation.
Transaction Behavior
This endpoint performs multiple database operations in a single atomic transaction:
-
Customer Management:
- If customer with the phone number exists → use existing customer
- If customer doesn’t exist → create new customer with type
NO-REGISTRADO
-
Vehicle Management:
- If vehicle with the license plate exists → use existing vehicle
- If vehicle doesn’t exist → create new vehicle with provided details
-
Customer-Vehicle Link:
- Link the customer and vehicle (if not already linked)
-
Reservation Creation:
- Create reservation with status
PENDIENTE
- Price is recalculated server-side to prevent manipulation
-
Additional Services:
- Link selected additional services to the reservation
If any step fails, the entire transaction is rolled back and no data is saved.
Error Codes
| Status Code | Description |
|---|
| 201 | Success - Reservation created |
| 400 | Bad Request - Missing required fields (entry_date, phone, or license_plate) |
| 500 | Internal Server Error - Database transaction failed |
Examples
Complete Request
curl -X POST https://paparcapp-azby.onrender.com/api/reservations/public-new \
-H "Content-Type: application/json" \
-d '{
"full_name": "Juan Pérez",
"phone": "+34612345678",
"email": "[email protected]",
"license_plate": "1234ABC",
"brand": "Toyota",
"model": "Corolla",
"vehicle_type": "TURISMO",
"entry_date": "2026-03-10T10:00:00.000Z",
"exit_date": "2026-03-15T10:00:00.000Z",
"id_main_service": 1,
"additional_services": [2, 4]
}'
Minimal Request
curl -X POST https://paparcapp-azby.onrender.com/api/reservations/public-new \
-H "Content-Type: application/json" \
-d '{
"full_name": "Juan Pérez",
"phone": "+34612345678",
"license_plate": "1234ABC",
"vehicle_type": "TURISMO",
"entry_date": "2026-03-10T10:00:00.000Z",
"exit_date": "2026-03-15T10:00:00.000Z",
"id_main_service": 1
}'
Success Response
{
"success": true,
"message": "Reserva creada con éxito",
"data": {
"id_reservation": 42,
"customer_name": "Juan Pérez",
"phone": "+34612345678",
"license_plate": "1234ABC",
"brand": "Toyota",
"model": "Corolla",
"total_price": 145.75
}
}
Error Response - Missing Required Fields
{
"success": false,
"message": "Faltan datos obligatorios."
}
Error Response - Database Error
{
"success": false,
"message": "Error interno del servidor al procesar tu reserva."
}
Notes
- Price Verification: The total price is always recalculated server-side using the provided parameters to prevent client-side manipulation.
- Customer Type: All customers created through this endpoint are tagged as
NO-REGISTRADO to distinguish them from registered app users.
- Default Values: If
brand, model, or email are not provided, default values are used (Desconocida, Desconocido, null respectively).
- Vehicle Color: Always set to
No color for public reservations.
- Initial Status: New reservations always start with status
PENDIENTE (pending).
- Idempotency: While this endpoint is not strictly idempotent, creating multiple reservations with the same customer/vehicle data will reuse existing customer and vehicle records.