Session Lifecycle

End-to-end charging session flow through ChargeIndia Hub.

This page describes the complete session path from authorization through CDR delivery.

Sequence diagram

sequenceDiagram
  participant eMSP
  participant Hub as ChargeIndia Hub
  participant CPO
  eMSP->>Hub: PUT tokens/.../authorize
  Hub->>CPO: PUT tokens/.../authorize
  CPO-->>Hub: ALLOWED
  Hub-->>eMSP: ALLOWED
  eMSP->>Hub: POST commands/START_SESSION
  Hub->>CPO: POST commands/START_SESSION
  CPO-->>Hub: ACCEPTED + callback
  Hub-->>eMSP: ACCEPTED (via response_url)
  CPO->>Hub: PUT sessions/... (ACTIVE)
  Hub->>eMSP: PUT sessions/... (async push)
  eMSP->>Hub: POST commands/STOP_SESSION
  Hub->>CPO: POST commands/STOP_SESSION
  CPO->>Hub: PUT sessions/... (COMPLETED)
  Hub->>eMSP: PUT sessions/... (async push)
  CPO->>Hub: POST cdrs
  Hub->>eMSP: POST cdrs (async push)

Step-by-step

1. Token authorization

The eMSP authorizes the driver's token before charging:

eMSP → Hub: PUT /ocpi/2.2.1/tokens/{emsp_cc}/{emsp_pid}/{token_uid}/authorize
Hub → CPO:  PUT /ocpi/2.2.1/tokens/{emsp_cc}/{emsp_pid}/{token_uid}/authorize

The CPO responds with ALLOWED, BLOCKED, NOT_ALLOWED, or UNKNOWN. The Hub returns this to the eMSP.

2. Start session

The eMSP sends a remote start command:

eMSP → Hub: POST /ocpi/2.2.1/commands/START_SESSION
Hub → CPO:  POST /ocpi/2.2.1/commands/START_SESSION

Required fields:

  • response_url — where async results are delivered (Hub rewrites CPO callback)
  • token — driver token object
  • location_id, evse_uid, connector_id — target charge point

3. Session becomes active

The CPO pushes session state to Hub:

CPO → Hub: PUT /ocpi/2.2.1/sessions/{cpo_cc}/{cpo_pid}/{session_id}

The session must include cdr_token identifying the eMSP. The Hub asynchronously pushes to the eMSP:

Hub → eMSP: PUT /ocpi/2.2.1/sessions/{cpo_cc}/{cpo_pid}/{session_id}

4. Stop session

The eMSP sends stop:

eMSP → Hub: POST /ocpi/2.2.1/commands/STOP_SESSION

Include session_id in the command body.

5. Session completed

The CPO pushes final session state (COMPLETED) to Hub, which forwards to eMSP asynchronously.

6. CDR delivery

The CPO posts the CDR:

CPO → Hub: POST /ocpi/2.2.1/cdrs
Hub → eMSP: POST /ocpi/2.2.1/cdrs (async)

Required fields summary

FieldSet byPurpose
cdr_token.country_codeCPO on session/CDRRoutes async delivery to eMSP
cdr_token.party_idCPO on session/CDRRoutes async delivery to eMSP
response_urleMSP on commandAsync command result delivery
session_idCPO / command flowLinks stop command to active session

Timing expectations

PathTypeTarget latency
Token authorizeRealtimeSynchronous (CPO response time)
CommandsRealtime + asyncImmediate accept/reject; async result via callback
SessionsAsync pushp95 < 5 seconds (Hub → eMSP)
CDRsAsync pushp95 < 5 seconds (Hub → eMSP)

See Async Delivery for retry behavior.

Common failures

FailureCause
Authorization UNKNOWNCPO unreachable or token not recognized
Command REJECTEDEVSE unavailable, invalid location, or routing not configured
Session not received by eMSPMissing cdr_token or eMSP receiver URL not configured
CDR not receivedSame as session — check cdr_token and receiver URL

Related docs