Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/devdavco/backend_1/llms.txt

Use this file to discover all available pages before exploring further.

The POST /reserva/create endpoint persists a new booking in the reservas table and returns the fully-saved Reserva object with its assigned id. The request body must include the IDs of both the user and the space being booked, three timestamps defining the session window and the post-cleaning end time, and an initial estado. Both foreign-key IDs are validated against the database before the record is saved — if either does not exist, the request is rejected with a 500 error.

Request body

espacioId
integer
required
ID of the coworking space to book. Must be a positive integer that references an existing Espacio record. Values of 0 or below are rejected.
usuarioId
integer
required
ID of the user making the booking. Must be a positive integer that references an existing Usuario record. Values of 0 or below are rejected.
horaInicio
string
required
Start time of the reservation. Must be formatted as yyyy-MM-dd HH:mm (e.g. "2025-06-10 09:00"). Seconds and timezone offsets are not accepted.
horaFinUsuario
string
required
The time at which the user’s session ends. Must be formatted as yyyy-MM-dd HH:mm. This should be later than horaInicio and earlier than horaFinTotal.
horaFinTotal
string
required
The absolute end of the reserved slot, including the space’s post-session cleaning buffer. Must be formatted as yyyy-MM-dd HH:mm. Calculate this as horaFinUsuario plus the value of espacio.minutos_limpieza for the chosen space.
estado
string
required
Initial lifecycle status. Must be one of confirmada, pendiente, or cancelada.
version
integer
Optional initial version value for optimistic locking. Defaults to null when omitted. JPA’s @Version mechanism will manage this field automatically after creation; most callers should leave it unset.

Validation rules

The service layer (ReservaServiceImpl) enforces the following before persisting:
  • The request object itself must not be null.
  • usuarioId must be non-null and greater than 0. A matching Usuario record must exist in the database.
  • espacioId must be non-null and greater than 0. A matching Espacio record must exist in the database.
If any of these checks fail the endpoint returns an HTTP 500 error with a descriptive message.

Request

curl -X POST http://localhost:8080/reserva/create \
  -H "Content-Type: application/json" \
  -d '{
    "espacioId": 2,
    "usuarioId": 3,
    "horaInicio": "2025-06-10 09:00",
    "horaFinUsuario": "2025-06-10 11:00",
    "horaFinTotal": "2025-06-10 11:30",
    "estado": "pendiente"
  }'
All three timestamp fields (horaInicio, horaFinUsuario, horaFinTotal) are parsed with the strict @JsonFormat(pattern = "yyyy-MM-dd HH:mm") annotation. Any other format — including ISO 8601 strings with seconds (2025-06-10T09:00:00), timezone offsets, or date-only strings — will cause Jackson to fail to deserialise the request body and return an error.

Response

Returns 201 Created with the full persisted Reserva object.
{
  "id": 12,
  "usuarioId": 3,
  "espacioId": 2,
  "horaInicio": "2025-06-10 09:00",
  "horaFinUsuario": "2025-06-10 11:00",
  "horaFinTotal": "2025-06-10 11:30",
  "estado": "pendiente",
  "version": 0
}

Response fields

id
integer
Auto-generated primary key assigned by the database on insert.
usuarioId
integer
ID of the user who owns the booking, as supplied in the request.
espacioId
integer
ID of the coworking space, as supplied in the request.
horaInicio
string
Persisted start time in yyyy-MM-dd HH:mm format.
horaFinUsuario
string
Persisted user session end time in yyyy-MM-dd HH:mm format.
horaFinTotal
string
Persisted absolute end time (including cleaning buffer) in yyyy-MM-dd HH:mm format.
estado
string
The initial status value that was saved. One of confirmada, pendiente, or cancelada.
version
integer
Initial optimistic-locking version. Will be 0 when version was omitted from the request body, or the supplied value if one was provided.

Build docs developers (and LLMs) love