- Reference
- OCPI 2.2.1 (eMSP)
- Receiver CDRs
OpenAPI reference
Receiver CDRs
/cdrsSend a new CDR to the receiver. Response includes a Location header with the absolute URL to the newly created CDR. Re-POSTing an already-used `id` is always rejected with status_code 2001 (immutabili
API: OCPI 2.2.1 (eMSP) · Module: CDRs (eMSP)
Base path:/cdrs· Base URL:https://ocpi-api.gridos.co/ocpi/emsp/2.2.1
Overview
POST /cdrsAbsolute URL: https://ocpi-api.gridos.co/ocpi/emsp/2.2.1/cdrs
Send a new CDR to the receiver. Response includes a Location header with the absolute URL to the newly created CDR. Re-POSTing an already-used id is always rejected with status_code 2001 (immutability per §3) -- including a byte-for-byte identical retry; there is no idempotent-retry short-circuit, so a client that suspects a delivery failure must GET the CDR by id to check before retrying with the same id. To correct a CDR, post a new one with credit=true and credit_reference_id pointing at the original. Self-reference and crediting an existing credit CDR are rejected.
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 POST 'https://ocpi-api.gridos.co/ocpi/emsp/2.2.1/cdrs' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"country_code":"NL","party_id":"STK","id":"12345","start_date_time":"2015-06-29T21:39:09Z","end_date_time":"2015-06-29T23:37:32Z","session_id":"101","cdr_token":{"country_code":"NL","party_id":"TNM","uid":"100012","type":"RFID","contract_id":"NL-TNM-000100012"},"auth_method":"WHITELIST","cdr_location":{"id":"LOC1","name":"Gent Zuid","address":"F.Rooseveltlaan 3A","city":"Gent","postal_code":"9000","country":"BEL","coordinates":{"latitude":"51.047599","longitude":"3.729944"},"evse_uid":"3256","evse_id":"BE*BEC*E041503003","connector_id":"1","connector_standard":"IEC_62196_T2","connector_format":"SOCKET","connector_power_type":"AC_1_PHASE"},"currency":"EUR","tariffs":[{"country_code":"NL","party_id":"STK","id":"12","currency":"EUR","type":"REGULAR","elements":[{"price_components":[{"type":"TIME","price":2,"step_size":300}]}],"last_updated":"2015-02-02T14:15:01Z"}],"charging_periods":[{"start_date_time":"2015-06-29T21:39:09Z","dimensions":[{"type":"TIME","volume":1.973}],"tariff_id":"12"}],"total_cost":{"excl_vat":4},"total_energy":15.342,"total_time":1.973,"last_updated":"2015-06-29T22:01:13Z"}'Request
Request body
application/json · Required
Schema: CDRCreate
| Field | Type | Required | Description |
|---|---|---|---|
country_code | string | Yes | — |
party_id | string | Yes | — |
id | string | Yes | — |
start_date_time | string (date-time) | Yes | — |
end_date_time | string (date-time) | Yes | — |
session_id | string | No | — |
cdr_token | Cdr Token | Yes | — |
auth_method | `"AUTH_REQUEST" | "COMMAND" | "WHITELIST"` |
authorization_reference | string | No | — |
cdr_location | Cdr Location | Yes | — |
meter_id | string | No | — |
currency | string | Yes | — |
tariffs | object[] | No | — |
charging_periods | object[] | Yes | Charging Periods |
signed_data | object | No | — |
total_cost | Total Cost | Yes | — |
total_fixed_cost | object | No | — |
total_energy | number | Yes | — |
total_energy_cost | object | No | — |
total_time | number | Yes | — |
total_time_cost | object | No | — |
total_parking_time | number | No | — |
total_parking_cost | object | No | — |
total_reservation_cost | object | No | — |
remark | string | No | — |
invoice_reference_id | string | No | — |
credit | boolean | No | — |
credit_reference_id | string | No | — |
home_charging_compensation | boolean | No | — |
last_updated | string (date-time) | Yes | — |
Request examples
Example 1
{
"country_code": "NL",
"party_id": "STK",
"id": "12345",
"start_date_time": "2015-06-29T21:39:09Z",
"end_date_time": "2015-06-29T23:37:32Z",
"session_id": "101",
"cdr_token": {
"country_code": "NL",
"party_id": "TNM",
"uid": "100012",
"type": "RFID",
"contract_id": "NL-TNM-000100012"
},
"auth_method": "WHITELIST",
"cdr_location": {
"id": "LOC1",
"name": "Gent Zuid",
"address": "F.Rooseveltlaan 3A",
"city": "Gent",
"postal_code": "9000",
"country": "BEL",
"coordinates": {
"latitude": "51.047599",
"longitude": "3.729944"
},
"evse_uid": "3256",
"evse_id": "BE*BEC*E041503003",
"connector_id": "1",
"connector_standard": "IEC_62196_T2",
"connector_format": "SOCKET",
"connector_power_type": "AC_1_PHASE"
},
"currency": "EUR",
"tariffs": [
{
"country_code": "NL",
"party_id": "STK",
"id": "12",
"currency": "EUR",
"type": "REGULAR",
"elements": [
{
"price_components": [
{
"type": "TIME",
"price": 2,
"step_size": 300
}
]
}
],
"last_updated": "2015-02-02T14:15:01Z"
}
],
"charging_periods": [
{
"start_date_time": "2015-06-29T21:39:09Z",
"dimensions": [
{
"type": "TIME",
"volume": 1.973
}
],
"tariff_id": "12"
}
],
"total_cost": {
"excl_vat": 4
},
"total_energy": 15.342,
"total_time": 1.973,
"last_updated": "2015-06-29T22:01:13Z"
}Example 2
{
"country_code": "DE",
"party_id": "EMP",
"id": "CDR-98765",
"start_date_time": "2015-07-01T08:00:00Z",
"end_date_time": "2015-07-01T09:10:00Z",
"session_id": "SESSION-456",
"cdr_token": {
"country_code": "DE",
"party_id": "EMP",
"uid": "APP-22",
"type": "APP_USER",
"contract_id": "DE-EMP-C-7788"
},
"auth_method": "AUTH_REQUEST",
"cdr_location": {
"id": "LOC2",
"name": "Central Station Garage",
"address": "Stationsplein 1",
"city": "Utrecht",
"postal_code": "3511AA",
"country": "NLD",
"coordinates": {
"latitude": "52.089444",
"longitude": "5.110278"
},
"evse_uid": "EVSE-UTR-1",
"evse_id": "NL*STK*EUTRECHT01",
"connector_id": "1",
"connector_standard": "IEC_62196_T2",
"connector_format": "SOCKET",
"connector_power_type": "AC_3_PHASE"
},
"currency": "EUR",
"charging_periods": [
{
"start_date_time": "2015-07-01T08:00:00Z",
"dimensions": [
{
"type": "ENERGY",
"volume": 18.75
}
]
}
],
"total_cost": {
"excl_vat": 6.95
},
"total_energy": 18.75,
"total_time": 1.1667,
"last_updated": "2015-07-01T09:10:00Z"
}Responses
| Status | Description | Schema |
|---|---|---|
201 | Successful Response | CdrResponse |
400 | Invalid or missing parameters (HTTP 200, OCPI envelope) | — |
401 | Unauthorized | — |
422 | Validation Error | HTTPValidationError |
201 — successful response
application/json
Schema: CdrResponse
| Field | Type | Required | Description |
|---|---|---|---|
status_code | integer | No | Default: 1000 |
status_message | string | No | — |
timestamp | string (date-time) | No | — |
data | CDROut | No | CDROut |
Response example
{
"status_code": 1000,
"status_message": "Success",
"timestamp": "2024-01-15T10:00:00Z",
"data": {
"auth_method": "WHITELIST",
"authorization_reference": "AUTH-REF-001",
"cdr_location": {
"address": "F.Rooseveltlaan 3A",
"city": "Gent",
"connector_format": "SOCKET",
"connector_id": "1",
"connector_power_type": "AC_3_PHASE",
"connector_standard": "IEC_62196_T2",
"coordinates": {
"latitude": "51.04759",
"longitude": "3.72994"
},
"country": "BEL",
"evse_id": "BE-BEC-E041503001",
"evse_uid": "3256",
"id": "LOC-001",
"name": "Gent Zuid Parking",
"postal_code": "9000"
},
"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"
}
],
"country_code": "NL",
"credit": false,
"currency": "EUR",
"end_date_time": "2024-01-15T11:30:00Z",
"home_charging_compensation": false,
"id": "CDR-001",
"invoice_reference_id": "INV-2024-001",
"last_updated": "2024-01-15T11:30:00Z",
"meter_id": "METER-001",
"party_id": "CPO",
"remark": "Charged at Gent Zuid Parking",
"session_id": "SESSION-001",
"signed_data": {
"encoding_method": "OCMF",
"signed_values": [
{
"nature": "START",
"plain_data": "AP;0;3;...",
"signed_data": "0x1234..."
}
]
},
"start_date_time": "2024-01-15T10:00:00Z",
"tariffs": [
{
"country_code": "NL",
"currency": "EUR",
"elements": [
{
"price_components": [
{
"price": 0.2,
"step_size": 1,
"type": "ENERGY",
"vat": 21
}
]
}
],
"id": "TARIFF-001",
"last_updated": "2024-01-15T10:00:00Z",
"party_id": "CPO"
}
],
"total_cost": {
"excl_vat": 3.064,
"incl_vat": 3.7074
},
"total_energy": 15.32,
"total_energy_cost": {
"excl_vat": 3.064,
"incl_vat": 3.7074
},
"total_fixed_cost": {
"excl_vat": 0.5,
"incl_vat": 0.605
},
"total_parking_cost": {
"excl_vat": 0,
"incl_vat": 0
},
"total_parking_time": 0.25,
"total_reservation_cost": {
"excl_vat": 0,
"incl_vat": 0
},
"total_time": 1.5,
"total_time_cost": {
"excl_vat": 0,
"incl_vat": 0
}
}
}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"
}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 POST 'https://ocpi-api.gridos.co/ocpi/emsp/2.2.1/cdrs' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"country_code":"NL","party_id":"STK","id":"12345","start_date_time":"2015-06-29T21:39:09Z","end_date_time":"2015-06-29T23:37:32Z","session_id":"101","cdr_token":{"country_code":"NL","party_id":"TNM","uid":"100012","type":"RFID","contract_id":"NL-TNM-000100012"},"auth_method":"WHITELIST","cdr_location":{"id":"LOC1","name":"Gent Zuid","address":"F.Rooseveltlaan 3A","city":"Gent","postal_code":"9000","country":"BEL","coordinates":{"latitude":"51.047599","longitude":"3.729944"},"evse_uid":"3256","evse_id":"BE*BEC*E041503003","connector_id":"1","connector_standard":"IEC_62196_T2","connector_format":"SOCKET","connector_power_type":"AC_1_PHASE"},"currency":"EUR","tariffs":[{"country_code":"NL","party_id":"STK","id":"12","currency":"EUR","type":"REGULAR","elements":[{"price_components":[{"type":"TIME","price":2,"step_size":300}]}],"last_updated":"2015-02-02T14:15:01Z"}],"charging_periods":[{"start_date_time":"2015-06-29T21:39:09Z","dimensions":[{"type":"TIME","volume":1.973}],"tariff_id":"12"}],"total_cost":{"excl_vat":4},"total_energy":15.342,"total_time":1.973,"last_updated":"2015-06-29T22:01:13Z"}'