To track charging sessions on a Tesla Model X, query recharge segments from the DIMO Telemetry API and add the car's charging signals to each segment. On a Tesla Model X (2016 and newer), the Tesla connection (OEM cloud, no hardware) reports charge level in %, session energy in kWh, charging status and charge limit, and DIMO can detect recharge segments for it.
DIMO gives developers API access to vehicle-state data: diagnostics, fault codes, battery and fuel health, odometer, and maintenance signals. Vehicle owners consent to and control sharing, so builders get data with clear provenance. See the full signal list on the Tesla Model X vehicle page. For any other vehicle, see how to track EV charging sessions.
Steps
- Create a Developer License in the Developer Console and note your
Client ID,Redirect URIandAPI Key. - Get the Model X shared with your app. Sharing is done with DIMO Connect, and you need a vehicle shared with you before you can fetch a Vehicle JWT.
- Get a Developer JWT, then exchange it for a Vehicle JWT for that vehicle through the Token Exchange API. Request "All-time, non-location data" (privilege 1) and "All-time location" (privilege 4). The
segmentsquery requires both privileges. - Send the Vehicle JWT in the
Authorizationheader of the Telemetry API, asBearer <Vehicle JWT>. - Call the
segmentsquery withmechanism: rechargeand a range of up to 31 days. Recharge detection uses charging signals and state of charge. - Request extra signal aggregates per segment. For charging, use
powertrainTractionBatteryChargingAddedEnergy(kWh) withMAXfor the highest session energy reading, andpowertrainTractionBatteryStateOfChargeCurrent(%) withFIRSTandLASTfor the charge level change. The level signal at the start and end of a recharge segment is also included by default. - Read
start,end,durationandisOngoingfrom each segment. IfisOngoingis true, the session extends past your query range andendis not returned. - Optionally, call
signalsLatestto read the current charging status withpowertrainTractionBatteryChargingIsCharging, or the power flow withpowertrainTractionBatteryCurrentPower(Battery Power, watts).
Code
This GraphQL query returns recharge segments for one Model X. Replace 12345 with the vehicle's token ID and send your Vehicle JWT in the Authorization header.
query GetChargingSessions {
segments(
tokenId: 12345
from: "2026-11-01T00:00:00Z"
to: "2026-11-07T00:00:00Z"
mechanism: recharge
signalRequests: [
{ name: "powertrainTractionBatteryChargingAddedEnergy", agg: MAX }
{ name: "powertrainTractionBatteryStateOfChargeCurrent", agg: FIRST }
{ name: "powertrainTractionBatteryStateOfChargeCurrent", agg: LAST }
]
limit: 50
) {
start {
timestamp
}
end {
timestamp
}
duration
isOngoing
startedBeforeRange
signals { name agg value }
}
}
When you want to test with your own Model X, pick up a Developer License from the Developer Console and read the authentication guide.
FAQ
Which Model X signals describe a charging session?
The Tesla connection reports charging status, charging cable connected, session energy (kWh), charge limit (%), charging voltage (volts), AC charge current (amps), battery power (watts) and current charge level (%). Use the exact names from the vehicle page when you request them.
Can I tune how recharge sessions are detected?
Yes. The config argument accepts minIncreasePercent for recharge detection (default 15).
How far back can I query?
A single segments request covers a maximum of 31 days. It returns up to 200 segments per request (100 by default), and you can use the after cursor to page through more.
Do I need a Vehicle JWT?
Yes. A Developer JWT does not grant access to vehicle data. Exchange it for a short-lived Vehicle JWT for the specific vehicle.
Methodology: based on the DIMO documentation for Authentication, Building Your First App, and the Telemetry API Segments and Signals references, with car details from the Tesla Model X vehicle page.