> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Samsara REST API

> Client-mode REST API connector for Samsara fleet vehicle stats, assets, and alerts

Technical Preview

## Overview

Client-mode REST API connector for Samsara fleet vehicle stats, assets, and alerts. `BASE_ADDRESS` defaults to `https://api.samsara.com`. Auth: **Bearer API token**. Pass secrets only at runtime via MQTT JSON placeholders or Hub `GET SECRET` — never commit real credentials.

## Auth

Bearer API token. Prefer Hub secrets / `GET SECRET`. Never hard-code tokens into the `.lot`.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}

DEFINE ROUTE SamsaraRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://api.samsara.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
        # Auth: Authorization Bearer {value.json.api_token} — prefer Hub secrets / GET SECRET.
        # Optional Basic: WITH USERNAME "YOUR_USER" / WITH PASSWORD GET SECRET "APP_PASSWORD"
    ADD EVENT Listvehicles
        WITH SOURCE_TOPIC "integrations/samsara/request/Listvehicles"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Listvehicles"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/vehicles"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getvehiclestats
        WITH SOURCE_TOPIC "integrations/samsara/request/Getvehiclestats"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Getvehiclestats"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/vehicles/stats?types={value.json.types}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getvehiclestatsfeed
        WITH SOURCE_TOPIC "integrations/samsara/request/Getvehiclestatsfeed"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Getvehiclestatsfeed"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/vehicles/stats/feed?types={value.json.types}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getvehicle
    # ... additional EVENTs in package .lot ...
```

## MQTT topics

Request topics under `integrations/samsara/request/...`; responses on `integrations/samsara/response/...`.

## Template reference

Generated from the shipped broker template `samsara` (`-routeCode SAMSARA`). It lists every event the template defines.

### Auth

Bearer API token

Auth headers used by the template: `Authorization: Bearer {value.json.api_token}`.

### Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Samsara connector | no |
| `BaseUrl` | string | Samsara base URL without trailing slash (e.g. [https://api.samsara.com](https://api.samsara.com)) | yes |

`BASE_ADDRESS` default: `https://api.samsara.com`.

### Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `Listvehicles` | GET | `/fleet/vehicles` | `integrations/samsara/request/Listvehicles` | `integrations/samsara/response/Listvehicles` | `api_token` |
| `Getvehiclestats` | GET | `/fleet/vehicles/stats?types={value.json.types}` | `integrations/samsara/request/Getvehiclestats` | `integrations/samsara/response/Getvehiclestats` | `api_token`, `types` |
| `Getvehiclestatsfeed` | GET | `/fleet/vehicles/stats/feed?types={value.json.types}` | `integrations/samsara/request/Getvehiclestatsfeed` | `integrations/samsara/response/Getvehiclestatsfeed` | `api_token`, `types` |
| `Getvehicle` | GET | `/fleet/vehicles/{value.json.id}` | `integrations/samsara/request/Getvehicle` | `integrations/samsara/response/Getvehicle` | `api_token`, `id` |
| `Listindustrialassets` | GET | `/industrial/assets` | `integrations/samsara/request/Listindustrialassets` | `integrations/samsara/response/Listindustrialassets` | `api_token` |
| `Listdrivers` | GET | `/fleet/drivers` | `integrations/samsara/request/Listdrivers` | `integrations/samsara/response/Listdrivers` | `api_token` |
| `Listequipment` | GET | `/fleet/equipment` | `integrations/samsara/request/Listequipment` | `integrations/samsara/response/Listequipment` | `api_token` |
| `Listaddresses` | GET | `/addresses` | `integrations/samsara/request/Listaddresses` | `integrations/samsara/response/Listaddresses` | `api_token` |

### Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode SAMSARA"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE SamsaraRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://api.samsara.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Listvehicles
        WITH SOURCE_TOPIC "integrations/samsara/request/Listvehicles"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Listvehicles"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/vehicles"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getvehiclestats
        WITH SOURCE_TOPIC "integrations/samsara/request/Getvehiclestats"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Getvehiclestats"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/vehicles/stats?types={value.json.types}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getvehiclestatsfeed
        WITH SOURCE_TOPIC "integrations/samsara/request/Getvehiclestatsfeed"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Getvehiclestatsfeed"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/vehicles/stats/feed?types={value.json.types}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getvehicle
        WITH SOURCE_TOPIC "integrations/samsara/request/Getvehicle"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Getvehicle"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/vehicles/{value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listindustrialassets
        WITH SOURCE_TOPIC "integrations/samsara/request/Listindustrialassets"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Listindustrialassets"
        WITH METHOD "GET"
        WITH ENDPOINT "/industrial/assets"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listdrivers
        WITH SOURCE_TOPIC "integrations/samsara/request/Listdrivers"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Listdrivers"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/drivers"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listequipment
        WITH SOURCE_TOPIC "integrations/samsara/request/Listequipment"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Listequipment"
        WITH METHOD "GET"
        WITH ENDPOINT "/fleet/equipment"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listaddresses
        WITH SOURCE_TOPIC "integrations/samsara/request/Listaddresses"
        WITH DESTINATION_TOPIC "integrations/samsara/response/Listaddresses"
        WITH METHOD "GET"
        WITH ENDPOINT "/addresses"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

### Usage example

Call `Listvehicles` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'integrations/samsara/response/Listvehicles' &
mosquitto_pub -t 'integrations/samsara/request/Listvehicles' -m '{"api_token": "<api_token>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API apps index](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.