# Test mode

> Run through charging, payments and faults without hardware and without real money.

With a test key `lh_test_…` you work in a fully separate test environment. Charging stations are simulated and payments use a test payment. Ideal for trying things out, for automated tests and for AI agents you want to let practise safely first.

## Create test devices

```bash
curl -X POST https://api.ladehase.com/v1/integrations/test \
  -H "Authorization: Bearer lh_test_…"
```

Ladehase creates a test integration with simulated charge points. The request can be repeated, existing test devices are kept.

## Simulate a car

Control a test device with `POST /v1/devices/{id}/simulate`. Allowed actions:

<table>
  <thead>
    <tr><th>Action</th><th>Effect</th></tr>
  </thead>
  <tbody>
    <tr><td>`plug`</td><td>Plug in a car. `vehicle_need_wh` sets how much energy the car takes until it is full.</td></tr>
    <tr><td>`unplug`</td><td>Unplug the cable. A running session ends with the reason `unplugged`.</td></tr>
    <tr><td>`set_power`</td><td>Change the charging power, in watts with `power_w`.</td></tr>
    <tr><td>`offline`, `online`</td><td>Disconnect or reconnect the charging station.</td></tr>
    <tr><td>`error`, `clear_error`</td><td>Trigger or clear a fault.</td></tr>
  </tbody>
</table>

```bash
curl -X POST https://api.ladehase.com/v1/devices/dev_…/simulate \
  -H "Authorization: Bearer lh_test_…" \
  -H "Content-Type: application/json" \
  -d '{ "action": "plug", "vehicle_need_wh": 20000 }'
```

## Test payments

When you scan the QR code of a test charge point, the payment page opens a test payment. There you choose whether the payment succeeds, fails or is cancelled. This lets you check every path without moving money.

> **Hinweis:** Webhooks work in test mode exactly as in live mode. Every event carries `livemode: false`.

## Go live

As soon as you have connected a real charging station and an account at zahls.ch or Freika, use a live key `lh_live_…`. Nothing changes in your code except the key.
