- Reference
- OCPI 2.1.1 (eMSP)
- Receiver Session
OpenAPI reference
Receiver Session
/sessions/{country_code}/{party_id}/{session_id}Inform about a new/updated Session object in the CPO's system.
API: OCPI 2.1.1 (eMSP) · Module: Sessions (eMSP)
Base path:/sessions· Base URL:https://ocpi-api.gridos.co/ocpi/emsp/2.1.1
Overview
PUT /sessions/{country_code}/{party_id}/{session_id}Absolute URL: https://ocpi-api.gridos.co/ocpi/emsp/2.1.1/sessions/{country_code}/{party_id}/{session_id}
Inform about a new/updated Session object in the CPO's system.
Requires authentication. Use Authorization: Token <token>. See OCPI credentials.
How to call
Quick Shell sample (set OCPI_TOKEN when auth is required). Full Python and TypeScript under Examples.
curl -sS -X PUT 'https://ocpi-api.gridos.co/ocpi/emsp/2.1.1/sessions/NL/ABC/SESSION1' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"id":"SESSION-123","start_datetime":"2015-06-29T21:39:09Z","kwh":12.4,"auth_id":"FA54320","auth_method":"AUTH_REQUEST","location":{"id":"LOC1","type":"ON_STREET","address":"F.Rooseveltlaan 3A","city":"Gent","postal_code":"9000","country":"BEL","coordinates":{"latitude":"51.047599","longitude":"3.729944"},"evses":[{"uid":"3256","status":"CHARGING","connectors":[{"id":"1","standard":"IEC_62196_T2","format":"CABLE","power_type":"AC_3_PHASE","voltage":220,"amperage":16,"last_updated":"2015-06-29T21:39:01Z"}],"last_updated":"2015-06-29T21:39:01Z"}],"last_updated":"2015-06-29T21:39:01Z"},"currency":"EUR","status":"ACTIVE","last_updated":"2015-06-29T21:40:00Z"}'Request
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
country_code | string | Yes | ISO-3166 alpha-2 country code of the party performing this request. |
party_id | string | Yes | 3-char party ID of the CPO or eMSP (ISO-15118). |
session_id | string | Yes | Session.id of the Session object. |
Request body
application/json · Required
Schema: SessionCreate
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | — |
start_datetime | string (date-time) | Yes | — |
end_datetime | string (date-time) | No | — |
kwh | number | Yes | — |
auth_id | string | Yes | — |
auth_method | `"AUTH_REQUEST" | "WHITELIST"` | Yes |
location | Location | Yes | — |
meter_id | string | No | — |
currency | string | Yes | — |
charging_periods | object[] | No | — |
total_cost | number | No | — |
status | `"ACTIVE" | "COMPLETED" | "INVALID" |
last_updated | string (date-time) | Yes | — |
Request examples
Example 1
{
"id": "SESSION-123",
"start_datetime": "2015-06-29T21:39:09Z",
"kwh": 12.4,
"auth_id": "FA54320",
"auth_method": "AUTH_REQUEST",
"location": {
"id": "LOC1",
"type": "ON_STREET",
"address": "F.Rooseveltlaan 3A",
"city": "Gent",
"postal_code": "9000",
"country": "BEL",
"coordinates": {
"latitude": "51.047599",
"longitude": "3.729944"
},
"evses": [
{
"uid": "3256",
"status": "CHARGING",
"connectors": [
{
"id": "1",
"standard": "IEC_62196_T2",
"format": "CABLE",
"power_type": "AC_3_PHASE",
"voltage": 220,
"amperage": 16,
"last_updated": "2015-06-29T21:39:01Z"
}
],
"last_updated": "2015-06-29T21:39:01Z"
}
],
"last_updated": "2015-06-29T21:39:01Z"
},
"currency": "EUR",
"status": "ACTIVE",
"last_updated": "2015-06-29T21:40:00Z"
}Example 2
{
"id": "SESSION-456",
"start_datetime": "2015-07-01T08:00:00Z",
"end_datetime": "2015-07-01T09:10:00Z",
"kwh": 18.75,
"auth_id": "EMP-7788",
"auth_method": "COMMAND",
"location": {
"id": "LOC2",
"type": "PARKING_GARAGE",
"address": "Stationsplein 1",
"city": "Utrecht",
"postal_code": "3511AA",
"country": "NLD",
"coordinates": {
"latitude": "52.089444",
"longitude": "5.110278"
},
"evses": [
{
"uid": "EVSE-UTR-1",
"status": "AVAILABLE",
"connectors": [
{
"id": "1",
"standard": "IEC_62196_T2",
"format": "SOCKET",
"power_type": "AC_3_PHASE",
"voltage": 400,
"amperage": 32,
"last_updated": "2015-07-01T07:59:00Z"
}
],
"last_updated": "2015-07-01T07:59:00Z"
}
],
"last_updated": "2015-07-01T07:59:00Z"
},
"currency": "EUR",
"status": "COMPLETED",
"total_cost": 6.95,
"last_updated": "2015-07-01T09:10:00Z"
}Responses
| Status | Description | Schema |
|---|---|---|
200 | Successful Response | SessionResponse |
400 | Invalid or missing parameters (HTTP 200, OCPI envelope) | — |
401 | Unauthorized | — |
422 | Validation Error | HTTPValidationError |
200 — successful response
application/json
Schema: SessionResponse
| Field | Type | Required | Description |
|---|---|---|---|
status_code | integer | No | Default: 1000 |
status_message | string | No | — |
timestamp | string (date-time) | No | — |
data | SessionOut | No | SessionOut |
Response example
{
"data": {
"auth_id": "DE8ACC12E46L89",
"auth_method": "WHITELIST",
"authorization_id": "DE8ACC12E46L89",
"charging_periods": [
{
"dimensions": [
{
"type": "ENERGY",
"volume": 41
}
],
"start_date_time": "2015-06-29T22:39:09Z"
}
],
"currency": "EUR",
"end_datetime": "2015-06-29T23:50:16Z",
"id": "101",
"kwh": 41,
"last_updated": "2015-06-29T23:50:16Z",
"location": {
"address": "F.Rooseveltlaan 3A",
"city": "Gent",
"coordinates": {
"latitude": "51.047599",
"longitude": "3.729944"
},
"country": "BEL",
"evses": [
{
"connectors": [
{
"amperage": 64,
"format": "SOCKET",
"id": "1",
"last_updated": "2015-06-29T23:09:10Z",
"power_type": "AC_1_PHASE",
"standard": "IEC_62196_T2",
"tariff_id": "11",
"voltage": 230
}
],
"evse_id": "BE-BEC-E041503003",
"last_updated": "2015-06-29T23:09:10Z",
"status": "AVAILABLE",
"uid": "3256"
}
],
"id": "LOC1",
"last_updated": "2015-06-29T23:09:10Z",
"name": "Gent Zuid",
"postal_code": "9000",
"type": "ON_STREET"
},
"meter_id": "METER-001",
"start_datetime": "2015-06-29T22:39:09Z",
"status": "ACTIVE",
"total_cost": 10
},
"status_code": 1000,
"status_message": "Success",
"timestamp": "2015-06-29T22:39:09Z"
}400 — invalid or missing parameters (HTTP 200, OCPI envelope)
application/json
Response example
{
"status_code": 2001,
"status_message": "Invalid or missing parameters",
"timestamp": "2025-01-01T00:00:00Z",
"doc_url": "https://github.com/ocpplab/ocpi-gateway/blob/main/docs/errors.md#2001-invalid-parameters",
"errors": [
{
"field": "country_code",
"message": "expected 'NL' to match Token A identity",
"type": "value_error.identity_mismatch"
}
]
}401 — unauthorized
application/json
Response example
{
"status_code": 2000,
"status_message": "Unauthorized",
"timestamp": "2025-01-01T00:00:00Z"
}422 — validation error
application/json
Schema: HTTPValidationError
| Field | Type | Required | Description |
|---|---|---|---|
detail | ValidationError[] | No | Detail |
Response example
{
"detail": [
{
"loc": [],
"msg": "string",
"type": "string",
"input": {
"_type": "Input"
},
"ctx": {
"_type": "Context"
}
}
]
}Examples
Shell, Python, and TypeScript (set OCPI_TOKEN when auth is required).
curl -sS -X PUT 'https://ocpi-api.gridos.co/ocpi/emsp/2.1.1/sessions/NL/ABC/SESSION1' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"id":"SESSION-123","start_datetime":"2015-06-29T21:39:09Z","kwh":12.4,"auth_id":"FA54320","auth_method":"AUTH_REQUEST","location":{"id":"LOC1","type":"ON_STREET","address":"F.Rooseveltlaan 3A","city":"Gent","postal_code":"9000","country":"BEL","coordinates":{"latitude":"51.047599","longitude":"3.729944"},"evses":[{"uid":"3256","status":"CHARGING","connectors":[{"id":"1","standard":"IEC_62196_T2","format":"CABLE","power_type":"AC_3_PHASE","voltage":220,"amperage":16,"last_updated":"2015-06-29T21:39:01Z"}],"last_updated":"2015-06-29T21:39:01Z"}],"last_updated":"2015-06-29T21:39:01Z"},"currency":"EUR","status":"ACTIVE","last_updated":"2015-06-29T21:40:00Z"}'