# Sandbox & go-live

> Test the widget, prefill and the quote-to-bind webhook lifecycle with a test token, then switch to live.

Test everything end to end before you go live: the parts you use, including the widget, `upsert_lead`, event streams and signed webhooks. Sandbox leads never reach live insurance carriers or real customers.

## How sandbox isolation works

Your Kinro partnership contact issues two separate partner API tokens:

- **Sandbox token (`environment: "test"`):** Every lead created with a `test` token is flagged as a sandbox test lead. Live carrier submissions and outbound customer emails/SMS are blocked, and only your `test`-environment webhooks receive its events.
- **Production token (`environment: "live"`):** Used strictly in production after your go-live check.

Use the sandbox token at `https://api.kinro.com/mcp` once Kinro has configured your embed, even before activation. The production token and public embed require activation: until then, open the widget with a `customer_token` minted by `upsert_lead` with your sandbox token. Kinro can also provision access on `https://api-preview.kinro.com/mcp`. To point the widget at the preview endpoint, add `data-mcp-url="https://api-preview.kinro.com/mcp"` to the script tag.

For a complete run from a blank page to documents and webhooks, follow the [example integration](/docs/embedded/example-integration).

With a sandbox token, both `start_session` and `upsert_lead` attach the session to a test lead. Authenticate with a sandbox token whenever you want to create a test lead.

## Test leads and live leads

| | Test lead | Live lead |
| --- | --- | --- |
| **Created by** | Your `test` token (`upsert_lead`, `start_session`), a `customer_token` minted with it, or any visitor on a [local development page](/docs/embedded/add-script#8-develop-locally) | Your `live` token, a `customer_token` minted with it, or an anonymous visitor on your registered sites after activation |
| **Leo** | Answers in the widget as usual | Answers in the widget as usual |
| **Emails, texts and calls** | Held, never sent | Sent to the contact details the customer gave |
| **Carriers** | Never submitted to live carriers | Real carrier quotes and policies |
| **Visible to** | `test` tokens: `list_leads`, `test` webhooks and the `test` event stream | `live` tokens: `list_leads`, `live` webhooks and the `live` event stream |
| **Documents in `list_leads`** | Included | Not yet |
| **Simulated events** | Yes, on the preview endpoint | Never |

A lead never changes between test and live. To test the same customer again, create a new test lead.

## Shared test lead

On the preview endpoint, every `test` token can read one shared test lead. It belongs to a made-up business, `Sample Harbor Bakery LLC`, and has a bound policy with sample documents. Use it to build your lead list, document handling and webhook handlers before your own test leads have quotes or policies.

- Its `external_id` is `kinro_shared_test_lead`. [`list_leads`](/docs/embedded/leads-and-policies) returns it to every `test` token with `shared_test_lead: true`, and counts it in your `counts`.
- Its documents (declarations page, policy and certificate of insurance) are sample PDFs marked as samples. Download them as described in [Policy documents](/docs/embedded/leads-and-policies#policy-documents).
- `simulate_sandbox_event` with `external_id: "kinro_shared_test_lead"` sends its `quote.ready`, `policy.bound` and `policy.status_changed` events to your `test` webhooks and your event stream only. Other partners never see your events.
- Nobody can change it: its policy stays active whatever events you simulate, and you cannot prefill it or open the widget on it. Create your own test lead with `upsert_lead` to test the conversation.

## Simulating quote and policy events

On the preview endpoint, a **`test`** partner token grants access to the `simulate_sandbox_event` MCP tool so you can deterministically drive a sandbox lead through the entire insurance lifecycle:

1. Create a sandbox lead with `upsert_lead` using your `test` token.
2. Trigger `quote_ready` to emit a sample quote event on MCP SSE and your sandbox webhook. It has the same fields as a live `quote.ready`, with one quote whose `checkout_url` is `null`, so the handler you build here works unchanged in production.
3. Trigger `policy_bound` to create a sandbox policy and emit `policy.bound`.
4. Trigger `policy_status_changed` to transition the sandbox policy to `active`, `pending_docs`, `cancelled`, or `expired` and emit `policy.status_changed`.

> **Important:** Use the preview endpoint and a `test` token to call `simulate_sandbox_event`.

### Example: full sandbox lifecycle

```bash
# 1. Trigger a simulated quote
curl -X POST https://api-preview.kinro.com/mcp \
  -H "Authorization: Bearer $KINRO_TEST_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": "sim_1",
    "method": "tools/call",
    "params": {
      "name": "simulate_sandbox_event",
      "arguments": {
        "action": "quote_ready",
        "external_id": "sandbox_acct_001",
        "line_of_business": "general_liability",
        "monthly_premium_usd": 115
      }
    }
  }'

# 2. Trigger a simulated policy bind
curl -X POST https://api-preview.kinro.com/mcp \
  -H "Authorization: Bearer $KINRO_TEST_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": "sim_2",
    "method": "tools/call",
    "params": {
      "name": "simulate_sandbox_event",
      "arguments": {
        "action": "policy_bound",
        "external_id": "sandbox_acct_001"
      }
    }
  }'

# 3. Trigger a simulated cancellation
curl -X POST https://api-preview.kinro.com/mcp \
  -H "Authorization: Bearer $KINRO_TEST_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": "sim_3",
    "method": "tools/call",
    "params": {
      "name": "simulate_sandbox_event",
      "arguments": {
        "action": "policy_status_changed",
        "external_id": "sandbox_acct_001",
        "policy_status": "cancelled",
        "reason": "Sandbox cancellation test"
      }
    }
  }'
```

## Staging QA checklist

Before switching to your `live` token, check the items that apply to your integration. Skip widget checks if your integration works entirely through your server.

- **Widget mounting:** Popup opens and closes cleanly (button, backdrop, Escape, focus restoration) and inline containers mount/unmount cleanly on SPA navigation.
- **CSP compliance:** No console CSP errors on `script-src`, `connect-src`, or `style-src` (with `data-nonce`).
- **Prefill skipping:** Passing a `customer_token` minted by `upsert_lead` skips questions your backend already answered; an expired token triggers `error` and recovers cleanly.
- **Mobile & private browsing:** Test at 390px viewport and in Safari Private / Chrome Incognito (no third-party cookies required).
- **Webhooks:** Signature verification succeeds for `quote.ready`, `policy.bound`, and `policy.status_changed`, and duplicate `evt_*` IDs are handled idempotently.

## Going live

1. Share your production HTTPS origins and production webhook URL with Kinro.
2. Complete a short integration review with Kinro covering placements, prefill mapping, and webhook verification.
3. Receive your `live` `kinro_pk_*` token and production `whsec_*` webhook secret, swap credentials in your server secrets manager, and roll out to your first cohort.

---

Source: https://kinro.com/docs/embedded/test-and-go-live. All Kinro docs: https://kinro.com/docs/llms.txt
