> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withflock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigger Rewards

> This guide explains how to trigger rewards programmatically by ingesting a checkpoint to Flock's API.

<Note>
  For security reasons, rewards can only be triggered via the server-side API, not directly from client-side SDKs. All checkpoint events must be sent through your backend using the `/checkpoints/ingest` endpoint.
</Note>

Checkpoints provide a way to track key milestones in your user journey. When a checkpoint is triggered, the Flock backend can determine if a reward should be issued based on your campaign configuration.

### Step 1: Configure Checkpoints in Flock Dashboard

1. Log in to your Flock account at [app.withflock.com](https://app.withflock.com)
2. Navigate to the campaign where you want to configure checkpoints
3. In the campaign settings, select the checkpoint that should trigger rewards

### Step 2: Trigger Checkpoints via API

To trigger a checkpoint, you need to either call use our server-side SDK or make a POST request to the `/checkpoints/ingest` endpoint with the following data:

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { FlockSDK } from '@wflock/node-flock';

  const sdk = new FlockSDK({
    accessKey: 'your-service-access-key',
  });

  await sdk.checkpoints.ingest('purchase_completed', {
    externalUserId: 'user_123', // This is the user ID in your system
    environment: 'production', // or 'test'
  });
  ```

  ```python Python theme={null}
  import requests

  def trigger_checkpoint(checkpoint_name):
    url = "https://api.withflock.com/checkpoints/ingest"

    payload = {
      "name": checkpoint_name,
      "externalUserId": "user_123",    # User identifier in your system
      "environment": "production"      # 'production' or 'test'
    }

    headers = {
      "Content-Type": "application/json",
      "Authorization": "your_service_key"  # Your service API key
    }

    response = requests.post(url, json=payload, headers=headers)

    if response.status_code == 200:
      print("Checkpoint triggered successfully:", response.json())

  # Call the function to trigger the checkpoint
  trigger_checkpoint('purchase_completed')
  ```
</CodeGroup>

***
