Documentation Index
Fetch the complete documentation index at: https://samsara-showcase.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
What are we building?
This guide will describe how to capture route stop task completions by:- Configuring a document submission webhook notification
- Retrieving the full document object using the Documents API
Configure a Document Submission Webhook Notification
See the Webhooks guide for details on how to create a webhook. Specifically, you’ll want to configure a Document Submission alert to send to the webhook. Once you’ve configured the webhook and the alert, you’ll receive a JSON payload like the following whenever a document is submitted:driver object in the webhook payload contains an id field, which is the driver ID you’ll need to retrieve the full document object.
The document ID is located in the details field of the webhook payload, and always has the following structure:
A {documentTemplateName} document was submitted by {driverName} at {submissionTime}. Document: {documentUrl} (ID: {documentId})
You can use regex or other string operations to extract the document ID from this field.
Retrieve the Document
Once you’ve extracted the document ID from the webhook notification, you can use Fetches a document API to retrieve the full document object. TheGET /v1/fleet/drivers/{driver_id}/documents/{document_id} endpoint allows you to retrieve the document object using the driver ID and document ID collected from the webhook notification payload.
For example, using the payload above, you would perform the following GET request:
Associating a Document with a Stop
ThedispatchJobId field of the document will tell you which route stop this document was submitted at.
Alternative Strategies
In addition to capturing stop task completion via webhook handling, you can Track Route Progress and Fetch the route when a desired state change occurs (such as a stop moving into thedeparted state).
When you fetch the route, the each stop in the stops array will include a documents array, listing the documents (stop tasks) associated with that stop. You can then Fetch the document using its id.