Getting started
Lantern allows you to create custom earn events to reward customers for behaviour. These custom earn events can either be triggered by a Shopify Flow action or by a webhook.
Custom Earn Events
The first thing you will need to do is create a Custom Earn Event that we will trigger with the webhook.
Go to the Loyalty section of Lantern and then to Earn events and then press Create event. Give your new event a name, choose Custom for the type, and choose how many points you want to award. Also make sure to set the Status to Active.
Make sure to note the Handle showed in the card on the right of the screen. We will need this later. You can also set the option here to allow a member to only ever be allowed to receive the reward for this event once.
Webhooks
To use a webhook to trigger an earn event, you'll need to have an API Key that you can use to authenticate the webhook request.
To generate a new API Key in Lantern go to Settings and then Integrations. From there you can click the "Generate API Key" button and you should see a new API Key appear.
Once you have your API Key and Earn Event setup, you are ready to trigger it with a webhook.
You will need to send a POST request to the following URL: https://lantern.gadget.app/earn-events/action
You will also need to add an authorization header using the API Key you generated earlier.
It should look something like this: x-lantern-api-key: YOUR_LANTERN_API_KEY
.
Send either the Customer ID or email to identify the user you want to give the reward to as well as the handle from the Earn Event we created earlier. We will send these as a JSON body in the request.
It should look something like:
{
email: "[email protected]",
earn_event_handle: "YOUR_EARN_EVENT_HANDLE"
}
Or:
{
customer_id: "YOUR_CUSTOMER_ID",
earn_event_handle: "YOUR_EARN_EVENT_HANDLE"
}
A full example using curl would look like:
curl -XPOST -H 'x-lantern-api-key: YOUR_LANTERN API_KEY' -H "Content-type: application/json" -d '{"email":"[email protected]","earn_event_handle":"YOUR_EARN_EVENT_HANDLE"}' 'https://lantern.gadget.app/earn-events/action'
If all goes well you should receive a successful response with a 200 code. If you then view your customer in the Lantern admin you should see they received the award for the earn event.