Skip to main content
GET
/
api
/
admin
/
debug-reservations
Debug Reservations
curl --request GET \
  --url https://api.example.com/api/admin/debug-reservations
{
  "count": 123,
  "today": "<string>",
  "reservations": [
    {
      "id": "<string>",
      "reservation_date": "<string>",
      "status": "<string>",
      "locations": {
        "name": "<string>"
      },
      "customers": {
        "first_name": "<string>",
        "last_name": "<string>"
      }
    }
  ]
}

Debug Reservations

Retrieve today’s reservations with customer and location details for debugging operations.

Endpoint

GET /api/admin/debug-reservations

Authentication

Requires canAccessOperaciones permission.
await requirePermission("canAccessOperaciones");

Response

count
number
Number of reservations found for today
today
string
Today’s date in ISO format (YYYY-MM-DD)
reservations
array
Array of reservation objects with expanded relations

Example Request

curl -X GET https://your-domain.com/api/admin/debug-reservations \
  -H "Cookie: your-session-cookie"

Example Response

{
  "count": 3,
  "today": "2026-03-04",
  "reservations": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "reservation_date": "2026-03-04T19:30:00Z",
      "status": "confirmed",
      "pax": 4,
      "locations": {
        "name": "La Tasca Madrid · Centro"
      },
      "customers": {
        "first_name": "María",
        "last_name": "García"
      }
    }
  ]
}

Error Response

{
  "error": "Database error message",
  "status": 500
}

Implementation Details

The endpoint:
  1. Validates user has canAccessOperaciones permission
  2. Uses service role key to bypass RLS
  3. Filters reservations for today (00:00:00 to 23:59:59)
  4. Expands locations and customers relations
  5. Limits results to 10 reservations

Source Code Reference

app/api/admin/debug-reservations/route.ts
import { createClient } from '@supabase/supabase-js';
import { requirePermission } from "@/lib/authz";

export async function GET() {
    await requirePermission("canAccessOperaciones");

    const supabase = createClient(
        process.env.NEXT_PUBLIC_SUPABASE_URL!,
        process.env.SUPABASE_SERVICE_ROLE_KEY!
    );

    const today = new Date().toISOString().split('T')[0];

    const { data: reservations, error } = await supabase
        .from('reservations')
        .select('*, locations(name), customers(first_name, last_name)')
        .gte('reservation_date', `${today}T00:00:00`)
        .lte('reservation_date', `${today}T23:59:59`)
        .limit(10);

    if (error) {
        return Response.json({ error: error.message }, { status: 500 });
    }

    return Response.json({
        count: reservations?.length || 0,
        today,
        reservations
    });
}

Use Cases

  • Monitor today’s reservation activity
  • Debug reservation sync issues
  • Verify customer data integrity
  • Test location relationships

Build docs developers (and LLMs) love