# Charging sub-session ended

A charging sub-session has ended, representing a period of charging in a single mode.

Endpoint: POST charging_sub_session.ended
Version: 2.0
Security: oauth2

## Header parameters:

  - `svix-event-type` (string, required)
    The event type for this webhook, always `charging_sub_session.ended` for this endpoint. This matches the `type` field in the body envelope, so you can route on the header without parsing the body.

  - `svix-id` (string, required)
    Unique identifier for this webhook message. It remains stable across delivery retries of the same event, so receivers can use it to deduplicate.

  - `svix-timestamp` (string, required)
    The time at which this webhook message was dispatched, as a Unix epoch timestamp in seconds.

  - `svix-signature` (string, required)
    Space-separated list of HMAC signatures used to verify that the payload was sent by ev.energy and was not tampered with. See https://docs.svix.com/receiving/verifying-payloads/how for how to verify.

## Request fields (application/json):

  - `type` (string, required)
    The event type. Also delivered in the `svix-event-type` header.
    Enum: "charging_sub_session.ended"

  - `timestamp` (string, required)
    ISO 8601 UTC timestamp for when the event occurred.

  - `data` (object, required)
    The ended charging sub-session, in the same format returned by `GET /v2/charging_sub_sessions/{id}`.

  - `data.url` (string, required)
    Example: https://api.ev.energy/v2/charging_sub_sessions/csub01HSH04KDEWF6Z4DB2J77J74K5

  - `data.vehicle` (any)

  - `data.vehicle.user` (any)
    Defaults to a url, but can be expanded to the full User resource via the `expand` query parameter.
    Example: https://api.ev.energy/v2/users/user01HN2NJ9NMRZBXT1H6FT9N7735

  - `data.vehicle.user.email` (string)

  - `data.vehicle.user.default_location` (any)
    LocationDetail is served when a single user is requested, otherwise Location is served for user lists.

  - `data.vehicle.user.default_location.address_1` (string | null)
    First line of address.

  - `data.vehicle.user.default_location.address_2` (string | null)
    Second line of address.

  - `data.vehicle.user.default_location.postal_code` (string | null)
    Postal Code.

  - `data.vehicle.user.default_location.country_code` (string)
    ISO 3166-1 2 letter Country Codes.
    Enum: "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"

  - `data.vehicle.user.default_location.coordinates` (any)

  - `data.vehicle.user.default_location.coordinates.latitude` (number, required)
    Example: 51.52576576674041

  - `data.vehicle.user.default_location.coordinates.longitude` (number, required)
    Example: -0.08366433371722264

  - `data.vehicle.user.default_location.tariff` (any)

  - `data.vehicle.user.default_location.tariff.url` (string, required)
    Example: https://api.ev.energy/v2/tariffs/tari01HN2NJ9NMRZBXT1H6FT9N7735

  - `data.vehicle.user.default_location.tariff.supplier` (any, required)
    The energy company that supplies this tariff.

  - `data.vehicle.user.default_location.tariff.name` (string, required)
    Example: Fangorn Biomass

  - `data.vehicle.user.default_location.tariff.currency` (string, required)
    Example: GBP

  - `data.vehicle.user.default_location.tariff.highlighted` (boolean)
    A highlighted tariff is one that is often selected by users.

  - `data.vehicle.user.default_location.tariff.type` (string)
    Enum: "FLAT_RATE", "DUAL_RATE", "THREE_RATE", "DYNAMIC", "EXTERNALLY_MANAGED", "OTHER"

  - `data.vehicle.user.default_location.tariff.daily_prices` (object)
    Information about the tariff's prices for different parts of the day.

  - `data.vehicle.user.default_location.tariff.daily_prices.peak` (object, required)
    A single price for a certain time range.

  - `data.vehicle.user.default_location.tariff.timezone_name` (string)
    Example: Europe/London

  - `data.vehicle.user.default_location.tariff.price_chart_url` (string | null)
    The url of a website which can display a chart of prices for the tariff. This website is an external resource and is not affiliated with ev.energy.
    Example: https://www.example.com/

  - `data.vehicle.user.default_location.tariff.gsp_group` (string | null)
    The GB Grid Supply Point (DNO region) the tariff applies to. Suppliers publish region-specific rates, so the same named tariff can appear once per region with differing prices; this field distinguishes them. `null` for tariffs that are not region-specific.
    Example: _C

  - `data.vehicle.user.default_location.tariff.valid_from` (string)
    The date from which this tariff became available to new customers.
    Example: 2026-03-17

  - `data.vehicle.user.default_location.tariff.valid_until` (string | null)
    The date after which this tariff is no longer available to new customers (it has been superseded). `null` if the tariff is still open to new sign-ups. Use the `valid` query parameter to filter the list to only currently-available tariffs.
    Example: 2027-03-17

  - `data.vehicle.user.default_location.tariff.scheduler_tariff` (any)
    The tariff used by the scheduler for charge optimisation, which may differ from the billing tariff. Returns a URL by default, or null if not set. Expandable with ?expand=scheduler_tariff to return a TariffBase object (additional fields may be present beyond those listed here).

  - `data.vehicle.user.default_location.city` (string | null)

  - `data.vehicle.user.default_location.state` (string | null)

  - `data.vehicle.user.default_location.evse_site` (any)
    If null, the user's location is not an EVSE Site. Otherwise, this field references the site they are a part of.

  - `data.vehicle.user.default_location.evse_site.cpms_connection_display_name` (string | null)
    A human-readable name for the Chargepoint Management System that the site is connected to.
    Example: ChargePoint

  - `data.vehicle.user.default_location.current_carbon_intensity_grams_per_kilowatt_hour` (integer | null)
    The current carbon intensity associated with the location in gCO2/kWh.
    Example: 300

  - `data.vehicle.latest_status_log` (any)
    An expandable reference to the most recent status log for this Vehicle. This can be requested or expanded to get the most accurate information we have on the device's current status.
    Example: https://api.ev.energy/v2/vehicles/vhcl01HRFF3SEVSCRAV9B3CHVDFN0H/status_logs/2024-04-17T09:39:45.994584Z/

  - `data.vehicle.latest_status_log.sampled_at` (string)
    The date and time when this data was recorded. Likely to be earlier than `logged_at`, but how much earlier depends on the integration and other factors.

  - `data.vehicle.latest_status_log.vehicle` (any)

  - `data.vehicle.latest_status_log.charge_rate_watts` (integer | null)
    The current rate of charge being received, in watts. Will be null if we are unable to get this information from the Vehicle integration.

  - `data.vehicle.charging_sub_sessions` (string)
    Provides a pre-constructed URL to list charging sub-sessions involving this Vehicle.
    Example: https://api.ev.energy/charging_sub_sessions/?vehicle_id=vhcl01HRFF3SEVSCRAV9B3CHVDFN0H

  - `data.vehicle.battery_size_watt_hours` (integer, required)
    The nominal battery capacity of the vehicle in watt-hours according to the vehicle integration or trim. Editable via PATCH only for unintegrated vehicles; sending it for an integrated vehicle is rejected. Setting it flags the battery size as user-provided. Stored to the nearest 0.01 kWh (10 Wh), so the value read back may be rounded.
    Example: 60000

  - `data.vehicle.maximum_charge_limit_percentage` (integer, required)
    The target state of charge of the car as a percentage between 50 and 100. The car will not be smart charged above this value. Can be null if target charge level has not been set or we don't know the car's battery size.

  - `data.vehicle.smart_charging_enabled` (boolean, required)
    Whether smart (dynamic) charging is enabled for this vehicle.
    Example: true

  - `data.vehicle.vehicle_class` (string | null, required)
    Class of vehicle, passenger or commercial.
    Enum: "PASSENGER", "COMMERCIAL", null

  - `data.evse` (any)

  - `data.evse.location` (object | null)
    The geographic location of the EVSE as a latitude/longitude point.
**Why smart charging needs it:** the location tells ev.energy which electricity grid the charger sits on, which drives the core smart-charging decisions:
- **Carbon optimisation** — selects the local carbon-intensity feed so charging is shifted to the lowest-carbon periods.
- **Timezone** — resolves the charger's timezone so time-of-day charging schedules and tariff windows are applied in local time.
- **Programs and solar** — determines the eligible grid/demand-response programs and the relevant solar forecast.

Without an accurate location the scheduler cannot reliably optimise charging for cost and carbon.
**When it is set:** during commissioning, where the supplied postcode/address is geocoded to a latitude/longitude (or, for app-linked chargers, copied from the owner's home location). It can be corrected later via `PATCH`. Null when the location has not yet been determined.
    Example: {"latitude":51.5074,"longitude":-0.1278}

  - `data.evse.location.latitude` (number, required)
    Example: 51.5074

  - `data.evse.location.longitude` (number, required)
    Example: -0.1278

  - `data.evse.charging_sub_sessions` (string)
    Provides a pre-constructed URL to list charging sub-sessions involving this EVSE.
    Example: https://api.ev.energy/charging_sub_sessions/?evse_id=evse01HSH04KDEWF6Z4DB2J77J74K5

  - `data.location` (object, required)

  - `data.location.postal_code` (string | null)

  - `data.location.address_1` (string | null)

  - `data.location.timezone` (string | null)
    IANA timezone name for the charging location.
    Example: Europe/London

  - `data.total_co2_grams` (integer | null, required)
    Estimated total CO2 emissions of this sub-session in grams

  - `data.co2_intensity_grams_per_kilowatt_hour` (integer | null, required)
    Estimated CO2 emissions per unit of electricity in grams per kilowatt hour

  - `data.cost_per_kilowatt_hour` (integer | null)
    Average cost per kilowatt hour of energy delivered during this charging sub-session

  - `data.total_points` (integer)
    Number of smart points earned during this charging sub-session

  - `data.total_points_missed` (integer | null)
    Difference between the number of smart points earned in this sub-session and the number that would have been earned by Smart charging

  - `data.duration_minutes` (integer, required)
    How long the vehicle was actively charging for, to the nearest minute. This can be much shorter than the gap between start and end, and does not tell you when within the sub-session energy was delivered — use the energy_usage endpoint for that.

  - `data.energy_usage` (any)
    A link to more detailed information about energy usage during the charging sub-session, including the intervals in which energy was actually delivered to the vehicle. Can be expanded.

  - `data.energy_usage.last_updated_at` (string)
    The datetime when the energy usages were last updated at.

