PATCH /api/v1/sorteos/:id/evaluate
Evaluates a sorteo by setting the winning number and automatically determining winning tickets. This operation processes all active tickets and calculates payouts.Authentication
Requires ADMIN role.Path Parameters
UUID of the sorteo to evaluate
Request Body
The winning number for this sorteo.
- Must be numeric (1-3 digits)
- Length must match the sorteo’s
digitsconfiguration - For 2-digit sorteos: “00” to “99”
- For 3-digit sorteos: “000” to “999”
"42", "07", "123"UUID of the REVENTADO multiplier that applies to this draw.Only required if a REVENTADO outcome occurred. Must be:
- A valid LoteriaMultiplier UUID
- Type:
REVENTADO - Belonging to the same loteria
- Active
"a1b2c3d4-e5f6-4a5b-9c8d-1e2f3a4b5c6d"Optional label for the extra multiplier outcome.Typically the multiplier’s name. Used for display and reporting.Examples:
"REVENTADO x5", "Triple Pago"Max: 50 charactersResponse
Indicates if the operation was successful
The evaluated sorteo object with winner information
Example Request (Simple)
Example Request (With REVENTADO)
Example Response
Error Responses
Evaluation Process
The evaluation runs in a single database transaction with the following steps:Update Sorteo
Set
status: EVALUATED, store winningNumber, extraMultiplierId, extraMultiplierX, and extraOutcomeCode.Mark REVENTADO Winners (if applicable)
If
extraMultiplierId provided, find all REVENTADO bets matching the winning number.Mark All Tickets as Evaluated
Set all active tickets to
status: EVALUATED and isWinner: false (base state).Calculate Ticket Payouts
For tickets with winning jugadas, calculate total payout and set
isWinner: true.REVENTADO Evaluation
REVENTADO is an extra multiplier feature that applies additional payouts to specific number bets.
- No REVENTADO
- With REVENTADO
Standard EvaluationOnly NUMERO bets are evaluated:Result:
- NUMERO bets on “42” win with normal multiplier
- REVENTADO bets on “42” do not win
Example Scenario
Ticket with both bet types:- NUMERO bet wins: 1000 × 75 = ₡75,000
- REVENTADO bet wins: 500 × 5 = ₡2,500
- Total payout: ₡77,500
Excluding Tickets from Evaluation
Tickets can be excluded from evaluation using the Sorteo Listas Exclusion system.
- Are not evaluated for winners
- Remain in their current state
- Are not counted in winner statistics
- Dispute resolution
- Manual corrections
- Testing
Account Statement Sync
What gets updated:totalPayouts: Sum of winning ticket payouts for the dayaccumulatedBalance: Running balance including new payouts
- Evaluation still succeeds (transaction commits)
- A
syncWarningis included in the response - Manual sync can be triggered via account statement sync endpoint
Validation Rules
Winning Number Validation
Winning Number Validation
- Must be numeric string
- Must match sorteo’s
digitslength - For 2 digits: “00” to “99” (with leading zeros)
- For 3 digits: “000” to “999” (with leading zeros)
Extra Multiplier Validation
Extra Multiplier Validation
If
extraMultiplierId is provided:- Must be a valid UUID
- Must exist in database
- Must be active (
isActive: true) - Must belong to the same loteria
- Must be of kind
REVENTADO - If
appliesToSorteoIdis set, must match this sorteo
State Validation
State Validation
- Sorteo must be in
OPENstatus - Cannot evaluate
SCHEDULED,EVALUATED, orCLOSEDsorteos - Use Revert Evaluation to re-evaluate
Performance Considerations
Evaluation uses raw SQL queries for performance when processing large numbers of tickets and jugadas.
- Bulk updates via raw SQL (no ORM overhead)
- Single transaction (ACID compliance)
- 3-minute timeout for sorteos with many tickets
- Indexed queries on sorteo, ticket, and jugada tables
Activity Logging
Evaluation creates detailed activity logs:Related Endpoints
Close Sorteo
Close after evaluation
Get Sorteo
View evaluation results
Pay Ticket
Pay winning tickets
Multipliers
Understand multiplier system