This guide will help you set up a basic “Purchase Reward” program. By the end, you’ll have sent an event and seen a user’s balance increase automatically.Documentation Index
Fetch the complete documentation index at: https://docs.scrip.dev/llms.txt
Use this file to discover all available pages before exploring further.
1. Set up your environment
Grab your API key from the Scrip dashboard and set it as an environment variable:2. Create your Program & Asset
A Program is the top-level container for your rules and participants. An Asset is the unit of value you’re tracking (points, credits, etc.). First create a program, then create an asset inside it.program_id from the response. You’ll use it in every subsequent call.
scale controls decimal precision. 0 means whole numbers only (10 points, not 10.5). Copy the asset_id from this response for the next step.
3. Define a Rule
Rules tell Scrip when to give out points. We’ll create a rule that gives 10 points for every event where thetype is "purchase".
4. Send an Event
Send a purchase event for a user. Theexternal_id is whatever ID you use for this user in your own system.
You don’t need to create the participant first. Scrip creates and enrolls them automatically when their first event arrives.
idempotency_key prevents duplicate processing. If you retry this request with the same key, Scrip returns the original response instead of crediting points again.
5. Verify the Balance
Events process asynchronously, so give it a moment. Then checkuser_123’s balance.
First, look up the participant by their external_id to get the Scrip-assigned id:
id to fetch their balances:
Next Steps
Now that you’ve seen the core loop, dive deeper:- Writing Rules: Use CEL to build complex logic (e.g., “double points for VIPs”).
- State Management: Use counters and tags to track user progress over time.
- Redemptions: Let users spend those points on rewards.