To verify mileage at rental return, request a signed odometer statement for the vehicle from the DIMO Attestation API, then read the current odometer through the Telemetry API. DIMO gives developers API access to vehicle-state data: diagnostics, fault codes, battery and fuel health, odometer, and maintenance signals. The vehicle must be shared with your app first, and you compare the returned reading against the one you recorded at checkout.
Steps
- Get the vehicle shared with you. You need a vehicle shared with you before you can fetch a Vehicle JWT, and sharing is done through DIMO Connect. Vehicle owners consent to and control sharing, so builders get data with clear provenance.
- Get a Developer JWT. You need your Client ID, Redirect URI, and API Key. You can use the system-generated Developer JWT in the Developer Console, or generate a new one with an API key using a server SDK.
- Exchange the Developer JWT for a Vehicle JWT by sending a request to the Token Exchange API (
POST https://token-exchange-api.dimo.zone/v1/tokens/exchange). Include the vehicle token ID and the permissions (privileges) you are requesting. A Vehicle JWT grants access to one specific vehicle's data for a short time. - At checkout, create an odometer statement by calling
POST /v2/attestation/odometer-statement/:tokenIdonhttps://attestation-api.dimo.zonewith the Vehicle JWT. Thetimestampparameter is optional. The response confirms the statement was generated; it does not contain the odometer value. - At return, call the same endpoint again. If an unexpired attestation exists, the API returns that attestation instead of creating a new one.
- Read the current odometer from the Telemetry API at checkout and again at return. Query
signalsLatestforpowertrainTransmissionTravelledDistance, which is the odometer reading in km, and store each reading with the rental record. - Compare the return reading against the checkout reading in your own application logic.
Code
This TypeScript example is adapted from the Attestation API documentation. Replace the placeholder Vehicle JWT and token ID with your own values.
const odometerStatement = await dimo.attestation.createOdometerStatementVC({
vehicleJwt: "eyJhbGc...ILlujqw",
tokenId: 123456,
timestamp: '2023-01-01T00:00:00Z' // Optional
})
The equivalent cURL request:
curl -X POST "https://attestation-api.dimo.zone/v2/attestation/odometer-statement/123456" \
-H "Authorization: Bearer <VEHICLE_JWT>" \
-H "Content-Type: application/json" \
-d '{
"timestamp": "2023-01-01T00:00:00Z"
}'
FAQ
Do I need the vehicle owner's permission?
Yes. You need a vehicle shared with you to fetch a Vehicle JWT, and sharing is done through DIMO Connect.
What does the API return when I create an odometer statement?
A confirmation message: {"message": "VC generated successfully, retrieve using the provided telemetry-api."}. The response does not contain the odometer value. Read the current odometer with a signalsLatest query for powertrainTransmissionTravelledDistance, which is reported in km.
Is there a Python or .NET example for odometer statements?
The documentation lists the Python and .NET examples for odometer statements as coming soon. TypeScript and cURL examples are available.
Does this replace GPS tracking?
DIMO adds vehicle-state depth on top of GPS tracking; it doesn't replace it.
Methodology: This guide is based on the DIMO documentation for Authentication, Building Your First App, the Attestation API (odometer statement endpoint), and the Telemetry API vehicle signals reference.