Skip to main content
POST
/
api
/
reservations
/
public-new
Create Public Reservation
curl --request POST \
  --url https://api.example.com/api/reservations/public-new \
  --header 'Content-Type: application/json' \
  --data '
{
  "full_name": "<string>",
  "phone": "<string>",
  "email": "<string>",
  "license_plate": "<string>",
  "brand": "<string>",
  "model": "<string>",
  "vehicle_type": "<string>",
  "entry_date": "<string>",
  "exit_date": "<string>",
  "id_main_service": 123,
  "additional_services": [
    {}
  ]
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "data.id_reservation": 123,
    "data.customer_name": "<string>",
    "data.phone": "<string>",
    "data.license_plate": "<string>",
    "data.brand": "<string>",
    "data.model": "<string>",
    "data.total_price": 123
  }
}

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

Customer Information

full_name
string
required
Full name of the customer making the reservation.
phone
string
required
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.
email
string
Customer’s email address (optional).

Vehicle Information

license_plate
string
required
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.
vehicle_type
string
required
Type of vehicle (e.g., COCHE, MOTO, FURGONETA, SUV).

Reservation Information

entry_date
string
required
Reservation entry date in ISO 8601 format (e.g., 2026-03-10T10:00:00.000Z).
exit_date
string
required
Reservation exit date in ISO 8601 format (e.g., 2026-03-15T10:00:00.000Z).
id_main_service
integer
required
ID of the main parking service selected.
additional_services
array
default:"[]"
Array of additional service IDs (integers) to include in the reservation.Example: [1, 3, 5]

Response

success
boolean
Indicates whether the reservation was created successfully.
message
string
Success or error message.
data
object
Reservation summary object (only present on success).
data.id_reservation
integer
Unique ID of the newly created reservation.
data.customer_name
string
Customer’s full name.
data.phone
string
Customer’s phone number.
data.license_plate
string
Vehicle license plate.
data.brand
string
Vehicle brand.
data.model
string
Vehicle model.
data.total_price
number
Final calculated price for the reservation.

Transaction Behavior

This endpoint performs multiple database operations in a single atomic transaction:
  1. Customer Management:
    • If customer with the phone number exists → use existing customer
    • If customer doesn’t exist → create new customer with type NO-REGISTRADO
  2. Vehicle Management:
    • If vehicle with the license plate exists → use existing vehicle
    • If vehicle doesn’t exist → create new vehicle with provided details
  3. Customer-Vehicle Link:
    • Link the customer and vehicle (if not already linked)
  4. Reservation Creation:
    • Create reservation with status PENDIENTE
    • Price is recalculated server-side to prevent manipulation
  5. 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 CodeDescription
201Success - Reservation created
400Bad Request - Missing required fields (entry_date, phone, or license_plate)
500Internal 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.

Build docs developers (and LLMs) love