POST /api/v1/loterias/:id/seed_sorteos
Generates sorteos (lottery draws) based on a loteria’sdrawSchedule configuration. Supports both automatic generation from schedule and manual creation of specific dates.
This endpoint is idempotent - running it multiple times with the same parameters will not create duplicate sorteos.
Authentication
Requires authentication. Typically ADMIN role.Path Parameters
UUID of the loteria to seed sorteos for
Query Parameters
Start date for sorteo generation.Format: ISO 8601 datetime or date stringExamples:
"2025-03-03T00:00:00-06:00""2025-03-03"
Number of days to generate sorteos for.Min: 1, Max: 31
Preview mode - calculate sorteos without creating them.
true: Return preview without creatingfalse: Actually create sorteos in database
Request Body
Optional: Specific dates to create sorteos for (overrides schedule calculation).Format: Array of ISO 8601 datetime stringsExample:
When provided, only these specific dates are processed. The
start and days parameters are ignored.Response
Indicates if the operation was successful
Result summary
Example Request (From Schedule)
Example Request (Specific Dates)
Example Request (Dry Run)
Example Response (Success)
Example Response (Dry Run)
Error Responses
Seeding Modes
- From Schedule
- Specific Dates
Automatic GenerationUses loteria’s Process:
drawSchedule to calculate sorteos:- Read
drawSchedulefromrulesJson - Calculate occurrences for date range
- Filter by
daysOfWeekif specified - Create sorteos for each occurrence
- Skip duplicates (idempotent)
Auto-Create Flag
- Auto-Create Enabled
- Auto-Create Disabled
autoCreateSorteos: true- Cron jobs can seed this loteria
- Manual seeding always works
- Default behavior
Idempotency
Safe to run multiple times - duplicate sorteos are automatically skipped based on unique constraint:
(loteriaId, scheduledAt).Dry Run Mode
Use
dryRun=true to preview what would be created without actually creating sorteos.- Verify schedule calculation
- Check sorteo names
- Estimate count
Inherited Configuration
Sorteos inherit configuration from the loteria at creation time.
digits: FromrulesJson.digitsreventadoEnabled: FromrulesJson.reventadoConfig.enabledloteriaId: Parent loteriaisActive: Defaults totrue
Common Use Cases
Daily Cron Job
Daily Cron Job
Automated daily seedingCron job runs daily to seed next 3 days:Ensures always have upcoming sorteos ready.
Weekly Batch
Weekly Batch
Weekly sorteo generationCreate entire week on Sunday:
Initial Setup
Initial Setup
First-time loteria setupAfter creating loteria, seed first month:
Special Draw
Special Draw
One-off special drawCreate specific sorteo outside schedule:
Backfill Missing
Backfill Missing
Fix gaps in coverageAfter schedule change, backfill missing dates:Existing sorteos skipped, only missing ones created.
Best Practices
Preview First
Use Preview Schedule to verify before seeding.
Related Endpoints
Preview Schedule
Preview before seeding
Get Loteria
View schedule configuration
List Sorteos
Verify created sorteos
Create Sorteo
Manually create individual sorteo