Signal data delivery when trigger conditions are met
Triggered when one or more signals you’ve configured as triggers change their value. This event delivers the updated signal data for all subscribed signals in the payload.
All Configured Signals Are Always IncludedEvery VEHICLE_STATE event contains all signals you configured in your webhook subscription, regardless of which signal(s) triggered the event. This ensures you always have complete vehicle state data.Example: If your webhook subscribes to 10 signals but only 1 trigger changes, you’ll receive all 10 signals in the payload.
The webhook payload includes a triggers field that specifies which trigger signal(s) changed to prompt this delivery. This helps you identify what caused the event without comparing all signal values.
If multiple triggers change simultaneously, all will be included in the array.
First Delivery Trigger
When a webhook subscription is first created, a FIRST_DELIVERY trigger is sent to provide the initial state of the vehicle.
Report incorrect code
Copy
Ask AI
{ "triggers": [ { "code": "FIRST_DELIVERY" } ]}
This initial delivery:
Occurs after vehicle subscription to a webhook
Contains all subscribed signals at their current values
Does not indicate any signal value changes
Helps establish baseline state for your application
When FIRST_DELIVERY is sent again:
When a vehicle is unsubscribed and then resubscribed to your webhook
If your endpoint fails to respond with a 2xx status code, Smartcar will retry delivery with the same FIRST_DELIVERY trigger
Use the triggers field to determine the delivery reason. Check for "code": "FIRST_DELIVERY" to identify initial state deliveries versus change-triggered deliveries.
Array of signal objects containing data for all signals configured in your webhook subscription. This array always includes every subscribed signal, even if only one trigger changed to fire this event.
Individual signals within a VEHICLE_STATE payload can contain errors if the vehicle doesn’t support that signal or if retrieval fails. When this occurs, the signal will have a status object with error details instead of a body with data:
Partial data delivery: When some signals succeed and others fail, you’ll receive a VEHICLE_STATE event with successful signals containing body data and failed signals containing status errors. This allows you to process available data even when some signals are unavailable.
function handleVehicleState(payload) { const { vehicleId, data } = payload; const { signals, triggers } = data; // Check if this is first delivery const isFirstDelivery = triggers.some(t => t.code === 'FIRST_DELIVERY'); // Process each signal signals.forEach(signal => { if (signal.body) { // Signal has data console.log(`${signal.name}: ${JSON.stringify(signal.body)}`); updateDatabase(vehicleId, signal.code, signal.body); } else if (signal.status) { // Signal has error console.error(`${signal.name} error: ${signal.status.error.code}`); handleSignalError(vehicleId, signal); } });}