Skip to main content
GET
/
api
/
reservations
Get Reservations by Date
curl --request GET \
  --url https://api.example.com/api/reservations \
  --header 'Authorization: <authorization>'
{
  "date": "<string>",
  "stats": {
    "stats.total_entries": 123,
    "stats.total_exits": 123
  },
  "entries": [
    {
      "entries[].id_reservation": 123,
      "entries[].entry_date": "<string>",
      "entries[].exit_date": "<string>",
      "entries[].status": "<string>",
      "entries[].license_plate": "<string>",
      "entries[].brand": "<string>",
      "entries[].color": "<string>",
      "entries[].customer_name": "<string>",
      "entries[].phone": "<string>",
      "entries[].service_name": "<string>"
    }
  ],
  "exits": [
    {}
  ]
}

Overview

Retrieves all reservations for a specific date, separated into entries and exits. This endpoint is used by administrators to view daily parking operations. This endpoint requires admin authentication.

Authentication

Authorization
string
required
Admin authentication token. Must be a valid session token with admin privileges.The isAdmin middleware validates the user’s admin status before allowing access.

Query Parameters

date
string
default:"today"
Date to filter reservations in ISO 8601 date format (e.g., 2026-03-10).If not provided, defaults to the current date.

Response

date
string
The date used for filtering reservations (ISO 8601 format).
stats
object
Summary statistics for the requested date.
stats.total_entries
integer
Total number of reservations with entry date matching the requested date.
stats.total_exits
integer
Total number of reservations with exit date matching the requested date.
entries
array
Array of reservation objects where the entry date matches the requested date.Each reservation object contains:
entries[].id_reservation
integer
Unique reservation ID.
entries[].entry_date
string
Entry date and time (ISO 8601 format).
entries[].exit_date
string
Exit date and time (ISO 8601 format, may be null).
entries[].status
string
Reservation status (e.g., PENDIENTE, EN CURSO, FINALIZADA, CANCELADA).
entries[].license_plate
string
Vehicle license plate number.
entries[].brand
string
Vehicle brand.
entries[].color
string
Vehicle color.
entries[].customer_name
string
Customer’s full name.
entries[].phone
string
Customer’s phone number.
entries[].service_name
string
Name of the main service.
exits
array
Array of reservation objects where the exit date matches the requested date.Structure is identical to the entries array.

Date Matching Logic

The endpoint performs the following logic:
  1. Queries all reservations where either:
    • entry_date matches the requested date (date component only)
    • OR exit_date matches the requested date (date component only)
  2. Separates results into two arrays:
    • Entries: Reservations where entry date matches
    • Exits: Reservations where exit date matches
  3. A single reservation can appear in both arrays if both entry and exit dates match the requested date (same-day reservations).

Error Codes

Status CodeDescription
200Success - Returns reservations data
401Unauthorized - Missing or invalid authentication token
403Forbidden - User is not an admin
500Internal Server Error - Database query failed

Examples

Request with Specific Date

curl -X GET "https://paparcapp-azby.onrender.com/api/reservations?date=2026-03-10" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Request without Date (defaults to today)

curl -X GET "https://paparcapp-azby.onrender.com/api/reservations" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Success Response

{
  "date": "2026-03-10",
  "stats": {
    "total_entries": 5,
    "total_exits": 3
  },
  "entries": [
    {
      "id_reservation": 101,
      "entry_date": "2026-03-10T10:00:00.000Z",
      "exit_date": "2026-03-15T10:00:00.000Z",
      "status": "PENDIENTE",
      "license_plate": "1234ABC",
      "brand": "Toyota",
      "color": "Rojo",
      "customer_name": "Juan Pérez",
      "phone": "+34612345678",
      "service_name": "Parking Cubierto"
    },
    {
      "id_reservation": 102,
      "entry_date": "2026-03-10T14:30:00.000Z",
      "exit_date": "2026-03-12T09:00:00.000Z",
      "status": "EN CURSO",
      "license_plate": "5678DEF",
      "brand": "Honda",
      "color": "Azul",
      "customer_name": "María García",
      "phone": "+34623456789",
      "service_name": "Parking Descubierto"
    }
  ],
  "exits": [
    {
      "id_reservation": 95,
      "entry_date": "2026-03-05T08:00:00.000Z",
      "exit_date": "2026-03-10T11:00:00.000Z",
      "status": "FINALIZADA",
      "license_plate": "9012GHI",
      "brand": "Ford",
      "color": "Negro",
      "customer_name": "Carlos López",
      "phone": "+34634567890",
      "service_name": "Parking Premium"
    }
  ]
}

Error Response - Unauthorized

{
  "error": "Unauthorized"
}

Error Response - Forbidden (Not Admin)

{
  "error": "Forbidden - Admin access required"
}

Error Response - Server Error

{
  "error": "Error en el servidor, por favor intente más tarde."
}

Use Cases

  • Daily Operations Dashboard: View all vehicles entering or exiting on a specific day
  • Reception Management: Check expected arrivals for the current day
  • Departure Planning: Review scheduled departures to prepare vehicles
  • Historical Analysis: Query past dates to analyze parking patterns

Notes

  • Date Format: Dates are compared using only the date component (year-month-day), ignoring time.
  • Null Exit Dates: Some reservations may have null exit dates if the customer hasn’t specified when they’ll leave. These won’t appear in the exits array.
  • Timezone Handling: The server uses en-CA locale for date formatting, which uses ISO 8601 format (YYYY-MM-DD).
  • Same-Day Reservations: If a reservation has both entry and exit on the requested date, it will appear in both the entries and exits arrays.
  • Ordering: Results are ordered by entry date in ascending order.

Build docs developers (and LLMs) love