In this article you will learn all of the options for data can be shared between Onfleet and other systems you may be using for your delivery operations.
The Onfleet API is a RESTful web service for developers to programmatically interact with Onfleet's data and real-time delivery management functionality. The complete API documentation is available here. Onfleet also offers additional open-source tooling regarding integrations via the Onfleet API, for more details, please visit our open-source developer repository.
Note: Full API access is only available in the Basic plan and above. For more info about Onfleet's plans, visit our pricing page.
All requests must be authenticated using one of your organization’s API keys. Your organization's administrator can create and maintain API keys through the "API & Webhooks" tab in their dashboard settings.
Add API Keys
Simply click the + button at the bottom of the API Keys section to create an API key registered with your organization.
Webhooks are an advanced feature that allows organizations to be notified as soon as special trigger conditions are met, via an HTTP POST to the URL specified.
To view Onfleet's API and Webhook documentation please go here.
Manage or create webhooks from the Onfleet Dashboard, by logging in as the admin user and navigating to the API & Webhooks tab in Settings.
To create a new webhook:
1. Click the + button under Webhooks
2. (optional) Label the webhook with a distinctive name
3. Choose from one of 13 webhook triggers:
- Task started
- Driver ETA less than or equal to X seconds
- Driver arriving, at or closer than X meters
- Task completed
- Task failed
- Driver status changed
- New task created
- Task updated
- Task deleted
- Task assigned
- Task unassigned
- Task delay time is greater than or equal to X seconds
- Task cloned
- SMS Recipient Response Missed
4. Enter the URL where webhooks updates should be pushed
5. Validate and create the webhook
To ensure ownership of the URL used, Onfleet requires validation before the webhook is enabled.
The URL value provided will receive a GET request from our servers, with a check query parameter. You need to respond to our validation request with exactly this value, untouched, as a simple string response. See the Create a Webhook documentation for code examples. To get started quickly with Onfleet webhooks, feel free to use the webhooks tool from our open-source repository which creates webhook endpoints for you.
Note: Zapier and RequestBin URLs are whitelisted and are automatically validated.
As an additional security measure, Onfleet will automatically generate a Webhook secret to ensure the request received by your webhook URL is from Onfleet. The Webhook secret can be found under the "API & Webhooks" section of the admin settings by selecting "Show Secret".
For more information on Webhook authentication please go here.
Zapier is a third-party tool that lets you easily connect the web apps you use, making it easy to automate tedious tasks.
Onfleet's Zapier integration allows you to create tasks from virtually any source, with full support for coordinate-based destinations, task linking, auto-assignment, and more. To access our public Zapier app, find us here, or click on any of the Zap Templates below to dive right in!
In this video, you can see an example of how to utilize Zapier to integrate Onfleet with Slack and create automated messages based on various actions happening within your dashboard:
Here is a list of Zapier errors that may have caused your zap to fail.
Besides an Onfleet zap, you can also utilize Onfleet webhook functionality to create a zap for timely notifications. This utilizes Webhooks by Zapier as the trigger, which allows for customizable, automated email notifications.
Zapier Webhook Integration 101
Zapier allows for easy integration between Onfleet and other useful web applications, making task creation and other Onfleet automation a breeze with very little to no engineering effort.
Webhooks by Zapier is a Zapier step that allows you to capture messages that are sent from an app when something happens. You can then use Webhooks by Zapier as a trigger step to automate other actions, for example: sending a message to the admin email/a Slack channel or saving data to Google Sheets when an Onfleet event happens for archival purposes.
Get Started with Webhooks
- Go to Zapier and attempt to make a zap
- Search for "webhooks" and select "Webhooks by Zapier"
As "Webhooks by Zapier" connects to 1000+ apps, we will only list out a few popular options. Feel free to reach out to Onfleet Support if you wish to explore new possibilities!
Connecting Onfleet to Zapier Webhooks
- Scroll or search for an app that you wish to connect to "Webhooks by Zapier" as an action step. Sample apps to choose from: Slack, Gmail, Google Sheets, Twilio (for phone call and SMS), or a plain simple email.
- Once selected, you will need to set up the catch hook for it to receive a sample webhook data. Zapier will generate a URL for your webhook, this is where Onfleet will send the event updates to. Copy this URL and paste it on your Onfleet settings -> API & Webhooks -> Create a new webhook. Don't click on "OK, I did this" just yet, we will cover this part in a bit!
Copy and paste the Zapier-generated webhook URL onto a new Onfleet webhook
This will enable Onfleet to send an event update of your choice over to Zapier as the trigger. By the time you reach this section, you're halfway there!
Simulating an Event Trigger
In order for the "Webhooks by Zapier" app to pull sample data, you will need to simulate a trigger of your interest after creating the webhook. The list of Onfleet webhooks is listed in the webhook documentation.
Assuming you want your trigger to be "Task started", simply create a task and start a task after creating the webhook. Same goes if you want your trigger to be "Task deleted", you should simulate deleting a task once the webhook is created.
Once you've simulated an event, go back to your Zap and click on "OK, I did this". The webhook will then pull the simulated event into a list of hooks for you as shown:
Here you will see the details of the simulated event with a trigger name of taskCreated, this "Payload" is what you can work off of, setting up filters and conditions before performing follow up actions.
Setting up Actions
As an example, I'm going to set up an automated email when my event is triggered. Once the webhook sample is selected, the webhook actions can now pull in all the information from the payload.
By clicking on the + button next to each field, you can search through the payload to find the data that you want to utilize in your automation. For example, I've parsed out the destination address and the taskID into the body of the email.
The last step would be testing out the event actions, follow the steps accordingly to send a test email to your recipient of interest.
Additional Action Steps (Optional)
For business purposes, one may opt-in to add additional steps to the webhook. To do so, simply go to your Zapier dashboard and select your zap. On the left panel, you can add a step in between the trigger and the action or even after the 1st action.
Sample additional action steps include filters, delays, data formatter, or even another application zap. Click on the + sign to learn more about what Zapier offers.
Note: Remember to trigger a sample event when you update your integration, this ensures that you are pulling in the desired and up-to-date payload.
You can connect Onfleet to your Shopify account via a simple Zapier integration, allowing you to automatically convert orders into tasks and auto-assign to drivers.
To access our public Zapier app listing, please follow this link.
To set up a Shopify integration, log in to Zapier and click Make a New Zap. From the Choose a Trigger app... drop-down menu, select Shopify.
From the Choose an Action app... drop-down menu, select Onfleet. In order to automatically create a delivery task when an order is placed in Shopify, choose New Paid Order from the available triggers and Create Task as the resulting action in Onfleet.
Select your Shopify Account from the available options or connect it via the Connect a different Shopify account tab. In order to connect your account, you will need to enter your Shopify username. To make sure that your account works properly, try to test it using the Test this Account button on the right hand side.
Then, select your Onfleet Account from the available options or connect it via the Connect a different Onfleet account tab. In order to connect your account, you will need to enter your Onfleet API key. Once again, to make sure that your account works properly, try to test it using the Test this Account button on the right-hand side.
You can further specify the conditions for your Shopify order that will trigger a new task in Onfleet. You have the option between different payment, order, or fulfillment statuses. There is also a custom filter you are able to create based on other Shopify fields.
To match up the Shopify order to an Onfleet task, choose your organization as the merchant, or “task creator”. Then, choose the executor, which is the “task executor”, i.e. the organization that will be performing the work. If you have drivers who are completing tasks, choose your own organization. Choose a linked organization if you are delegating tasks to a third party for fulfillment.
For Address Line 1, click on the Insert fields button on the right-hand side and search for Shipping Address Address1.
Repeat this action for the following fields and fill in Shipping Address Address2 for Address Line 2, Shipping Address City for Address City, Shipping Address Province Code for Address State/Province, Shipping Address Zip for Address Postal Code/ZIP, and Shipping Address Country for Address Country. For the Longitude, search for Shipping Address Longitude. For Latitude, fill in Shipping Address Latitude. You also have the option to choose whether you want the task created to be a Pick-up task.
For the Recipient Name, choose Shipping Address Name, and for the Recipient phone Shipping Address Phone. You can also include a note used for special delivery instructions, door codes, etc. that will remain attached to the recipient in Onfleet for future deliveries. Choose Customer Note here from the available options. In the Task Details section, you can specify the name, quantity, or price of the order by putting in Line Items Title, Line Items Quantity, and Line Items Price.
For the Complete After Timestamp, choose either Created At (typical for on-demand deliveries) or another date/time field from Shopify. You can also add a Complete Before Timestamp using a Shopify field or by using Zapier's time modifiers. For example, to specify that a delivery should occur within two hours of creation, add Created At, a space, then "+2h." For more information about Zapier's time modifiers, see Adjusting Dates and Times.
The Driver-Auto-Assign Mode and the Driver Auto-Assign Team Filter are optional, and allow you to specify a team and mode of auto-assignment. For definitions of available modes, see Create a Task in Onfleet's API documentation.
Finally, click the Test Shopify Trigger button to test your trigger. If it is working properly, activate your Zap by clicking on the button Turn Zap on and you are ready to start deliveries!
Driver Behavior Analytics by Zendrive
NOTE: This feature is available to Premium and Professional plans only
Driver behavior analytics is a feature that uses Zendrive technology to collect even more granular driver data for operational analysis.
|Collect driving data
via app or our SDK
|Monitor and examine
completed trips on your
|Recognize safe drivers,
and coach drivers who
engagement and safety
Zendrive uses the sensors on a smartphone; GPS, gyroscope, accelerometer to collect data relevant to driving risk, such as:
- Aggressive acceleration
- Hard Braking
- Excessive Speeding
- Risky phone use
- Time of day
- Type of road
- Mode of transport
Get set up
To enable driver behavior analytics in Onfleet, please email email@example.com. We will work with Zendrive on your behalf to get your account setup and linked to your Onfleet organization.