Skip to main content

⚡ 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】.

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

FieldTypeCard.Description
country_codeCiString(2)1Country code of the CPO【343458627312853†L6261-L6265】.
party_idCiString(3)1Party ID of the CPO【343458627312853†L6266-L6270】.
idCiString(36)1Unique identifier for the session within the CPO system【343458627312853†L6271-L6275】.
start_date_timeDateTime1Timestamp when the session became ACTIVE【343458627312853†L6276-L6285】.
end_date_timeDateTime?Timestamp when the session finished【343458627312853†L6286-L6291】.
kwhnumber1Energy delivered during the session【343458627312853†L6292-L6296】.
cdr_tokenCdrToken1Token used to start the session【343458627312853†L6304-L6308】.
auth_methodAuthMethod1Method of authentication (e.g. WHITELIST, COMMAND)【343458627312853†L6309-L6316】.
authorization_referenceCiString(36)?Reference provided by the eMSP in real‑time authorize, StartSession or ReserveNow requests【343458627312853†L6317-L6325】.
location_idCiString(36)1Identifier of the Location where the session is taking place【343458627312853†L6327-L6331】.
evse_uidCiString(36)1EVSE UID within the Location【343458627312853†L6332-L6337】.
connector_idCiString(36)1Connector ID within the EVSE【343458627312853†L6338-L6345】.
meter_idstring(255)?Identification of the kWh meter【343458627312853†L6346-L6349】.
currencystring(3)1ISO‑4217 currency code【343458627312853†L6350-L6353】.
charging_periodslist of ChargingPeriod*Detailed consumption periods used to calculate cost【343458627312853†L6354-L6358】.
total_costPrice?Calculated cost of the session in the specified currency【343458627312853†L6359-L6366】.
statusSessionStatus1State of the session (PENDING, ACTIVE, INVALID, COMPLETED, etc.)【343458627312853†L6367-L6370】.
last_updatedDateTime1Timestamp 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】.