# Fleet Workflow Events

The fleet module emits events that can trigger automation via the workflow engine.

- `vehicle.registered` – after a vehicle record is created.
- `vehicle.reported` – when a vehicle report is submitted.
- `vehicle_report.confirmed` – when a report is confirmed by an administrator.
- `trip.started` – when a trip log begins.
- `trip.ended` – when a trip record is closed.
- `service.due` – when a vehicle's service date is reached.

The file `vehicle_reported_workflow.json` illustrates emailing the addresses
stored under the `fleet_issue_notify` key in `tenant_module_settings` when a
report is created.

The endpoint `POST /api/vehicle_reports/{id}/confirm` updates a report's status
and emits `vehicle_report.confirmed`. Use `vehicle_report_confirmed_workflow.json`
to automatically create a procurement request when confirmations occur.

Create or update workflows by POSTing to `/api/workflows`. The example JSON files
in this directory can be imported as starting points:

```bash
curl -X POST /api/workflows \
     -H 'Content-Type: application/json' \
     -d @docs/service_due_workflow.json

curl -X POST /api/workflows \
     -H 'Content-Type: application/json' \
     -d @docs/vehicle_reported_workflow.json
```

Adjust the `trigger_event` and steps to suit your organisation.
