Guest organisation
OCPI
Learn reference
Guest organisation
OCPI
Learn reference

Order the charging session messages

By Abhishek Uniyal · Updated

Step 6 of 11

OCPI 2.2.1

Compare versions

This authored OCPI flow follows one card-started charging session. Order the messages between the CPO and eMSP, then compare the record held by each platform.

What changes in OCPI 2.2.1
Modules in OCPI 2.2.1
Sessions
CDRs
Locations
Tariffs
Tokens
Commands
Credentials
Versions
Hub Client Info
Charging Profiles
Payments · extension
Advertised sender and receiver interfaces

An endpoint declares how another platform can pull or push data. Credentials uses the same interface for both roles.

The header token is encoded

The request header carries an encoded token; the Credentials body still carries the raw token.

Billing records name the Token owner

A charge record names the country and company that own the driver's Token.

Which OCPI messages are exchanged?

  1. CPOeMSP

    Real-time authorization

    POST/tokens/{token_uid}/authorize

    When the eMSP has its Tokens authorized in real time, the CPO asks the eMSP whether a Token may charge, optionally at a given Location. The eMSP answers with an AuthorizationInfo object, and ALLOWED means the Token may charge.

    Response

    {"status_code": 1000, "data": {"allowed": "ALLOWED", "token": {…}}, "timestamp": "2026-10-16T09:30:00Z"}
    Sources (6)
    "An eMSP might want their Tokens to be authorized 'real-time', not white-listed. For this the eMSP has to implement the POST Authorize request and set the Token.whitelist field to `NEVER` for Tokens they want to have authorized 'real-time'."OCPI 2.2.1 Tokens module · #mod_tokens_real-time_authorization"Do a 'real-time' authorization request to the eMSP system, validating if a Token might be used (at the optionally given Location)."OCPI 2.2.1 Tokens module · #mod_tokens_post_method"When the token is known by the Sender, the response SHALL contain a AuthorizationInfo object. If the token is not known, the response SHALL contain the status code: `2004: Unknown Token`, and no `data` field."OCPI 2.2.1 Tokens module · #mod_tokens_post_response_dataALLOWED: This Token is allowed to charge (at this location).OCPI 2.2.1 Tokens module · #mod_tokens_allowed_enum"OCPI status code, as listed in Status Codes, indicates how the request was handled. To avoid confusion with HTTP codes, OCPI status codes consist of four digits."OCPI 2.2.1 Transport and format chapter · #transport_and_format_response_format1000: Generic success codeOCPI 2.2.1 Status codes chapter · #status_codes_1xxx_success
  2. CPOeMSP

    New Session

    PUT/sessions/{country_code}/{party_id}/{session_id}

    The CPO pushes the Session it just created to the eMSP's Sessions endpoint.

    Response

    {"status_code": 1000, "timestamp": "2026-10-16T09:30:00Z"}
    Sources (2)
    "When the CPO creates a Session object they push it to the corresponding eMSP by calling PUT on the eMSP's Sessions endpoint with the newly created Session object."OCPI 2.2.1 Sessions module · #mod_sessions_push_model"We also advise that in such cases, platform sending the response leave the `data` field unset in the response format. This applies for example to PUT requests when pushing Session objects, and PATCH requests to add charging periods to Sessions."OCPI 2.2.1 Transport and format chapter · #transport_and_format_response_format
  3. CPOeMSP

    Session update

    PATCH/sessions/{country_code}/{party_id}/{session_id}

    In OCPI 2.2.1 and 2.3.0 the CPO sends every change to a Session it already pushed by calling PATCH on the eMSP's Sessions endpoint. Only the fields that need to be updated have to be present, and any field it does not specify is considered unchanged. Every PATCH request SHALL contain last_updated.

    Response

    {"status_code": 1000, "timestamp": "2026-10-16T09:30:00Z"}
    Sources (3)
    "Any changes to a Session in the CPO system are sent to the eMSP system by calling PATCH on the eMSP's Sessions endpoint with the updated Session object."OCPI 2.2.1 Sessions module · #mod_sessions_push_model"Same as the PUT method, but only the fields/objects that need to be updated have to be present. Fields/objects which are not specified are considered unchanged."OCPI 2.2.1 Sessions module · #mod_sessions_patch_method"Any request to the PATCH method SHALL contain the `last_updated` field."OCPI 2.2.1 Sessions module · #mod_sessions_patch_method
  4. CPOeMSP

    Session update: status COMPLETED

    PATCH/sessions/{country_code}/{party_id}/{session_id}

    When the Session has finished, the CPO sends the change with PATCH and sets its status to COMPLETED, the final status of a Session. Sessions cannot be deleted.

    Response

    {"status_code": 1000, "timestamp": "2026-10-16T09:30:00Z"}
    Sources (2)
    "Any changes to a Session in the CPO system are sent to the eMSP system by calling PATCH on the eMSP's Sessions endpoint with the updated Session object."OCPI 2.2.1 Sessions module · #mod_sessions_push_model"Sessions cannot be deleted, final status of a session is: `COMPLETED`."OCPI 2.2.1 Sessions module · #mod_sessions_push_model
  5. CPOeMSP

    Charge detail record (CDR)

    POST/cdrs

    The CPO pushes the new CDR to the eMSP's CDRs endpoint with POST. The eMSP answers with a Location header holding the URL of the new CDR. A CDR cannot be changed once it is sent.

    Response

    Location: https://www.server.com/ocpi/emsp/2.2.1/cdrs/123456{"status_code": 1000, "timestamp": "2026-10-16T09:30:00Z"}
    Sources (3)
    "When the CPO creates CDR(s) they push them to the relevant eMSP by calling POST on the eMSPs CDRs endpoint with the newly created CDR(s)."OCPI 2.2.1 CDRs module · #mod_cdrs_push_model"The response should contain the URL to the just created CDR object in the eMSP's system."OCPI 2.2.1 CDRs module · #mod_cdrs_response_headers"Because a CDR is for billing purposes, it cannot be changed or replaced once sent to the eMSP. Changes are simply not allowed."OCPI 2.2.1 CDRs module · #mod_cdrs_flow_and_lifecycle