Virtual Charger
A virtual charger is a simulated OCPP 1.6J charger that runs on Capacitor's servers. It connects to the same OCPP endpoint as physical chargers and exchanges the same messages (BootNotification, StatusNotification, StartTransaction, MeterValues), so anything you build against it works with real hardware. Use it to try Capacitor or test your integration before your charger is installed. Every other endpoint (chargers, transactions, webhooks, commands) treats it like any other charger.
Plans and limits
| Plan | Virtual chargers | Connectors each |
|---|---|---|
| Free | 1 | 1 |
| Starter and above | 5 | up to 4 |
- Virtual chargers don't count towards your charger limit.
- Charging sessions stop automatically after 30 minutes.
- A virtual charger nobody uses for 2 hours goes to sleep (
virtualState: "sleeping"). It wakes automatically when you call an endpoint for it, such asGET /chargers/:chargeBoxId. - Energy readings run faster than real time, so demo sessions show numbers quickly. Virtual sessions are flagged
virtual: true. - Only Capacitor can run a virtual charger. A physical device can't connect as one.
- Webhooks and OCPP commands (reset, configuration…) work with virtual chargers on the Starter plan and above, as for any charger.
Create a virtual charger
/api/v1/chargers/virtualCreate a virtual charger. It starts connecting straight away and is usually online within a few seconds.
{"name": "Test bay","connectors": 1,"chargeRate": 7.4}
| Parameter | Type | Description |
|---|---|---|
name | string | Display name (max 100 chars). Default "Virtual charger" |
connectors | integer | 1-4. More than 1 needs the Starter plan or above |
chargeRate | number | Charging power in kW, 1-350. Default 7.4 |
{"id": "abc123","chargeBoxId": "VIRTUAL-7KQ2MX","name": "Test bay","virtual": true,"virtualConfig": { "connectors": 1, "chargeRate": 7.4 },"virtualState": "starting","message": "Virtual charger created and connecting. It is usually online within a few seconds."}
Errors: 429 when you've reached your plan's virtual charger allowance, 403 when you ask for more connectors than your plan allows, 503 when virtual chargers are temporarily unavailable.
Charger-side actions
/api/v1/chargers/:chargeBoxId/virtual/actionsDo what a driver or installer would do at the charger.
{ "action": "plug", "connectorId": 1 }
| Parameter | Type | Description |
|---|---|---|
action* | string | plug, unplug, fault, clear_fault, go_offline, go_online |
connectorId | integer | Connector for plug/unplug/fault/clear_fault. Default 1 |
plug: the connector goes toPreparing, ready forPOST /transactions/start.unplug: ends any session; the connector goes toAvailable.fault/clear_fault: puts the connector intoFaultedand back.go_offline/go_online: disconnects the charger and reconnects it.
{"chargeBoxId": "VIRTUAL-7KQ2MX","action": "plug","virtualLive": {"connected": true,"connectors": [{ "id": 1, "status": "Preparing", "transactionId": null, "meterWh": 0 }]}}
Walkthrough: a full charging session
API=https://api.capacitor.live/api/v1H="X-API-Key: $CAPACITOR_API_KEY"# 1. Create (note the chargeBoxId in the response)curl -s -X POST $API/chargers/virtual -H "$H"# 2. Wait until it's online (isOnline: true, connector 1 Available)curl -s $API/chargers/VIRTUAL-7KQ2MX -H "$H"# 3. Plug in a vehiclecurl -s -X POST $API/chargers/VIRTUAL-7KQ2MX/virtual/actions -H "$H" \-H "Content-Type: application/json" -d '{"action":"plug","connectorId":1}'# 4. Start charging. Any idTag works on every plancurl -s -X POST $API/transactions/start -H "$H" \-H "Content-Type: application/json" \-d '{"chargeBoxId":"VIRTUAL-7KQ2MX","connectorId":1,"idTag":"DEMO42"}'# 5. Find the session (or listen for the transaction.started webhook)curl -s "$API/transactions?chargeBoxId=VIRTUAL-7KQ2MX&status=in_progress" -H "$H"# 6. Stop itcurl -s -X POST $API/transactions/1/stop -H "$H"# 7. Delete the virtual charger when you're donecurl -s -X DELETE $API/chargers/VIRTUAL-7KQ2MX -H "$H"
POST /transactions/start returns 202 when the charger accepts the request; the session itself starts a moment later. Confirm it with the transaction.started webhook or by listing in-progress transactions.Virtual fields on chargers
GET /chargers and GET /chargers/:chargeBoxId include these extra fields for virtual chargers:
| Parameter | Type | Description |
|---|---|---|
virtual | boolean | true for virtual chargers |
virtualState | string | online, offline or sleeping (detail endpoint) |
virtualConfig | object | { connectors, chargeRate } (detail endpoint) |
virtualLive | object | null | Live simulator view: connected, connectors[] with status and meterWh (detail endpoint) |