> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chargerdojo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom journey examples

> Copy complete OCPI journey manifests to read a CPO charge and CDR, send charging data to an eMSP, or reserve an EVSE and cancel the reservation.

Use these files to test a [charge point operator (CPO) or e-mobility service provider (eMSP)](https://docs.chargerdojo.com/guide/glossary.md#who-the-parties-are)
endpoint. Start with [remote start and stop](https://docs.chargerdojo.com/guide/author-a-scenario.md) if you need to
check your CPO's Commands and Sessions interfaces.

[Register your test endpoint](https://docs.chargerdojo.com/guide/connect-a-partner.md), then select it in **Charging journeys**.
For each file, choose
**Import scenario**, then choose **Use selected endpoint** on **Configure**.
Choose **Preview the plan** to check the steps. Choose **Run journey** and
**Open in Runs** to inspect each exchange under **Journey evidence**.

## Read a Session and CDR from a CPO

Use an OCPI 2.2.1 CPO endpoint with a [Commands Receiver](https://docs.chargerdojo.com/guide/glossary.md#sender-and-receiver) and
Locations, Sessions and CDRs [Sender interfaces](https://docs.chargerdojo.com/guide/glossary.md#sender-and-receiver). ChargerDojo plays the eMSP and reads the
[Session and charge detail record (CDR)](https://docs.chargerdojo.com/guide/glossary.md#what-moves-between-them)
from your CPO.

```json theme={null}
{
  "schemaVersion": 1,
  "journey": "custom",
  "targetId": "replace-with-your-selected-endpoint",
  "roleUnderTest": "CPO",
  "journeyPack": "commands",
  "ocpiVersion": "2.2.1",
  "topology": { "kind": "direct" },
  "clock": { "mode": "real", "durationSeconds": 300 },
  "session": { "cadenceSeconds": 60, "strategy": "put-and-patch", "updates": ["status"] },
  "completion": {},
  "seed": "read-session-and-cdr",
  "actions": [
    {
      "action": "command_post",
      "atSeconds": 5,
      "scenarioIds": ["C01"],
      "values": { "command": "START_SESSION" }
    },
    { "action": "session_get", "atSeconds": 90, "scenarioIds": ["N16"], "values": { "start": 1 } },
    {
      "action": "command_post",
      "atSeconds": 120,
      "scenarioIds": ["C07"],
      "values": { "command": "STOP_SESSION", "start": 1 }
    },
    { "action": "session_get", "atSeconds": 200, "scenarioIds": ["N16"], "values": { "start": 1 } },
    { "action": "cdr_get", "atSeconds": 240, "scenarioIds": ["N16"] }
  ]
}
```

Preview shows a Locations GET, START and its result wait, a Sessions GET, STOP
and its result wait, a second Sessions GET and a CDRs GET. The second Sessions GET
reads the status available at 200 seconds. Schedule the CDRs GET late enough for
your CPO to publish the CDR.

In this OCPI 2.2.1 charging example, open the second Sessions GET in **Journey evidence**.
Find its Session ID in `session_id` on a record returned by the CDRs GET. Compare the
Session's `kwh` with the CDR's `total_energy`. N16 checks the response envelope on each read.

OCPI 2.1.1 CDRs carry the Token reference in `auth_id` and have no `session_id` field.
OCPI 2.2.1 allows a CDR to omit `session_id` if the CPO does not implement Sessions or
the CDR is for a reservation that never became a charging Session.

## Deliver a Session and CDR to an eMSP

Use an OCPI 2.2.1 eMSP endpoint that advertises
Sessions and CDRs [Receivers](https://docs.chargerdojo.com/guide/glossary.md#sender-and-receiver). ChargerDojo plays the CPO and sends a
[Session and charge detail record (CDR)](https://docs.chargerdojo.com/guide/glossary.md#what-moves-between-them)
to that eMSP. Select the Sandbox eMSP if you want to try this without a partner.

```json theme={null}
{
  "schemaVersion": 1,
  "journey": "custom",
  "targetId": "replace-with-your-selected-endpoint",
  "roleUnderTest": "EMSP",
  "journeyPack": "core-charging",
  "ocpiVersion": "2.2.1",
  "topology": { "kind": "direct" },
  "clock": { "mode": "accelerated", "durationSeconds": 300 },
  "session": { "cadenceSeconds": 60, "strategy": "put-and-patch", "updates": ["kwh"] },
  "completion": {},
  "seed": "session-and-cdr",
  "actions": [
    { "action": "session_put", "atSeconds": 0, "scenarioIds": ["S01"] },
    {
      "action": "session_patch",
      "atSeconds": 60,
      "scenarioIds": ["S10", "S11"],
      "values": { "kwh": 1 }
    },
    { "action": "session_complete", "atSeconds": 120, "scenarioIds": ["N16"] },
    { "action": "cdr_post", "atSeconds": 150, "scenarioIds": ["B01"] }
  ]
}
```

Preview shows a Session PUT, a Session PATCH, a final Session PUT and a CDR POST.
The PATCH sends 1 kWh. The final PUT closes the same Session. With no later energy
override, the final Session and CDR both use 1 kWh.

In the report, **S01** checks acceptance of the Session PUT. **S10** and
**S11** check the Session update and PATCH. **N16** checks the OCPI response
envelope on the close. **B01** checks that the eMSP accepts the CDR and returns
the new CDR's URL in the HTTP `Location` header. Compare the Session ID and energy
in the final Session and CDR request bodies.

## Reserve, read the reserved Session, then cancel

Use an OCPI 2.2.1 CPO endpoint with a Commands Receiver and Locations and Sessions
Sender interfaces. The test Location needs an eligible [EVSE](https://docs.chargerdojo.com/guide/glossary.md#what-moves-between-them)
with the `RESERVABLE` capability. See [command names and checks](https://docs.chargerdojo.com/guide/author-a-scenario.md#command-values-and-checks).

```json theme={null}
{
  "schemaVersion": 1,
  "journey": "custom",
  "targetId": "replace-with-your-selected-endpoint",
  "roleUnderTest": "CPO",
  "journeyPack": "commands",
  "ocpiVersion": "2.2.1",
  "topology": { "kind": "direct" },
  "clock": { "mode": "real", "durationSeconds": 180 },
  "session": { "cadenceSeconds": 60, "strategy": "put-and-patch", "updates": ["status"] },
  "completion": {},
  "seed": "reserve-and-cancel",
  "actions": [
    { "action": "command_post", "atSeconds": 5, "scenarioIds": ["C13"], "values": { "command": "RESERVE_NOW" } },
    { "action": "session_get", "atSeconds": 60, "scenarioIds": ["C13"], "values": { "reservation": 1 } },
    {
      "action": "command_post",
      "atSeconds": 90,
      "scenarioIds": ["C13"],
      "values": { "command": "CANCEL_RESERVATION", "reservation": 1 }
    }
  ]
}
```

Preview shows six steps. The Locations GET finds an EVSE before RESERVE.
ChargerDojo waits for the result of each command. The Sessions GET and CANCEL
both use `reservation: 1` because RESERVE is the first entry in `actions`.

In the report, **C13** covers the reservation command exchanges and checks that
an accepted RESERVE creates a Session that carries the RESERVE request's
`authorization_reference` and has status `RESERVATION`. The
[OCPI 2.2.1 SessionStatus enum](https://github.com/ocpi/ocpi/blob/ca8c04c5c8cc10ad1be2a82f61b19377d98e2a67/mod_sessions.asciidoc#mod_sessions_sessionstatus_enum)
defines `RESERVATION` as "The session is started due to a reservation, charging has not yet started."
ChargerDojo also accepts `RESERVED`, the spelling in the Reservation section.
The [Session object](https://github.com/ocpi/ocpi/blob/ca8c04c5c8cc10ad1be2a82f61b19377d98e2a67/mod_sessions.asciidoc#mod_sessions_session_object)
requires the same reference when RESERVE supplies it.

Open the CANCEL request and compare its reservation ID with the one sent by
RESERVE. The CANCEL result shows whether the CPO cancelled it.

See the [manifest field reference](https://docs.chargerdojo.com/guide/journey-manifest-fields.md) for file settings
and the [command values](https://docs.chargerdojo.com/guide/author-a-scenario.md#command-values-and-checks)
for other command forms.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.