Get Started
Trigger Rewards
In Flock, rewards can be triggered automatically or manually, depending on the selected reward trigger. If you select any trigger other than “New User Signup”, you are required to implement the reward trigger in your backend code.
This guide explains how to trigger rewards programmatically by sending a POST request to Flock’s API.
Step 1: Retrieve Your API Key
- Log in to your Flock account at app.withflock.com.
- Navigate to the Secrets page.
- Locate the Service key on the page. This is the API key you will use to authenticate your requests.
Step 2: Understand the Trigger Rewards Endpoint
Endpoint:
Payload: The request payload should follow this structure:
Field | Type | Description |
---|---|---|
campaignId | string | The ID of the referral campaign for which the reward is being triggered. |
customerExternalId | string | A unique identifier for the customer triggering the reward. |
mode | enum | Determines the reward payout mode: latest (trigger only the latest reward) or all (trigger all eligible rewards). |
Step 3: Implement the API Call
Here’s an example implementation in Node.js using axios
:
Step 4: Testing Your Integration
- Use a development or staging environment to test the API call before going live.
- Verify the response from Flock to ensure the reward is triggered successfully.
- Monitor your logs to track reward triggering and debug any issues.
Example Response
A successful reward trigger will return a 200 OK
response with the reward details: