Tutorials
How to implement the LoyaltySurf REST API in common use-case scenarios.
Table of contents
Example 1: Trigger a loyalty action
Step 2: Trigger loyalty action
const request = require("request");
const options = {
method: 'POST',
url: 'https://api.loyaltysurf.io/v1/campaign/4pdlhb/loyalty-action', // Replace '4pdlhb' with your LoyaltySurf program ID
headers: {
Authorization: 'Bearer <YOUR_API_KEY>' // Replace '<YOUR_API_KEY>' with your API key -- get this from https://app.loyaltysurf.io/settings
},
json: true
};
const uploadFile = () => {
// ...code that allows the user to upload a file...
options.body = {
participantEmail: '[email protected]', // Replace '[email protected]' with your user's email address
rewardId: 'crew_jw83va', // Replace 'crew_jw83va' with a reward ID from your LoyaltySurf program
};
// Send the API request to trigger the loyalty action
request(options, (error, response, body) => {
if (error) {
throw new Error(error);
}
// Check to see if the loyalty action was triggered successfully
const { success, message } = body.success;
if (success) {
console.log('loyalty action trigger success!');
} else {
console.log('loyalty action trigger failed :( ', message);
}
});
};Set up reward fulfillment
Example 2: Get a participant's details
Step 2: Retrieve a participant by email
Last updated
Was this helpful?