Verifying rule completion
This recipe explains how to submit and verify loyalty rule completion via the Snag API.
Prerequisites
Before submitting and verifying loyalty rule completion, you must have a user registered in Snag.
Depending on the social platform, you’ll need the following user information:
-
Twitter: User’s Twitter handle and Twitter user ID
-
Telegram: User’s Telegram handle and Telegram user ID
-
Discord: User’s Discord handle and Discord user ID
For more information on user management, see:
Overview
Use the Snag API to submit and verify loyalty rule completions from your own backend. Because external verification to third-party services (e.g. Twitter, Telegram, etc.) may take up to a couple minutes, we use an asynchronous process to verify rule completion.
Note: The API-based verification process described in this recipe is only required for the following rule types:
- Code Entry
- Complete Profile
- Connect Discord
- Connect Email
- Connect Epic
- Connect Steam
- Connect Telegram
- Connect Twitter
- Connect Wallet
- Daily Check-In
- Discord Member
- Discord Messages
- External Rule
- Follow X Account
- Link Click
- Poll
- Quiz
- Telegram Join
- Telegram Messages
- Text Input
- TokenHold (only for multiplier reward type) - this step is not required for Cadence based rules (e.g., Token Hold, Sold On … etc), as these rules run automatically on the specified start time and on set cadence (daily, weekly, monthly).
- X New Tweet
- X Post Reaction
- X Text in Bio
- X Text in Comment
- X Text in Username
Let’s set up a rule to follow a specific Twitter account. The twitter handle or twitter user ID can be configured in the admin dashboard. We can then use the loyalty rule completion endpoint to submit a request to verify the rule completion. We can use the loyalty rule status endpoint to check the status of the rule completion request. When verification is complete, our system then creates a loyalty transaction to reward the user. The rule completion endpoint will return an error if re-called and the rule is already completed for the user.
Here is an example implementation in javascript on how you can use the following three endpoints to submit and verify loyalty rule completion:
Was this page helpful?