Steps 8-12 are part of the driver workflow, where you work with dispatches. In the last step, you created the dispatch; in this step, you make several PUT
calls to update it: first, to add a new stop; next, to remove a stop; then to change the driver and vehicle; and finally, to set the dispatch from 'planned' to 'active' status.
Recall that a dispatch consists of a minimum of two stops. The first is called the shipper stop (where the dispatch begins) and the last is called the consignee stop (where the dispatch is completed). Any other stops in between are considered additional stops, and are called dispatch stops in our system. We now add a new dispatch stop in this request, where vendor_id
is ‘VDS-2’.
Let’s modify a planned dispatch by PUT
ting to the /dispatches
endpoint.
Add a New Stop
PUT https://api.keeptruckin.com/v1/dispatches
The PUT
method for this endpoint only accepts a JSON object in the body of the request. It modifies an existing dispatch.
The sample request in this workflow is an example of a dispatch with one added stop. The response echoes the details of the PUT
request, and is not paginated.
Remove a Stop
We added a new dispatch stop in the last section. We now remove a dispatch stop in this request, where vendor_id
is ‘VDS-1’.
Once again we modify a planned dispatch by making a PUT
request to the /dispatches
endpoint.
PUT https://api.keeptruckin.com/v1/dispatches
The PUT
method for this endpoint only accepts a JSON object in the body of the request. It modifies an existing dispatch. When updating an existing dispatch, if you don't want to make any changes and only want to remove stops, you don't need to send all the information again. You can see this in our example to the right.
The response echoes the details of the PUT
request, and is not paginated.
Change the Driver and Vehicle of the Planned Dispatch
A dispatch can be in either a planned, active, cancelled, or completed state. A driver can have only one active dispatch while having any number of planned dispatches.
While a dispatch is still in ‘planned’ status, you can change things like the driver and vehicle for it. You cannot make these changes for an ‘active’ status dispatch.
Again we modify a planned dispatch by making a PUT
request to the /dispatch
endpoint.
PUT https://api.keeptruckin.com/v1/dispatches
Update a Planned Dispatch to 'Active' Status
A dispatch can be in either a planned, active, cancelled, or completed state. Let’s update a ‘planned’ dispatch to ‘active” status.
For the last time in this workflow, we modify a planned dispatch by making a PUT
request to the /dispatches
endpoint.
PUT https://api.keeptruckin.com/v1/dispatches
{
"vendor_id":"VD-1",
"status":"active"
}
Learn more
Read our reference documentation about the Dispatches object and about the PUT method to this endpoint for details.