- Reference
- OCPI 2.2.1 (CPO)
- Sender ChargingPreferences
OpenAPI reference
Sender ChargingPreferences
/sessions/{session_id}/charging_preferencesSet charging preferences on an ongoing session. **This CPO does not implement smart charging** and advertises no `CHARGING_PREFERENCES_CAPABLE` EVSE, so per OCPI 2.2.1 §9.2.2 every request is answered
API: OCPI 2.2.1 (CPO) · Module: Sessions (CPO)
Base path:/sessions· Base URL:https://ocpi-api.gridos.co/ocpi/cpo/2.2.1
Overview
PUT /sessions/{session_id}/charging_preferencesAbsolute URL: https://ocpi-api.gridos.co/ocpi/cpo/2.2.1/sessions/{session_id}/charging_preferences
Set charging preferences on an ongoing session. This CPO does not implement smart charging and advertises no CHARGING_PREFERENCES_CAPABLE EVSE, so per OCPI 2.2.1 §9.2.2 every request is answered with OCPI status_code 2001 (the spec's not-capable response). The gateway logs a compliance warning if it ever observes a session whose EVSE does advertise that capability.
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/cpo/2.2.1/sessions/SESSION1/charging_preferences' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"profile_type":"CHEAP","departure_time":"2020-03-10T18:00:00Z"}'Request
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | Session.id of the Session object. |
Request body
application/json · Required
Schema: ChargingPreferences
| Field | Type | Required | Description |
|---|---|---|---|
profile_type | `"CHEAP" | "FAST" | "GREEN" |
departure_time | string (date-time) | No | — |
energy_need | number | No | — |
discharge_allowed | boolean | No | — |
Request examples
Example 1
{
"profile_type": "CHEAP",
"departure_time": "2020-03-10T18:00:00Z"
}Example 2
{
"profile_type": "GREEN"
}Responses
| Status | Description | Schema |
|---|---|---|
200 | Successful Response | ChargingPreferencesResultResponse |
400 | Invalid or missing parameters (HTTP 200, OCPI envelope) | — |
401 | Unauthorized | — |
422 | Validation Error | HTTPValidationError |
200 — successful response
application/json
Schema: ChargingPreferencesResultResponse
| Field | Type | Required | Description |
|---|---|---|---|
status_code | integer | No | Default: 1000 |
status_message | string | No | — |
timestamp | string (date-time) | No | — |
data | `"ACCEPTED" | "DEPARTURE_REQUIRED" | "ENERGY_NEED_REQUIRED" |
Response example
{
"status_code": 1000,
"status_message": "Success",
"timestamp": "2024-01-15T10:00:00Z",
"data": "ACCEPTED"
}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 PUT 'https://ocpi-api.gridos.co/ocpi/cpo/2.2.1/sessions/SESSION1/charging_preferences' \
-H "Authorization: Token $OCPI_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"profile_type":"CHEAP","departure_time":"2020-03-10T18:00:00Z"}'