πŸ“„Reward rules webhook

Introduction

Reward rules webhook is a synchronous webhook that allow users to override Magami's default reward rules draw logic in a campaign. Reward rules webhook only support the HTTP(S) protocol; it is sent as POST requests with the application/json body and expects a response of the same content type.

Configuration

You can add the webhook in the Integrations section inside campaign detail page. Make sure to select Override prize/reward draw rules in the Actions section before you save your webhook information.

After your webhook successfully added, go to edit campaign first and head to Reward Rules section to enable Use webhook instead? and select your webhook, then save the changes. Only one webhook can be selected.

Request payload

Magami will send a payload of the campaign and its reward(s) to help you to create your own reward draw rules logic.

The request header will contain an attribute named Magami-Event with value override_prize_draw_rules.

Here is the example of request payload that Magami sent:

{
    "campaign": {
        "id": 1,
        "name": "Campaign Name",
        "code": "",
        "slug": "campaign-name",
        "campaign_type": "instant_draw",
        "start_at": "2022-02-02T17:00:00.000000Z",
        "end_at": "2024-02-10T16:59:59.000000Z",
        "logo": null,
        "is_active": 1,
        "welcome_screen_before_campaign": null,
        "welcome_screen_during_campaign": null,
        "welcome_screen_after_campaign": null,
        "result_screen_win": null,
        "result_screen_not_win": null,
        "security_option": "unique_codes",
        "security_coupon_set_id": 13,
        "domains": null,
        "created_at": null,
        "updated_at": "2023-02-14T07:22:08.000000Z",
        "deleted_at": null,
        "use_webhook_for_rules": 1,
        "rules_webhook_url": "https:\/\/bin-request.dev.embrio.id\/magami",
        "settings": {
            "limit_participants_win": "1"
        },
        "description": null,
        "use_leaderboard": 0
    },
    "rewards": [
        {
            "reward_id": 1,
            "name": "Reward 1",
            "qty": 200000
        },
        {
            "reward_id": 2,
            "name": "Reward 2",
            "qty": 50
        },
    ]
}

Response payload

Magami expects a response sent from the webhook which contains information about reference ID of a reward which the participant/end-user will get as reward_id. Since you make your own logic, meaning that you can decide whether the participant getting a reward or not. If the latter, you can leave the value as null.

Here is the example of response payload that you must send back to Magami:

Last updated