Integration Guides
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 |
---|---|---|
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). |
environment | enum (recommended) | The environment to trigger rewards for: test or production . This is the recommended way to trigger rewards. |
campaignId | string (alternative) | The ID of a specific campaign to trigger rewards for. Use this only if you need to target a specific campaign. |
Note: You must provide either environment
or campaignId
, but not both.
Step 3: Implement the API Call
Here’s an example implementation in various programming languages:
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: