- Reference
- OCPI 2.2.1 (eMSP)
- Receiver Session
OpenAPI reference
Receiver Session
/sessions/{country_code}/{party_id}/{session_id}Notify the receiver of partial updates to a Session. Per OCPI 2.2.1 §9.4.3, the body MUST include `last_updated` (2001 if absent); path `country_code`/`party_id` MUST match the body's, when the body c
API: OCPI 2.2.1 (eMSP) · Module: Sessions (eMSP)
Base path:/sessions· Base URL:https://ocpi-api.gridos.co/ocpi/emsp/2.2.1
Overview
PATCH /sessions/{country_code}/{party_id}/{session_id}Absolute URL: https://ocpi-api.gridos.co/ocpi/emsp/2.2.1/sessions/{country_code}/{party_id}/{session_id}
Notify the receiver of partial updates to a Session. Per OCPI 2.2.1 §9.4.3, the body MUST include last_updated (2001 if absent); path country_code/party_id MUST match the body's, when the body carries them (2001 on mismatch).
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 PATCH 'https://ocpi-api.gridos.co/ocpi/emsp/2.2.1/sessions/NL/ABC/SESSION1' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"kwh":14.1,"status":"COMPLETED","end_date_time":"2020-03-09T11:37:32Z","last_updated":"2020-03-09T11:37:32Z"}'Request
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
country_code | string | Yes | ISO-3166 alpha-2 country code (uppercase). |
party_id | string | Yes | CPO/eMSP party ID (ISO-15118, 3 uppercase alphanumerics). |
session_id | string | Yes | Session.id of the Session object. |
Request body
application/json · Required
Schema: SessionUpdate
| Field | Type | Required | Description |
|---|---|---|---|
country_code | string | No | — |
party_id | string | No | — |
id | string | No | — |
start_date_time | string (date-time) | No | — |
end_date_time | string (date-time) | No | — |
kwh | number | No | — |
cdr_token | CdrToken | No | OCPI CdrToken: the token reference embedded in Sessions and CDRs. |
auth_method | `"AUTH_REQUEST" | "COMMAND" | "WHITELIST"` |
authorization_reference | string | No | — |
location_id | string | No | — |
evse_uid | string | No | — |
connector_id | string | No | — |
meter_id | string | No | — |
currency | string | No | — |
charging_periods | object[] | No | — |
total_cost | Price | No | OCPI Price: an amount with and without VAT. |
status | `"ACTIVE" | "COMPLETED" | "INVALID" |
last_updated | string (date-time) | No | — |
Request examples
Example 1
{
"kwh": 14.1,
"status": "COMPLETED",
"end_date_time": "2020-03-09T11:37:32Z",
"last_updated": "2020-03-09T11:37:32Z"
}Example 2
{
"charging_periods": [
{
"start_date_time": "2020-03-10T08:00:00Z",
"dimensions": [
{
"type": "ENERGY",
"volume": 18.75
}
]
}
],
"last_updated": "2020-03-10T08:30:00Z"
}Responses
| Status | Description | Schema |
|---|---|---|
200 | Successful Response | SessionResponse |
400 | Invalid or missing parameters (HTTP 200, OCPI envelope) | — |
401 | Unauthorized | — |
404 | Not Found | — |
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
{
"status_code": 1000,
"status_message": "Success",
"timestamp": "2024-01-15T10:00:00Z",
"data": {
"auth_method": "WHITELIST",
"authorization_reference": "AUTH-REF-001",
"cdr_token": {
"contract_id": "NL-TNM-012345678905880-S",
"country_code": "NL",
"party_id": "TNM",
"type": "RFID",
"uid": "012345678905880"
},
"charging_periods": [
{
"dimensions": [
{
"type": "ENERGY",
"volume": 15.32
}
],
"start_date_time": "2024-01-15T10:00:00Z",
"tariff_id": "TARIFF-001"
}
],
"connector_id": "1",
"country_code": "NL",
"currency": "EUR",
"end_date_time": "2024-01-15T11:30:00Z",
"evse_uid": "3256",
"id": "SESSION-001",
"kwh": 15.32,
"last_updated": "2024-01-15T11:30:00Z",
"location_id": "LOC-001",
"meter_id": "METER-001",
"party_id": "CPO",
"start_date_time": "2024-01-15T10:00:00Z",
"status": "COMPLETED",
"total_cost": {
"excl_vat": 3.064,
"incl_vat": 3.7074
}
}
}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": 2001,
"status_message": "Unauthorized",
"timestamp": "2025-01-01T00:00:00Z"
}404 — not found
application/json
Response example
{
"status_code": 2001,
"status_message": "Session not found",
"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 PATCH 'https://ocpi-api.gridos.co/ocpi/emsp/2.2.1/sessions/NL/ABC/SESSION1' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"kwh":14.1,"status":"COMPLETED","end_date_time":"2020-03-09T11:37:32Z","last_updated":"2020-03-09T11:37:32Z"}'