Replicating Vehicles

Vehicles Object Details

Endpoint: GET https://api.samsara.com/fleet/vehicles

Schema: this is a minimum set of fields we suggest replicating, however you can remove/add data based on the data you see in the API documentation

  • id
  • name
  • vin
  • createdAtTime
  • updatedAtTime

Primary Key: id

Step 1 - Backfilling

Call the endpoint and create records for every objects in the response. If there is more than one page, be sure to implement pagination in order to get through all the data.

Step 2 - Consuming New Data and Changes

Every 24 hours, query the endpoint with the updatedAfterTime parameter set to 24 hours from the current time. Then, paginate through all objects returned. Update existing records if it is a change to an existing objects, otherwise create a new record for a new vehicle object that has been added

Step 3 - Remove Deleted Objects (Optional)

There currently isn't a way to consume specific deletion events. The best alternative is to wipe your table and recreate it following Step 1 at a regular cadence. This way, you will be inherently removing deleted vehicle objects.