> ## Documentation Index
> Fetch the complete documentation index at: https://help.lobyco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lottery events

> JSON Schemas for the three events Lobyco publishes as an admin user draws, approves and replaces the winners of a lottery challenge.

Lobyco publishes a lottery event when an admin user draws, approves or replaces the winners of a lottery challenge in Lobyco Nexus. The events describe the draw, not one customer, so they carry no `CustomerId`.

> [!WARNING]
>
> You can't receive lottery events. None of them is a Data streams type, so a subscription can't select them, and no OutboundAPI connection is triggered by them. The schemas below are for reference only.

## Field reference

Field definitions match the challenge models of the Challenges endpoints.

| Event | Data streams type | Raised when |
| - | - | - |
| Lottery Winners Drawn | Not available | An admin user draws the winners, or draws them again. |
| Lottery Winners Approved | Not available | An admin user approves the winners. |
| Lottery Winner Removed | Not available | An admin user replaces a winner. |

[Draw lottery winners](https://help.lobyco.com/business-documentation/activities/challenges/draw-lottery-winners.md) shows these actions in Lobyco Nexus. Each one is possible only after a lottery challenge has ended, and only until its winners are approved.

Lottery Winners Drawn carries no winners. `WinnersCount` is the sum of `TotalRewards` over `Rewards`. It is the number of prizes the draw gives out at most, not the number of customers drawn. `BackupWinnersCount` is the number of backup winners the admin user asked for, or `0`. On a store lottery, both counts are per store.

Lottery Winners Approved carries the challenge's whole configuration in `ActivityConfiguration`. When a bonus reward can't be allocated, the draw stays unapproved and Lobyco publishes nothing.

On Lottery Winner Removed, `WinnerToRemove` is the winner taken off the list and `RemoveReason` is the reason the admin user gave. `NewWinner` is the customer drawn to take their place, or `null` when no customer was eligible. In both, `MemberId` identifies the customer.

`EventId` joins the event's name, an identifier and a time from the payload, written as `yyyy-MM-ddTHH:mm:ss.fffffff`. Each schema's `EventId` description shows which identifier and which time.

## Schemas

> [tab] Lottery Winners Drawn
>
> ```json theme={"system"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "$defs": {
>     "Reward": {
>       "type": ["object", "null"],
>       "properties": {
>         "Id": { "type": ["string", "null"] },
>         "OfferId": { "type": ["string", "null"] },
>         "Title": { "type": ["string", "null"] },
>         "DisplayTitle": { "type": ["string", "null"] },
>         "DisplayImageUrl": { "type": ["string", "null"] },
>         "TotalRewards": { "type": ["integer", "null"] },
>         "BonusAmount": { "type": ["number", "null"] },
>         "RewardType": { "type": "string", "enum": ["Coupon", "Bonus", "Custom", "LotteryTicket", "Multiple"] },
>         "Tier": { "type": "integer" },
>         "IssueStoreCoupon": { "type": "boolean" }
>       }
>     }
>   },
>   "properties": {
>     "ActivityId": { "type": "string" },
>     "UnifiedCampaignId": { "type": ["string", "null"] },
>     "Rewards": { "type": ["array", "null"], "items": { "$ref": "#/$defs/Reward" } },
>     "DrawType": { "type": "string", "enum": ["Instant", "GlobalLottery", "StoreLottery"] },
>     "WinnersCount": { "type": "integer" },
>     "BackupWinnersCount": { "type": "integer" },
>     "DrawnAt": { "type": "string", "format": "date-time" },
>     "EventId": { "type": "string", "description": "Composed as LotteryWinnersDrawn-{ActivityId}-{DrawnAt}." }
>   }
> }
> ```

> [tab] Lottery Winners Approved
>
> ```json theme={"system"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "$defs": {
>     "Reward": {
>       "type": ["object", "null"],
>       "properties": {
>         "Id": { "type": ["string", "null"] },
>         "OfferId": { "type": ["string", "null"] },
>         "Title": { "type": ["string", "null"] },
>         "DisplayTitle": { "type": ["string", "null"] },
>         "DisplayImageUrl": { "type": ["string", "null"] },
>         "TotalRewards": { "type": ["integer", "null"] },
>         "BonusAmount": { "type": ["number", "null"] },
>         "RewardType": { "type": "string", "enum": ["Coupon", "Bonus", "Custom", "LotteryTicket", "Multiple"] },
>         "Tier": { "type": "integer" },
>         "IssueStoreCoupon": { "type": "boolean" }
>       }
>     },
>     "ProgressRule": {
>       "type": ["object", "null"],
>       "properties": {
>         "Id": { "type": "integer" },
>         "ProgressCalculationType": { "type": "string", "enum": ["ProductCount", "PurchaseAmount", "StoreVisit", "PaymentMethod"] },
>         "UnitOfMeasure": { "type": ["string", "null"], "enum": ["Item", "Litre", "Gram", "Kilogram", null] },
>         "ApplicationType": { "type": "string", "enum": ["Include", "Exclude"] },
>         "RequiredProgress": { "type": ["number", "null"] },
>         "MinimumPurchaseAmount": { "type": ["number", "null"] },
>         "CooldownHours": { "type": ["integer", "null"] },
>         "PaymentTypes": { "type": ["array", "null"], "items": { "type": "string" } },
>         "Tier": { "type": "integer" },
>         "RuleIndex": { "type": "integer" },
>         "HasAffiliationFilter": { "type": "boolean" }
>       }
>     },
>     "ActivityConfiguration": {
>       "type": ["object", "null"],
>       "properties": {
>         "UnifiedCampaignId": { "type": ["string", "null"] },
>         "ActivityId": { "type": "string" },
>         "ActivityName": { "type": "string" },
>         "StartTime": { "type": "string", "format": "date-time" },
>         "EndTime": { "type": "string", "format": "date-time" },
>         "Rewards": { "type": ["array", "null"], "items": { "$ref": "#/$defs/Reward" } },
>         "ProgressRules": { "type": ["array", "null"], "items": { "$ref": "#/$defs/ProgressRule" } },
>         "ChainIds": { "type": ["array", "null"], "items": { "type": "string" } },
>         "ActivationLimit": { "type": ["integer", "null"] },
>         "HideInList": { "type": "boolean" },
>         "PickUpEndDate": { "type": ["string", "null"], "format": "date-time" },
>         "DaysForPickup": { "type": ["integer", "null"] },
>         "Status": { "type": "string", "enum": ["Draft", "Published"] },
>         "AudienceIds": { "type": ["array", "null"], "items": { "type": "string" } },
>         "IsSinglePurchase": { "type": "boolean" },
>         "RewardHighestTierOnly": { "type": "boolean" },
>         "AccrualValue": { "type": ["number", "null"] },
>         "ProductFileUrl": { "type": ["string", "null"] },
>         "CategoryFileUrl": { "type": ["string", "null"] },
>         "ActivationMode": { "type": "string", "enum": ["Manual", "Automatic"] },
>         "IsTemplate": { "type": "boolean" },
>         "DrawType": { "type": "string", "enum": ["Instant", "GlobalLottery", "StoreLottery"] },
>         "Scope": { "type": "string", "enum": ["Individual", "Household"] },
>         "DrawApproved": { "type": ["boolean", "null"] },
>         "DrawStartedAt": { "type": ["string", "null"], "format": "date-time" },
>         "TimeUnit": { "type": "string", "enum": ["None", "Hour", "Day", "Week", "Month", "Year"] },
>         "TimeUnitBetweenCardsIssued": { "type": ["integer", "null"] },
>         "ValidForDays": { "type": ["integer", "null"] },
>         "SegmentationType": { "type": "string", "enum": ["Standard", "Triggered"] },
>         "DiscountFilterType": { "type": "string", "enum": ["IncludeAll", "ExcludeAll", "RecalculateBasedOnPrice"] },
>         "FundedBy": { "type": ["string", "null"] },
>         "CheckoutTypes": { "type": ["array", "null"], "items": { "type": "string", "enum": ["Pos", "SelfCheckout", "ScanAndPay", "Online"] } },
>         "Tags": { "type": ["array", "null"], "items": { "type": "string" } },
>         "IssueStoreCoupon": { "type": "boolean" }
>       }
>     }
>   },
>   "properties": {
>     "ActivityConfiguration": { "$ref": "#/$defs/ActivityConfiguration" },
>     "ApprovedAt": { "type": "string", "format": "date-time" },
>     "ActivityId": { "type": "string" },
>     "UnifiedCampaignId": { "type": ["string", "null"] },
>     "EventId": { "type": "string", "description": "Composed as LotteryWinnersApproved-{ActivityId}-{ApprovedAt}." }
>   }
> }
> ```

> [tab] Lottery Winner Removed
>
> ```json theme={"system"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "type": "object",
>   "$defs": {
>     "LotteryWinner": {
>       "type": ["object", "null"],
>       "properties": {
>         "Id": { "type": "integer" },
>         "MemberId": { "type": ["string", "null"] },
>         "CardId": { "type": "string" },
>         "ActivityId": { "type": "string" },
>         "StoreId": { "type": ["string", "null"] },
>         "PurchaseId": { "type": ["string", "null"] },
>         "CardClosedAt": { "type": "string", "format": "date-time" },
>         "DrawDate": { "type": "string", "format": "date-time" },
>         "RemoveDate": { "type": "string", "format": "date-time" },
>         "IsRemoved": { "type": "boolean" },
>         "RemoveReason": { "type": ["string", "null"] },
>         "RewardId": { "type": ["string", "null"] },
>         "RewardTitle": { "type": ["string", "null"] },
>         "IsBackup": { "type": "boolean" }
>       }
>     }
>   },
>   "properties": {
>     "NewWinner": { "$ref": "#/$defs/LotteryWinner" },
>     "WinnerToRemove": { "$ref": "#/$defs/LotteryWinner" },
>     "RemoveReason": { "type": ["string", "null"] },
>     "UnifiedCampaignId": { "type": ["string", "null"] },
>     "RemovedAt": { "type": "string", "format": "date-time" },
>     "ActivityId": { "type": "string" },
>     "EventId": { "type": "string", "description": "Composed as LotteryWinnerRemoved-{WinnerToRemove.Id}-{RemovedAt}." }
>   }
> }
> ```

## API reference

Endpoint documentation: [Challenges](https://help.lobyco.com/api-reference/promotion-platform/challenges).

## Related

* [Challenge events](https://help.lobyco.com/integration/external-integrations/events/challenge-events.md) — the definition the lottery belongs to.
* [Card events](https://help.lobyco.com/integration/external-integrations/events/card-events.md) — the cards whose customers enter the draw.
* [Draw lottery winners](https://help.lobyco.com/business-documentation/activities/challenges/draw-lottery-winners.md) — what an admin user does in Lobyco Nexus.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.