fleetbase / samsara-api
Vehicle Data Import & Location Integration via Samsara API
Requires
- php: ^8.0
- fleetbase/core-api: *
- php-http/guzzle7-adapter: ^1.0
- psr/http-factory-implementation: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.34.1
- nunomaduro/collision: ^5.11.0|^6.4.0
- pestphp/pest: ^1.22.6
- phpstan/phpstan: ^1.10.38
- symfony/var-dumper: ^5.4.29
This package is not auto-updated.
Last update: 2025-08-28 03:43:38 UTC
README
A comprehensive Fleetbase extension that integrates with the Samsara API for vehicle data import and real-time location tracking. This extension enables fleet operators to seamlessly sync vehicle data from Samsara into their Fleetbase instance, providing unified fleet management capabilities.
Overview
The Samsara Extension bridges the gap between Samsara's fleet management platform and Fleetbase's comprehensive logistics solution. It provides real-time vehicle data synchronization, location tracking, and event processing capabilities that enhance fleet visibility and operational efficiency.
- PHP 8.2 or above
- Ember.js v5.4 or above
- Ember CLI v5.4 or above
- Node.js v18 or above
Key Benefits
- Unified Fleet Management: Manage both Samsara and non-Samsara vehicles within a single Fleetbase interface
- Real-time Location Tracking: Automatic location updates via Samsara webhooks
- Comprehensive Vehicle Data: Import detailed vehicle information including VIN, serial numbers, and metadata
- Multi-tenant Architecture: Secure company-level data isolation
- Role-based Access Control: Granular permissions for different user roles
- Scalable Integration: Handles high-volume webhook events and API calls
Features
Core Functionality
- Vehicle Data Synchronization: Automated import of vehicle information from Samsara
- Real-time Location Updates: Live vehicle tracking via webhook integration
- Credential Management: Secure storage and management of Samsara API credentials
- Event Processing: Comprehensive webhook event handling and logging
- Multi-company Support: Full multi-tenancy with company-level data isolation
Advanced Features
- Scheduled Synchronization: Configurable sync intervals for vehicle data
- Error Handling & Retry Logic: Robust error handling with automatic retry mechanisms
- Health Monitoring: Built-in health checks and sync status monitoring
- Audit Trail: Complete logging of all sync operations and webhook events
- Flexible Linking: Link Samsara vehicles to existing FleetOps vehicles
Structure
├── addon
├── app
├── assets
├── translations
├── config
├── node_modules
├── server
│ ├── config
│ ├── data
│ ├── migrations
│ ├── resources
│ ├── src
│ ├── tests
│ └── vendor
├── tests
├── testem.js
├── index.js
├── package.json
├── phpstan.neon.dist
├── phpunit.xml.dist
├── pnpm-lock.yaml
├── ember-cli-build.js
├── composer.json
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
Installation
Backend
Install the PHP packages using Composer:
composer require fleetbase/core-api composer require fleetbase/samsara-api
Frontend
Install the Ember.js Engine/Addon:
pnpm install @fleetbase/samsara-engine
Configuration
Environment Variables
Add the following environment variables to your .env
file:
# Samsara Extension Configuration SAMSARA_DEFAULT_SYNC_INTERVAL=5 SAMSARA_WEBHOOK_TIMEOUT=30 SAMSARA_API_TIMEOUT=30 SAMSARA_MAX_RETRY_ATTEMPTS=3
Samsara API Credentials
The extension requires Samsara API credentials to function. You can configure these through the Fleetbase console:
- Navigate to FleetOps > Settings > Samsara
- Click Add Credential
- Fill in the required information:
- Name: A descriptive name for the credential set
- API Token: Your Samsara API token
- API Base URL: Usually
https://api.samsara.com
(leave blank for default) - Environment: Select Sandbox or Production
- Sync Interval: How often to sync vehicle data (1-60 minutes)
Webhook Configuration
For real-time updates, configure webhooks in your Samsara dashboard:
- Webhook URL:
https://api.fleetbase.io/int/v1/samsara/webhook/{companyId}
- Events: Select the events you want to receive:
- Vehicle Location Updates
- Vehicle Information Changes
- Alert Events
- Secret: Generate a webhook secret for signature verification
Usage
Basic Vehicle Synchronization
Once configured, the extension automatically synchronizes vehicle data from Samsara. You can also trigger manual synchronization:
- Navigate to FleetOps > Settings > Samsara > Vehicles
- Click Sync All to import all vehicles
- Use the Sync button next to individual vehicles for selective updates
Permissions & Security
The extension implements comprehensive role-based access control with the following permission structure:
Permission Categories
Credential Permissions
samsara view credentials
: View API credentialssamsara create credentials
: Create new credentialssamsara update credentials
: Modify existing credentialssamsara delete credentials
: Remove credentialssamsara test credentials
: Test API connectionssamsara manage credentials
: Activate/deactivate credentials
Vehicle Permissions
samsara view vehicles
: View vehicle data and sync statussamsara create vehicles
: Create new vehicle syncssamsara update vehicles
: Modify vehicle sync settingssamsara delete vehicles
: Remove vehicle syncssamsara sync vehicles
: Trigger manual synchronizationsamsara link vehicles
: Link/unlink vehicles to FleetOpssamsara view location history
: Access vehicle location history
Webhook Permissions
samsara view webhook events
: View webhook events and logssamsara manage webhook events
: Retry events and manage settings
Administrative Permissions
samsara view sync status
: View synchronization statussamsara manage sync
: Trigger syncs and manage settingssamsara admin
: Full administrative access
Predefined Roles
Samsara Viewer
Basic read-only access to view vehicles, credentials, and events.
Samsara Operator
Operational access including vehicle syncing and linking capabilities.
Samsara Manager
Management access including credential management and webhook configuration.
Samsara Administrator
Full administrative access to all extension features.
Usage
Backend
🧹 Keep a modern codebase with PHP CS Fixer:
composer lint
⚗️ Run static analysis using PHPStan:
composer test:types
✅ Run unit tests using PEST
composer test:unit
🚀 Run the entire test suite:
composer test
Frontend
🧹 Keep a modern codebase with ESLint:
pnpm lint
✅ Run unit tests using Ember/QUnit
pnpm test
pnpm test:ember
pnpm test:ember-compatibility
🚀 Start the Ember Addon/Engine
pnpm start
🔨 Build the Ember Addon/Engine
pnpm build
Contributing
See the Contributing Guide for details on how to contribute to this project.
License
This project is licensed under the AGPL-3.0-or-later License. See the LICENSE file for details.
Developed by Fleetbase
For support, please contact support@fleetbase.io or visit our documentation.