> ## 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.

# Quickstart

> Create a program, configure an asset and rule, send an event, and verify the resulting balance

Set up a purchase reward program: create a program and asset, add a rule, send an event, and watch a user's balance increase automatically.

## 1. Set up your environment

Grab your API key from the [Scrip dashboard](https://app.scrip.dev) and set it as an environment variable:

```bash theme={null}
export SCRIP_API_KEY="sk_your_api_key"
```

## 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.

```bash theme={null}
# Create the Program
curl -X POST https://api.scrip.dev/v1/programs \
  -H "Authorization: Bearer $SCRIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Customer Loyalty"}'
```

Copy the `id` from the response. It's the `program_id` you'll pass in every subsequent call.

```bash theme={null}
# Create a 'Points' asset inside that program
curl -X POST https://api.scrip.dev/v1/assets \
  -H "Authorization: Bearer $SCRIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "program_id": "YOUR_PROGRAM_ID",
    "name": "Points",
    "symbol": "PTS",
    "inventory_mode": "SIMPLE",
    "issuance_policy": "UNLIMITED",
    "scale": 0
  }'
```

`scale` controls decimal precision. `0` means whole numbers only (10 points, not 10.5). This quickstart uses `SIMPLE` mode because it only needs a running balance.

Use `LOT` mode instead if this asset needs expiration, vesting, auth/settlement matching, or issuer attribution for multi-program settlement. `inventory_mode` is immutable after creation. Copy the `id` from this response; it's the `asset_id` 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 the `type` is `"purchase"`.

```bash theme={null}
curl -X POST https://api.scrip.dev/v1/rules \
  -H "Authorization: Bearer $SCRIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "program_id": "YOUR_PROGRAM_ID",
    "name": "10 Points per Purchase",
    "condition": "event.type == \"purchase\"",
    "actions": [
      {
        "type": "CREDIT",
        "asset_id": "YOUR_ASSET_ID",
        "amount": "10"
      }
    ]
  }'
```

## 4. Send an Event

Send a purchase event for a user. The `external_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.

```bash theme={null}
curl -X POST https://api.scrip.dev/v1/events \
  -H "Authorization: Bearer $SCRIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "program_id": "YOUR_PROGRAM_ID",
    "external_id": "user_123",
    "idempotency_key": "first-purchase-001",
    "event_timestamp": "2026-07-05T12:00:00Z",
    "event_data": {
      "type": "purchase",
      "amount": 49.99
    }
  }'
```

`event_timestamp` is required: it records when the event actually happened, which is what time-based rules evaluate against. The `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 check `user_123`'s balance.

First, look up the participant by their `external_id` to get the Scrip-assigned `id`:

```bash theme={null}
curl https://api.scrip.dev/v1/participants?external_id=user_123 \
  -H "Authorization: Bearer $SCRIP_API_KEY"
```

Then use that `id` to fetch their balances:

```bash theme={null}
curl https://api.scrip.dev/v1/participants/PARTICIPANT_UUID/balances \
  -H "Authorization: Bearer $SCRIP_API_KEY"
```

You should see 10 points. The rule matched the purchase event, credited the participant, and recorded the transaction in the ledger.

## Next Steps

Now that you've seen the core loop, dive deeper:

* **[Writing Rules](/guides/writing-rules)**: Use CEL to build complex logic (e.g., "double points for VIPs").
* **[State Management](/guides/state-management)**: Use counters and tags to track user progress over time.
* **[Redemptions](/guides/redemptions)**: Let users spend those points on rewards.
