# Sandbox and test data

> Test against PerfectRide before any rider is involved: portal tests, certification trips and fixed scenarios.

## Sandbox and live

- The key decides the environment. The events and supply URLs are the same for both.
- Sandbox trips have no rider and no money. Send their events with your `prk_test_` key.
- An event sent with the wrong key for its trip gets 403 `wrong_environment`.

## Test your API

In the portal, **Test your API** calls your sandbox the way a real trip does and shows 6 results.

| Test | Passes when |
|---|---|
| Quote | You answer `POST /quotes` within 2 seconds, or say `available: false` |
| Book | `POST /trips` books, and the same `Idempotency-Key` again returns the same trip |
| Get trip | `GET /trips/{partner_trip_id}` returns that trip |
| Cancel | `POST /trips/{partner_trip_id}/cancel` answers 2xx |
| Wrong signature | You answer 401 |
| Old timestamp | A 10-minute-old `X-PR-Timestamp` gets 401 |

Sandbox only, public HTTPS hosts only, 10 runs an hour.

## Certification trips

Start a run in **Certification** (5 a day). We book one test trip per scenario. Each shows its `pr_trip_id` and PIN. Play them, then press check.

| Scenario | What you do |
|---|---|
| Card trip | Assign a driver, send a location, arrive. Send `trip.started` with pin `0000` (we refuse it), then with the PIN shown. Complete at the quoted price. Optional: `trip.rider_rated` |
| Driver cancels | Assign a driver, then cancel as the driver (`cancelled_by: driver`) |
| No drivers | Send `trip.no_driver` |
| Rider cancels | Nothing. We book it twice with the same `Idempotency-Key` and cancel it as the rider |
| Stops | Only when your Max stops is above 0. Assign, arrive, start with the PIN, send `trip.arrived_at_stop` then `trip.departed_stop` for each `stop_order`, complete at the quoted price |

> **Note:** Cash is not part of the sandbox run. PerfectRide switches cash on per partner during the pilot. See [Cash trips](https://docs.perfectride.io/docs/cash-trips).

## What certification checks

| Check | Required |
|---|---|
| Quote within 2 seconds, and `available: false` handled | Yes |
| Trip completed | Yes |
| Events in the right order. `trip.driver_assigned` carries a valid `driver.phone` | Yes |
| Cancel by the rider (we call you) and by the driver (you send it) | Yes |
| `trip.no_driver` when nobody is free | Yes |
| Duplicate booking returns the same trip | Yes |
| Signatures and timestamps checked both ways | Yes |
| Rider code: a wrong code is refused, the right one starts the trip | Yes |
| Driver counts: a valid `POST /supply` with your sandbox key during the run | Yes |
| Trip with stops | Once your Max stops is above 0 |
| Ratings both ways | Optional |
| Settlement report matches | Optional |

## Tools

| Tool | Use |
|---|---|
| [Postman collection](https://docs.perfectride.io/partner-api/perfectride-partner-api.postman_collection.json) | Send signed events, and call your own endpoints the way we do |
| [Sample server](https://docs.perfectride.io/partner-api/sample-server.md) | A reference partner in one Node file: `run t_1 4821` plays a whole trip |
| Event log | In the portal: your last 100 events, accepted or refused, with the reason |

**Our reference partner**

PerfectRide tests its own side against a mock partner that implements this spec, at `https://www.perfectride.io/api/partner-sandbox/mock`. Its behaviour follows the pickup address, which is a handy model for your own test switches:

- `slow`: the quote takes 3 seconds (over the 2 second limit)
- `nodriver`: 200 `{ "available": false }`
- `broken`: 500

It only answers keys PerfectRide wired to it.

## Next

- [Quickstart: your first trip](https://docs.perfectride.io/docs/quickstart.md): Get sandbox keys, answer a quote and a booking, send your first signed event and see it in the portal.
- [Go-live checklist](https://docs.perfectride.io/docs/go-live.md): Everything that must be done before PerfectRide starts your pilot with live riders.
- [Trip events](https://docs.perfectride.io/docs/trip-events.md): Tell PerfectRide what happens on each trip, in order, and handle our answers.

Source: https://docs.perfectride.io/docs/sandbox
