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

> ## Agent Instructions
> Start with https://docs.scrip.dev/agents.md and https://docs.scrip.dev/which-endpoints-you-need.md. Your application only needs a few API calls as users earn and spend (`POST /v1/events`, balance/history reads, and redemptions); program setup happens in the dashboard or setup scripts.
> Use `https://api-sandbox.scrip.dev` with `sk_test_` keys for testing, and `https://api.scrip.dev` with `sk_live_` keys for production. Keep API keys on your server.
> Pass your own user ID as `external_id` on events and prefix it with `ext:` in participant URL paths (e.g., `GET /v1/participants/ext:user_123/balances`). By default (`on_unknown_participant: CREATE`), the first event for a new `external_id` creates and enrolls the participant automatically.
> Events process asynchronously: `POST /v1/events` returns `202 Accepted` when queued, and rules evaluate in the background. Pass an `idempotency_key` (such as an order ID) on every event, and wait for the `event.completed` webhook or poll `GET /v1/events/{event_id}` before reading updated balances.
> Connect the hosted MCP server at https://mcp.scrip.dev/mcp (OAuth, defaults to Sandbox) to inspect programs, validate and simulate rules, and trace events. Append `.md` to any docs URL for Markdown, or fetch https://docs.scrip.dev/openapi.json for full endpoint schemas.

# Test in the sandbox

> Test events, balances, gift cards, and webhooks in an isolated environment before going live.

The sandbox is a persistent test environment included with every organization. Its programs, participants, balances, API keys, webhook endpoints, and rate limits are completely separate from production, so you can test your integration end to end without touching live data.

| What you want to test | Where to start |
| - | - |
| Earn points and read a participant's balance | [Send an event and check the balance](#send-an-event-and-check-the-balance) |
| Receive and replay signed webhooks | [Check webhook delivery](#check-webhook-delivery) |
| Redeem a test gift card | [Test a gift card](#test-a-gift-card) |
| Dry-run rules without changing balances | [Testing](https://docs.scrip.dev/guides/testing.md) |

## Switch to the sandbox and get a key

1. Open the [Scrip dashboard](https://app.scrip.dev) and select **Sandbox** from the environment menu. (Every member of your organization gets sandbox access automatically with their production role; see [Environments](https://docs.scrip.dev/environments.md) for team management details.)
2. Go to [**Developers > API keys**](https://app.scrip.dev/developers?tab=keys) and create a sandbox key (`sk_test_...`).
3. Configure your local or staging app with the sandbox base URL (`https://api-sandbox.scrip.dev`) and your `sk_test_` key.

Switching environments in the dashboard only changes what you see in the UI. Your application always talks to whichever base URL and API key you configure in its environment variables.

## Send an event and check the balance

Follow the [Quickstart](https://docs.scrip.dev/quickstart.md) with your sandbox base URL and `sk_test_` key to create a program, send a purchase event, and check the user's balance:

```bash theme={null}
GET /v1/participants/ext:user_123/balances
```

Events process in the background, so wait for the `event.completed` webhook or poll `GET /v1/events/{event_id}` before checking the balance. To test rule changes without creating ledger entries at all, you can also run [rule simulations](https://docs.scrip.dev/guides/testing.md).

## Check webhook delivery

Register a sandbox webhook endpoint for your test receiver. Scrip delivers to public HTTPS URLs; to test against `localhost`, use a local tunnel as shown in [Develop locally](https://docs.scrip.dev/guides/webhooks.md#develop-locally).

```bash theme={null}
POST /v1/webhook-endpoints
```

```json theme={null}
{
  "url": "https://example.com/webhooks/scrip",
  "description": "Sandbox receiver",
  "enabled_events": [
    "event.completed",
    "event.failed",
    "balance.credited",
    "redemption.fulfillment_succeeded",
    "redemption.fulfillment_failed"
  ]
}
```

Save the `secret` returned in the `201` response and use it to [verify webhook signatures](https://docs.scrip.dev/guides/webhooks.md#verify-a-delivery).

You can send a signed sample payload immediately to test your signature verification handler before triggering real events:

```bash theme={null}
POST /v1/webhook-endpoints/{webhook_endpoint_id}/test
```

```json theme={null}
{"event_type": "balance.credited"}
```

To test idempotency in your webhook handler, open [**Developers > Webhooks**](https://app.scrip.dev/developers?tab=webhooks) and click **Resend** on any delivery (or call `POST /v1/webhook-deliveries/{delivery_id}/resend`). Scrip resends the payload with a fresh signature and the same `webhook-id` header so you can verify your receiver deduplicates it.

## Test a gift card

In the sandbox, gift card redemptions use a Tremendous test account loaded with `$100,000` in test funds, so no real money moves and no real gift cards are issued.

1. With **Sandbox** selected in the dashboard, go to **Rewards > Add reward > Add gift cards**.
2. Click **Connect Tremendous**, enter an email that does not already manage a live Tremendous account, and complete the sandbox setup flow.
3. Once the status shows **Connected**, add a gift card to your sandbox program.
4. Redeem the item for your test participant:

```bash theme={null}
POST /v1/participants/ext:user_123/redemptions/items
```

```json theme={null}
{
  "program_id": "8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01",
  "reward_id": "2b7a9c4e-1f3d-4a8b-9e6c-5a1d3f7b8c08",
  "face_value": {"amount_minor": 2500, "currency": "USD"},
  "idempotency_key": "sandbox-gift-card-1001"
}
```

Check the redemption's `status` in the response and confirm that `redemption.fulfillment_succeeded` (or `redemption.fulfillment_failed`) arrives at your sandbox webhook endpoint. See [Gift cards](https://docs.scrip.dev/guides/gift-cards.md) for the full fulfillment and claim-link flow.

## Going to production

Sandbox data persists until you modify or archive it. To test a fresh scenario, pass a new `external_id` (such as `user_test_2`) or create a new sandbox program.

There is no one-click copy from Sandbox to Production. When you are ready to launch, switch the dashboard to **Production**, configure your live program (or apply your [rule configuration](https://docs.scrip.dev/guides/managing-rule-configuration.md) via the API), and point your production app at `https://api.scrip.dev` with an `sk_live_` key.

> [card] [Testing & simulations](https://docs.scrip.dev/guides/testing.md)
>
> Validate CEL expressions, simulate draft rules, and inspect event traces.

> [card] [Environments](https://docs.scrip.dev/environments.md)
>
> Compare Sandbox and Production URLs, headers, and isolation rules.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.