Module Identifier: sessions
The Session object describes one charging session. The Session object is owned by the CPO back-end system, and can be GET from the CPO system, or pushed by the CPO to another system.
When the CPO creates a Session object they push it to the eMSPs by calling PUT on the eMSPs Sessions endpoint with the newly created Session object.
Any changes to a Session in the CPO system are sent to the eMSP system by calling PATCH on the eMSPs Sessions endpoint with the updated Session object.
Sessions cannot be deleted, final status of a session is: COMPLETED
.
When the CPO is not sure about the state or existence of a Session object in the eMSPs system, the CPO can call the GET to validate the Session object in the eMSP system.
eMSPs who do not support the push model need to call GET on the CPOs Sessions endpoint to receive a list of Sessions.
This GET can also be used, combined with the Push model to retrieve Sessions after the system (re)connects to a CPO, to get a list Sessions 'missed' during a time offline.
Example endpoint structure: /ocpi/cpo/2.0/sessions/?date_from=xxx&date_to=yyy
Fetch Sessions from the CPO systems.
Only Sessions with last_update
between the given {date_from} and {date_to} will be returned.
This request is paginated, so also supports the pagination related URL parameters.
| Parameter | Datatype | Required | Description | |------------|---------------------------------------|----------|-------------------------------------------------------------------------------| | date_from | [DateTime](types.md#12-datetime-type) | yes | Only return Sessions that have `last_updated` after this Date/Time. | | date_to | [DateTime](types.md#12-datetime-type) | no | Only return Sessions that have `last_updated` before this Date/Time. | | offset | int | no | The offset of the first object returned. Default is 0. | | limit | int | no | Maximum number of objects to GET. |The response contains a list of Session objects that match the given parameters in the request, the header will contain the pagination related headers.
Any older information that is not specified in the response is considered as no longer valid. Each object must contain all required fields. Fields that are not specified may be considered as null values.
| Datatype | Card. | Description | |-------------------------------|-------|-------------------------------------------------------------------------| | [Session](#31-session-object) | * | List of Session objects that match the request parameters |Sessions is a client owned object, so the end-points need to contain the required extra fields: {party_id} and {country_code}.
Example endpoint structure:
/ocpi/emsp/2.0/sessions/{country_code}/{party_id}/{session_id}
The CPO system might request the current version of a Session object from the eMSP system for, for example validation purposes, or the CPO system might have received a error on a PATCH.
The following parameters can be provided as URL segments.
| Parameter | Datatype | Required | Description | |------------------|---------------------------------------|----------|-------------------------------------------------------------------------------| | country_code | [string](types.md#15-string-type)(2) | yes | Country code of the CPO requesting this PUT to the eMSP system. | | party_id | [string](types.md#15-string-type)(3) | yes | Party ID (Provider ID) of the CPO requesting this PUT to the eMSP system. | | session_id | [string](types.md#15-string-type)(15) | yes | id of the Session object to get from the eMSP system. |The response contains the request Session object, if available.
| Datatype | Card. | Description | |-------------------------------|-------|---------------------------------------------------------------| | [Session](#31-session-object) | 1 | Session object requested. |Inform the system about a new/updated session in the eMSP backoffice by PUTing a Session object.
The request contains the new or updated Session object.
| Type | Card. | Description | |---------------------------------|-------|------------------------------------------| | [Session](#31-session-object) | 1 | new Session object. |The following parameters can be provided as URL segments.
| Parameter | Datatype | Required | Description | |------------------|---------------------------------------|----------|-------------------------------------------------------------------------------| | country_code | [string](types.md#15-string-type)(2) | yes | Country code of the CPO requesting this PUT to the eMSP system. | | party_id | [string](types.md#15-string-type)(3) | yes | Party ID (Provider ID) of the CPO requesting this PUT to the eMSP system. | | session_id | [string](types.md#15-string-type)(15) | yes | id of the new or updated Session object. |Same as the PUT method, but only the fields/objects that have to be updated have to be present, other fields/objects that are not specified are considered unchanged.
PATCH To URL: https://www.server.com/ocpi/cpo/2.0/sessions/NL/TNM/101
{
"total_cost": "0.60"
}
{
"id": "101",
"start_datetime": "2015-06-29T22:39:09+02:00",
"kwh": "0.00",
"auth_id": "FA54320",
"location": {
"id": "LOC1",
"type": "on_street",
"name": "Gent Zuid",
"address": "F.Rooseveltlaan 3A",
"city": "Gent",
"postal_code": "9000",
"country": "BE",
"coordinates": {
"latitude": "3.72994",
"longitude": "51.04759"
},
"evse": {
"uid": "3256",
"evse_id": "BE-BEC-E041503003",
"STATUS": "AVAILABLE",
"connectors": [{
"id": "1",
"standard": "IEC_62196_T2",
"format": "SOCKET",
"power_type": "AC_1_PHASE",
"voltage": "230",
"amperage": "64",
"tariff_id": "11"
}]
}
},
"currency": "EUR",
"total_cost": "2.50",
"status": "PENDING"
}
{
"id": "101",
"start_datetime": "2015-06-29T22:39:09+02:00",
"end_datetime": "2015-06-29T23:50:16+02:00",
"kwh": "0.00",
"auth_id": "FA54320",
"location": {
"id": "LOC1",
"type": "on_street",
"name": "Gent Zuid",
"address": "F.Rooseveltlaan 3A",
"city": "Gent",
"postal_code": "9000",
"country": "BE",
"coordinates": {
"latitude": "3.72994",
"longitude": "51.04759"
},
"evse": {
"uid": "3256",
"evse_id": "BE-BEC-E041503003",
"STATUS": "AVAILABLE",
"connectors": [{
"id": "1",
"standard": "IEC_62196_T2",
"format": "SOCKET",
"power_type": "AC_1_PHASE",
"voltage": "230",
"amperage": "64",
"tariff_id": "11"
}]
}
},
"currency": "EUR",
"charging_periods": [{
"start_date_time": "2015-06-29T22:39:09+02:00",
"dimensions": [{
"type": "ENERGY",
"volume": 120
}, {
"type": "MAX_CURRENT",
"volume": 30
}]
}, {
"start_date_time": "2015-06-29T22:40:54+02:00",
"dimensions": [{
"type": "energy",
"volume": 41000
}, {
"type": "MIN_CURRENT",
"volume": 34
}]
}, {
"start_date_time": "2015-06-29T23:07:09+02:00",
"dimensions": [{
"type": "PARKING_TIME",
"volume": 0.718
}]
}],
"total_cost": "8.50",
"status": "COMPLETED"
}
Describe all datatypes used in this object
| Property | Description | |-----------|----------------------------------------------------------------------------| | ACTIVE | The session is accepted and active. | | COMPLETED | The session is finished successfully. | | INVALID | The session is declared invalid and will not be billed. | | PENDING | The session is pending and has not yet started. This is the initial state. |