Overview
The Reservation Management API provides endpoints for creating, reading, updating, and deleting reservations. Reservations link users (clients) to housing listings with specific check-in and check-out dates.All endpoints require JWT authentication via the
Authorization: Bearer {token} header.Get All Reservations
Retrieve a list of all reservations in the system.Response
Array of ReservationDTO objects
Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 200 | Successfully retrieved list of reservations |
| 403 | Forbidden - Access denied |
Get Reservation by ID
Retrieve a specific reservation by its ID.ID of the reservation to retrieve (e.g., 1)
Response
Returns a single ReservationDTO object with all reservation details.Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 200 | Successfully retrieved reservation |
| 404 | Reservation not found |
| 403 | Forbidden - Access denied |
Create Reservation
Create a new reservation with the provided details.Request Body
Check-in date and time in ISO 8601 format (e.g., “2024-08-10T15:00:00” or “2024-08-10”)
Check-out date and time in ISO 8601 format (e.g., “2024-08-15T11:00:00” or “2024-08-15”)
Whether the reservation has been rated (default: false for new reservations)
DNI of the client making the reservation (must be an existing user)
Code/ID of the housing to reserve (must be an existing housing listing)
Name of the housing (should match the housingCode)
Response
Returns the created reservation with an auto-generated ID.Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 201 | Reservation created successfully |
| 400 | Invalid input (e.g., invalid dates, non-existent client or housing) |
| 403 | Forbidden - Access denied |
Update Reservation
Update an existing reservation.ID of the reservation to update (e.g., 1)
Request Body
All ReservationDTO fields can be updated (see Create Reservation for field descriptions).Response
Returns the updated reservation.Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 200 | Reservation updated successfully |
| 404 | Reservation not found |
| 400 | Invalid input |
| 403 | Forbidden - Access denied |
Delete Reservation
Delete a reservation by its ID.ID of the reservation to delete (e.g., 1)
Response
No content is returned on successful deletion.Status Codes
| Code | Description |
|---|---|
| 204 | Reservation deleted successfully |
| 404 | Reservation not found |
| 403 | Forbidden - Access denied |
Admin Reservation Management
Administrators have additional endpoints for managing reservations:Accept Reservation
Requires ADMIN role. Marks a reservation as accepted by setting the
valorated field to true.200- Reservation accepted successfully404- Reservation not found403- Forbidden (requires ADMIN role)401- Unauthorized (invalid JWT)
Deny Reservation
Requires ADMIN role. Denies and deletes a reservation from the system.
204- Reservation denied and removed successfully404- Reservation not found403- Forbidden (requires ADMIN role)401- Unauthorized (invalid JWT)
Date Handling
The API uses SQL Date format internally but accepts ISO 8601 datetime strings. Dates can be provided in the following formats:YYYY-MM-DD(e.g., “2024-08-10”)YYYY-MM-DDTHH:mm:ss(e.g., “2024-08-10T15:00:00”)
Authentication
All Reservation Management endpoints require JWT authentication:ROLE_ADMIN role.
Error Responses
Error type
Detailed error message
Example Error Response
Example Error Response
