Back to Documentation Overview

Tasks in Dispatch API

Tasks refer to actions that are be completed by the Dispatch API. In terms of ridehail, it can refer to trips from one location to another while for delivery services, it can refer to packages that need to be taken from Point A to Point B.

There are 4 steps a task needs to go through to be completed. These steps are:

  1. Drive to the pick-up location
  2. Pick up the resource
  3. Drive to the drop-off location
  4. Drop off the resource

The current state of the task can be fetched from the GetTask endpoint of the Task API. A task can have 3 states:

  1. In progress means that a task has steps that need to be completed. If the assignment field is not set, it means that a vehicle has not yet been assigned to the task. We can refer to the states of the steps to see how far along the task is in being completed.
  2. Completed means that a task has been completed. The time of completion is also returned in the response.
  3. Cancelled means that a task has been cancelled. The source of cancellation and its description is returned in the response.

Along with the states of the task, the GetTask endpoint also returns the states of all the steps. The state is defined by the boolean field completed which tells us whether the step has been completed or not. Along with the state, we also return the timestamp of when the step was completed. If it has not been completed yet, we return the expected time of completion which can be used to show ETAs to the users.

You can use this cURL command to fetch the current state of the task and steps:

curl --request POST \
--header "Content-Type: application/json" \
--header "X-Api-Key: $RIDEOS_API_KEY" \
--data '{"taskId": "task-1"}'