Webhooks
Webhooks send real-time HTTP notifications when events occur in your fleet. Receive instant updates for rides, vehicle status changes, customer actions, and more.
Navigation
Access Webhooks from Dashboard > Settings > Webhooks.
Overview
What Webhooks Do
Instead of polling the API, webhooks push updates to you:
Event occurs → Levy sends HTTP POST → Your server receives data
Use Cases
- Real-time dashboards
- External alerting systems
- Data synchronization
- Billing integrations
- Analytics platforms
- Custom notifications
Setting Up Webhooks
Create Webhook Endpoint
- Navigate to Settings > Webhooks
- Click Add Webhook
- Configure:
- Endpoint URL
- Events to receive
- Secret (for verification)
- Click Create
Configuration Options
| Field | Description |
|---|---|
| URL | Your server endpoint |
| Events | Which events to receive |
| Secret | Signature verification key |
| Active | Enable/disable delivery |
URL Requirements
Your endpoint must:
- Use HTTPS
- Return 2xx response
- Respond within 30 seconds
- Accept POST requests
- Handle JSON body
Available Events
Ride Events
| Event | Trigger |
|---|---|
ride.started | Ride begins |
ride.ended | Ride completes |
ride.paused | Ride is paused |
ride.resumed | Ride resumes |
ride.cancelled | Ride cancelled |
Vehicle Events
| Event | Trigger |
|---|---|
vehicle.status_changed | Status update |
vehicle.low_battery | Battery below threshold |
vehicle.offline | Connection lost |
vehicle.zone_enter | Entered zone |
vehicle.zone_exit | Left zone |
Customer Events
| Event | Trigger |
|---|---|
customer.created | New registration |
customer.updated | Profile changed |
customer.blocked | Account blocked |
customer.wallet_updated | Balance changed |
Payment Events
| Event | Trigger |
|---|---|
payment.succeeded | Payment completed |
payment.failed | Payment failed |
refund.created | Refund issued |
IoT Events
| Event | Trigger |
|---|---|
iot.connected | Device online |
iot.disconnected | Device offline |
iot.alarm | Alarm triggered |
Event Payload
Standard Structure
All events include:
{
"id": "evt_abc123",
"type": "ride.ended",
"created": "2025-12-25T10:30:00Z",
"data": {
// Event-specific data
},
"account_id": "acc_xyz789"
}
Example: Ride Ended
{
"id": "evt_abc123",
"type": "ride.ended",
"created": "2025-12-25T10:30:00Z",
"data": {
"ride_id": "ride_456",
"customer_id": "cust_789",
"vehicle_id": "veh_012",
"duration_minutes": 15,
"distance_km": 2.5,
"fare": 5.50,
"start_location": {
"lat": 40.7128,
"lng": -74.0060
},
"end_location": {
"lat": 40.7200,
"lng": -74.0100
}
}
}
Example: Vehicle Status Changed
{
"id": "evt_def456",
"type": "vehicle.status_changed",
"created": "2025-12-25T11:00:00Z",
"data": {
"vehicle_id": "veh_012",
"vehicle_number": "LV-001",
"previous_status": "available",
"new_status": "in_use",
"battery_level": 85,
"location": {
"lat": 40.7128,
"lng": -74.0060
}
}
}
Verifying Webhooks
Signature Verification
Each webhook includes a signature header:
X-Levy-Signature: t=1640000000,v1=abc123...
Verification Steps
- Extract timestamp and signature
- Construct signed payload
- Compute expected signature
- Compare signatures
Example (Node.js)
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const [t, v1] = signature.split(',');
const timestamp = t.split('=')[1];
const sig = v1.split('=')[1];
const signedPayload = `${timestamp}.${payload}`;
const expected = crypto
.createHmac('sha256', secret)
.update(signedPayload)
.digest('hex');
return sig === expected;
}
Timestamp Validation
Prevent replay attacks:
- Check timestamp is recent (< 5 minutes)
- Reject old webhooks
Handling Webhooks
Response Requirements
Your endpoint should:
- Return 200-299 status
- Respond quickly (< 30s)
- Process asynchronously if slow
Retry Policy
Failed deliveries are retried:
| Attempt | Delay |
|---|---|
| 1 | Immediate |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 hours |
After 5 failures, webhook is paused.
Idempotency
Events may be delivered multiple times:
- Use event
idto deduplicate - Make handlers idempotent
- Store processed event IDs
Managing Webhooks
Viewing Webhooks
The Webhooks page shows:
- All configured webhooks
- Event subscriptions
- Delivery status
- Last delivery time
Testing Webhooks
Send test events:
- Click on webhook
- Click Send Test
- Select event type
- View delivery result
Viewing Delivery Logs
See delivery history:
- Timestamp
- Event type
- Response status
- Response body
- Retry attempts
Disabling Webhooks
To pause deliveries:
- Click on webhook
- Toggle Active off
- Events queue (up to 24h)
Deleting Webhooks
To remove:
- Click on webhook
- Click Delete
- Confirm deletion
Event Filtering
By Event Type
Select specific events:
- All events
- Ride events only
- Vehicle events only
- Custom selection
By Subaccount
Filter by location:
- All subaccounts
- Specific subaccounts
- Single subaccount
By Conditions
Advanced filtering:
- Vehicle model
- Status changes
- Threshold values
Best Practices
Endpoint Design
- Use dedicated webhook endpoint
- Return 200 immediately
- Process asynchronously
- Log all deliveries
Error Handling
- Handle malformed payloads
- Verify signatures always
- Implement timeout handling
- Alert on repeated failures
Security
- Use HTTPS only
- Verify signatures
- Validate timestamps
- Use secret rotation
Scalability
- Use message queues
- Handle bursts gracefully
- Scale endpoint as needed
- Monitor latency
Webhook Scenarios
Real-Time Dashboard
Event: ride.started → Update live ride count
Event: ride.ended → Calculate revenue
Event: vehicle.status_changed → Update map
Alert System
Event: vehicle.low_battery → Alert ops team
Event: vehicle.offline → Create ticket
Event: iot.alarm → Trigger notification
Analytics Pipeline
All events → Message queue → Analytics processor → Database
Troubleshooting
Webhooks Not Received
- Verify endpoint is accessible
- Check webhook is active
- Review event selection
- Check server logs
Signature Verification Failed
- Verify secret is correct
- Check payload parsing
- Validate timestamp handling
- Review implementation
Deliveries Failing
- Check endpoint returns 2xx
- Verify response time < 30s
- Review server errors
- Check firewall rules
Duplicate Events
- Implement deduplication
- Use event ID tracking
- Make handlers idempotent
- Check retry timing
Need Help?
For webhook configuration assistance, contact support@levyelectric.com.
Running a fleet on this hardware?
Levy Fleets runs scooters, e-bikes, mopeds and golf carts on the IoT hardware you already have, with integration pages for 29 vendors including Segway, Okai, Omni, Queclink, Invers and Comodule. Keyless unlock, geofencing, rider payments and rider support are included, and the Managed plan is a share of revenue with no per-vehicle software fee.