⚡ Sessions
A Session represents an ongoing charging event. Sessions are owned by the CPO and can be created, updated and retrieved by the eMSP via the Sessions module. They are dynamic objects designed to provide real‑time feedback to drivers about the progress and cost of their charging session【343458627312853†L6224-L6239】.
Session lifecycle
A session is created when a driver authenticates at an EVSE. Initially its status is PENDING. Once charging starts the status changes to ACTIVE, and when the driver disconnects or the charge is stopped it becomes COMPLETED. Sessions cannot be deleted; instead they transition to COMPLETED and a CDR is generated for invoicing【343458627312853†L6324-L6337】.
Recommended updates
OCPI recommends sending PATCH updates during a session to provide the eMSP with incremental cost information. Charging periods should be added at a cadence appropriate to the charging speed—sending a new period every minute during an AC session may be excessive, while one period for a 30‑minute DC session is not enough【343458627312853†L6235-L6249】. CPOs decide the exact interval, but should ensure that at least each tariff or price component change triggers a new charging period.【343458627312853†L6250-L6253】.
Session object
| Field | Type | Card. | Description |
|---|---|---|---|
country_code | CiString(2) | 1 | Country code of the CPO【343458627312853†L6261-L6265】. |
party_id | CiString(3) | 1 | Party ID of the CPO【343458627312853†L6266-L6270】. |
id | CiString(36) | 1 | Unique identifier for the session within the CPO system【343458627312853†L6271-L6275】. |
start_date_time | DateTime | 1 | Timestamp when the session became ACTIVE【343458627312853†L6276-L6285】. |
end_date_time | DateTime | ? | Timestamp when the session finished【343458627312853†L6286-L6291】. |
kwh | number | 1 | Energy delivered during the session【343458627312853†L6292-L6296】. |
cdr_token | CdrToken | 1 | Token used to start the session【343458627312853†L6304-L6308】. |
auth_method | AuthMethod | 1 | Method of authentication (e.g. WHITELIST, COMMAND)【343458627312853†L6309-L6316】. |
authorization_reference | CiString(36) | ? | Reference provided by the eMSP in real‑time authorize, StartSession or ReserveNow requests【343458627312853†L6317-L6325】. |
location_id | CiString(36) | 1 | Identifier of the Location where the session is taking place【343458627312853†L6327-L6331】. |
evse_uid | CiString(36) | 1 | EVSE UID within the Location【343458627312853†L6332-L6337】. |
connector_id | CiString(36) | 1 | Connector ID within the EVSE【343458627312853†L6338-L6345】. |
meter_id | string(255) | ? | Identification of the kWh meter【343458627312853†L6346-L6349】. |
currency | string(3) | 1 | ISO‑4217 currency code【343458627312853†L6350-L6353】. |
charging_periods | list of ChargingPeriod | * | Detailed consumption periods used to calculate cost【343458627312853†L6354-L6358】. |
total_cost | Price | ? | Calculated cost of the session in the specified currency【343458627312853†L6359-L6366】. |
status | SessionStatus | 1 | State of the session (PENDING, ACTIVE, INVALID, COMPLETED, etc.)【343458627312853†L6367-L6370】. |
last_updated | DateTime | 1 | Timestamp of the last update【343458627312853†L6371-L6374】. |
The charging_periods property is a list of objects containing start and end times, billing dimension (ENERGY, TIME, PARKING_TIME), volume and cost. When pricing conditions change (e.g. a peak rate after 17:00 or a different power tier), you must start a new charging period【343458627312853†L6243-L6255】. See the CDR section for more details on how charging periods influence billing.
Store‑and‑forward
The Gireve implementation guide advises CPOs to implement a store‑and‑forward mechanism. If a PUT or PATCH session request fails (no HTTP 2xx response), the message should be stored and retried later in FIFO order【826352846409834†L1275-L1283】.
Once a session is completed, a CDR should be generated immediately so that the eMSP can bill the driver【826352846409834†L1345-L1348】.