GET /api/v1/loterias/:id/preview_schedule
Previews the sorteos that would be generated based on a loteria’sdrawSchedule configuration without actually creating them in the database.
Use this endpoint to verify schedule changes before generating sorteos with Seed Sorteos.
Authentication
Requires authentication. Available to all roles.Path Parameters
UUID of the loteria to preview
Query Parameters
Start date/time for preview range.Format: ISO 8601 datetime or date stringExamples:
"2025-03-03T00:00:00-06:00"(specific datetime)"2025-03-03"(start of day in CR timezone)
Number of days to preview.Min: 1, Max: 31
Maximum number of sorteos to return.Min: 1, Max: 1000
Whether to include sorteos in the past.
true: Show all sorteos in date rangefalse: Only show future sorteos
Response
Indicates if the operation was successful
Array of preview sorteo objects
Preview metadata
Example Request (Today)
Example Request (Next Week)
Example Response
Error Responses
How Scheduling Works
The preview uses the loteria’srulesJson.drawSchedule to calculate occurrences:
Understanding alreadyExists
The
alreadyExists flag indicates whether a sorteo already exists in the database at that exact scheduledAt time.- Planning Seed
- Verify Schedule
- Find Missing
Before seeding sorteosCheck which sorteos need to be created:Result:
alreadyExists: false: Will be createdalreadyExists: true: Already exists, will be skipped
Date Range Examples
Schedule Configuration Examples
- Daily (All Days)
- Weekdays Only
- Weekend Only
Configuration:Preview Result (7 days):
- 2 draws per day
- 7 days × 2 = 14 sorteos
Timezone Handling
The preview:- Parses
startdate in Costa Rica timezone - Calculates date range using CR timezone
- Generates sorteos with CR times
- Returns ISO 8601 with timezone offset (
-06:00)
Use Cases
Before Seeding
Before Seeding
Preview before running Seed Sorteos to verify:
- Correct number of sorteos
- Correct times
- No unexpected duplicates
After Schedule Change
After Schedule Change
After updating
drawSchedule, preview to confirm:- New times are included
- Old times are removed (if applicable)
- Days of week filter working
Audit Coverage
Audit Coverage
Check sorteo coverage for a date range:
- Find gaps where sorteos are missing
- Verify all expected times exist
- Plan manual creation if needed
Capacity Planning
Capacity Planning
Estimate sorteo count for resource planning:
- Preview a month to estimate database growth
- Calculate expected ticket volume
- Plan server capacity
Related Endpoints
Seed Sorteos
Actually create the previewed sorteos
Get Loteria
View current schedule configuration
Update Loteria
Modify draw schedule
List Sorteos
See existing sorteos