# What is a scheduled task?

The documentation in this section shows how to create and work with scheduled
tasks using the Google Maps Mobility scheduled tasks service. It assumes
familiarity with the following:

- **Fleet Engine** : You should be familiar with Fleet Engine implementation details, request mechanisms, and security. For that, see [What is the Fleet
  Engine service?](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials) and the security topics in [Set up Fleet Engine](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet).
- **Vehicles basics** for on-demand services. See [Introduction to vehicles](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/vehicles-intro).
- **Task basics** for scheduled task services. See [Scheduled tasks](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/tasks-intro)

The `Task` resource that you'll use is available in both [gRPC](https://developers.google.com/maps/documentation/mobility/fleet-engine/reference/tasks/rpc/maps.fleetengine.delivery.v1#task) and
[REST](https://developers.google.com/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks).

In Fleet Engine for scheduled tasks, a task represents a driver activity that
fulfills a scheduled shipment or service for your consumers. You assign tasks to
vehicle stop locations where they are to be completed, and the vehicle travels
to those stops.

A task has two possible states, `OPEN` or `CLOSED`. These states indicate
whether the task is active or not in the system. As the journey evolves for an
active task, you report this to Fleet Engine by updating the vehicle stop
associated with the task, which is either ENROUTE or ARRIVED. Once the driver
completes tasks and leaves the stop, you remove the stop from the list of stops
on the vehicle. For more about
tasks and their relationship to stops and vehicles, see
[Scheduled tasks](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/tasks-intro#basic_task_fields) in **Fleet Engine essentials** .

## Life of a task

In order to track each task in Fleet Engine, you must first create a `Task`
entity. See either [gRCP](https://developers.google.com/maps/documentation/mobility/fleet-engine/reference/tasks/rpc/maps.fleetengine.delivery.v1#task) or [REST](https://developers.google.com/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks) for reference.

The following table describes an example end-to-end flow of a task created in
your system and its lifecycle stages in Fleet Engine. It assumes you have set up
Fleet Engine and have a vehicle for the task, with location updates
enabled in the driver app. See [Driver SDK: Scheduled tasks](https://developers.google.com/maps/documentation/mobility/driver-sdk/scheduled).

|---|---|---|
| 1 | **Create tasks.** | At the beginning of the work cycle, the dispatcher or service administrator first creates a manifest for delivery tasks or services. From there, your system then creates the task entities using `CreateTrip` with required fields, such as the type of task and the location. It can also supply other configurations at this point, such as target time window, sharing task progress, and custom attributes. See [Create shipment tasks](https://developers.google.com/maps/documentation/mobility/fleet-engine/journeys/tasks/create-shipment-tasks) and the related guides. |
| 2 | **Schedule tasks.** | When you schedule a task for delivery, you issue a delivery vehicle update request, which then updates the vehicle entity with a list of stops to travel. You assign each stop a list of tasks to be completed at the stop. See [Update delivery vehicle tasks](https://developers.google.com/maps/documentation/mobility/fleet-engine/journeys/tasks/update-tasks). |
| 3 | **Update the task progress.** | Once the task is assigned to a delivery stop and active in Fleet Engine, your system notifies Fleet Engine about the vehicle progress as it approaches, arrives at, and completes the stop. With this information, Fleet Engine can best perform routing and status updates along the journey as well as throughout the day for the vehicle. See [Update vehicle stop status](https://developers.google.com/maps/documentation/mobility/fleet-engine/journeys/tasks/update-stops). |
| 4 | **Share journeys.** | At the same time that the vehicle begins active navigation for the delivery day, you can share journey information with interested stakeholders. Fleet Engine makes both task details and vehicle location available to interested stakeholders in the following ways: - **Shipment information for consumers** . With this solution, consumers can see the status of their package along with the vehicle location information you permit them to view. See [Consumer sharing for scheduled tasks](https://developers.google.com/maps/documentation/mobility/journey-sharing/scheduled). - **Fleet status information for administrators** . With this solution, fleet administrators can visualize the locations of delivery vehicles and their stops in your fleets in near real time. If the route for a vehicle is known, the map view component animates that vehicle as it moves along its predicted path. See the [JavaScript Fleet Tracking library](https://developers.google.com/maps/documentation/mobility/operations/fleet-tracking). |
| 5 | **Finalize the task.** | You finalize shipment tasks in Fleet engine in the following ways: - **Close the task**: Closing a shipment task indicates that that task is no longer active. - **Set the task outcome**: Once a task is closed, you indicate either a successful or failed task to indicate if the delivery took place or not. This is an important part of finalizing a task to show the delivery outcome in your consumer experience and to ensure correct billing for the Fleet Engine service. Keep in mind that, like delivery vehicles, task entities remain active within Fleet Engine for 7 days regardless of state, at which point they are removed. See [Finalize tasks](https://developers.google.com/maps/documentation/mobility/fleet-engine/journeys/tasks/finalize-tasks). |

## Task sequence flow

The following diagram shows a detailed flow of a task lifecycle.

![TaskSequenceDiagram](https://developers.google.com/static/maps/documentation/mobility/fleet-engine/journeys/images/taskSequence.png)

## What's next

- [Create shipment tasks](https://developers.google.com/maps/documentation/mobility/fleet-engine/journeys/tasks/create-shipment-tasks)