Skip to main content

PUT/PATCH /api/v1/sorteos/:id

Updates an existing sorteo (lottery draw). Changes are only allowed for sorteos in SCHEDULED or OPEN status.
Sorteos in EVALUATED or CLOSED status cannot be updated. Use Revert Evaluation to reopen an evaluated sorteo.

Authentication

Requires ADMIN role.

Path Parameters

id
string
required
UUID of the sorteo to update

Request Body

All fields are optional. Only provided fields will be updated.
loteriaId
string
Change the associated loteria.
Can only change loteria when status is SCHEDULED. The new loteria must be active.
scheduledAt
string
Update the scheduled time.ISO 8601 datetime in Costa Rica timezone (GMT-6).Example: "2025-03-03T14:55:00-06:00"
name
string
Update the display name.Min: 1 character, Max: 100 characters
digits
integer
Update the number of digits (2 or 3).
Changing digits affects which winning numbers are valid during evaluation.
isActive
boolean
Activate or deactivate the sorteo.Inactive sorteos are hidden from vendedores and don’t accept ticket sales.

Response

success
boolean
Indicates if the operation was successful
data
object
The updated sorteo object (see Get Sorteo for full structure)

Example Request

curl -X PATCH https://api.example.com/api/v1/sorteos/7c9e6679-7425-40de-944b-e07fc1f90ae7 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Lotto 2:55 PM",
    "scheduledAt": "2025-03-03T14:55:00-06:00",
    "isActive": true
  }'

Example Response

{
  "success": true,
  "data": {
    "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "loteriaId": "550e8400-e29b-41d4-a716-446655440000",
    "scheduledAt": "2025-03-03T14:55:00-06:00",
    "name": "Lotto 2:55 PM",
    "status": "SCHEDULED",
    "digits": 2,
    "isActive": true,
    "reventadoEnabled": true,
    "winningNumber": null,
    "hasWinner": false,
    "createdAt": "2025-03-03T10:00:00-06:00",
    "updatedAt": "2025-03-03T12:30:00-06:00"
  }
}

Error Responses

{
  "success": false,
  "error": "No se puede editar un sorteo evaluado o cerrado"
}

Update Restrictions by Status

Full Update AccessAll fields can be updated:
  • loteriaId
  • scheduledAt
  • name
  • digits
  • isActive

Changing Loteria

Changing the loteriaId is only allowed when the sorteo is in SCHEDULED status and has no tickets sold.
Requirements:
  • Current status must be SCHEDULED
  • New loteria must exist and be active
  • New loteria configuration will be inherited
Example:
{
  "loteriaId": "new-loteria-uuid"
}

Changing Scheduled Time

Be cautious when changing scheduledAt for sorteos that already have tickets sold. Consider communication to vendedores and players.
Best practices:
  1. Before Opening: Safe to change anytime
  2. After Opening: Notify stakeholders of time change
  3. Close to Draw Time: Avoid changes - may cause confusion

Updating Digits

The digits field affects:
  • Valid winning number range during evaluation
  • Display formatting in UI
  • Ticket validation logic
{
  "digits": 2
}
// Valid winning numbers: 00-99

Activate/Deactivate Sorteo

Use the dedicated Set Active endpoint for bulk activation operations.
Deactivating a sorteo:
{
  "isActive": false
}
Effects:
  • Hidden from vendedor lists
  • Cannot create new tickets
  • Existing tickets remain valid
  • Can be reactivated later

Activity Logging

All sorteo updates are logged in the activity system with:
  • Action: SORTEO_UPDATE
  • User: Admin who made the change
  • Details: Changed fields and their new values
  • Description: Human-readable summary
Example activity log:
{
  "userId": "admin-uuid",
  "action": "SORTEO_UPDATE",
  "targetType": "SORTEO",
  "targetId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "details": {
    "name": "Lotto 2:55 PM",
    "scheduledAt": "2025-03-03T14:55:00-06:00",
    "description": "Actualización de datos para Lotto 2:55 PM (Lotto) del 2025-03-03 14:55:00 -0600"
  }
}

Get Sorteo

View current sorteo details

Open Sorteo

Open sorteo for sales

Close Sorteo

Close sorteo for evaluation

Activity Logs

View audit trail

Build docs developers (and LLMs) love