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.

You can also create and control virtual chargers from the dashboard: open Chargers and click Add virtual charger. Overview: OCPP simulator.

Plans and limits

PlanVirtual chargersConnectors each
Free11
Starter and above5up 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 as GET /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

POST/api/v1/chargers/virtual

Create a virtual charger. It starts connecting straight away and is usually online within a few seconds.

Request body (all optional)
json
{
  "name": "Test bay",
  "connectors": 1,
  "chargeRate": 7.4
}
ParameterTypeDescription
namestringDisplay name (max 100 chars). Default "Virtual charger"
connectorsinteger1-4. More than 1 needs the Starter plan or above
chargeRatenumberCharging power in kW, 1-350. Default 7.4
Response (201 Created)
json
{
  "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

POST/api/v1/chargers/:chargeBoxId/virtual/actions

Do what a driver or installer would do at the charger.

Request body
json
{ "action": "plug", "connectorId": 1 }
ParameterTypeDescription
action*stringplug, unplug, fault, clear_fault, go_offline, go_online
connectorIdintegerConnector for plug/unplug/fault/clear_fault. Default 1
  • plug: the connector goes to Preparing, ready for POST /transactions/start.
  • unplug: ends any session; the connector goes to Available.
  • fault / clear_fault: puts the connector into Faulted and back.
  • go_offline / go_online: disconnects the charger and reconnects it.
Response (200 OK)
json
{
  "chargeBoxId": "VIRTUAL-7KQ2MX",
  "action": "plug",
  "virtualLive": {
    "connected": true,
    "connectors": [{ "id": 1, "status": "Preparing", "transactionId": null, "meterWh": 0 }]
  }
}

Walkthrough: a full charging session

Terminal
bash
API=https://api.capacitor.live/api/v1
H="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 vehicle
curl -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 plan
curl -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 it
curl -s -X POST $API/transactions/1/stop -H "$H"
# 7. Delete the virtual charger when you're done
curl -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:

ParameterTypeDescription
virtualbooleantrue for virtual chargers
virtualStatestringonline, offline or sleeping (detail endpoint)
virtualConfigobject{ connectors, chargeRate } (detail endpoint)
virtualLiveobject | nullLive simulator view: connected, connectors[] with status and meterWh (detail endpoint)