Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

- Track the inspection API's renamed submission answers: `answers` with a `field` per entry, replacing `custom_field_values` with `custom_field`. Both older spellings are still accepted by the API, and the SDK forwards whichever is given without rewriting it.

## [1.4.0] - 2026-09-12

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ $inspection = $fleetbase->inspections->submitInspection([
'inspection_form' => $formId,
'driver' => $driverId,
'vehicle' => $vehicleId,
'custom_field_values' => [
['custom_field' => $fieldId, 'value_type' => 'object', 'value' => ['passed' => true]],
'answers' => [
['field' => $fieldId, 'value_type' => 'object', 'value' => ['passed' => true]],
],
], ['headers' => ['Idempotency-Key' => $submissionKey]]);
$inspection = $fleetbase->inspections->retrieveInspection($inspectionId);
$inspections = $fleetbase->inspections->listInspections(['driver' => $driverId]);
$history = $fleetbase->vehicles->listVehicleInspections($vehicleId, ['limit' => 30]);
```

Read the form's `grouped_fields` to obtain field IDs and required answer types. Reuse the same caller-generated idempotency key when replaying one submission; generate a new key for a new inspection. The SDK passes the key through to the API and does not implement its own deduplication. Forms are published in the console, not created through this public API. Form authoring, submission updates/deletion, and public inspection-link management are not supported public endpoints.
Read the form's `grouped_fields` to obtain field IDs and required answer types; a field's `id` is what an answer names, and it is the same id the submission answers with. `answers` was called `custom_field_values`, and each answer's `field` was called `custom_field`; both older spellings are still accepted on submit. Reuse the same caller-generated idempotency key when replaying one submission; generate a new key for a new inspection. The SDK passes the key through to the API and does not implement its own deduplication. Forms are published in the console, not created through this public API. Form authoring, submission updates/deletion, and public inspection-link management are not supported public endpoints.

## Configuration

Expand Down
4 changes: 2 additions & 2 deletions contracts/contract-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"postman": {
"repository": "https://github.com/fleetbase/postman",
"ref": "origin/main",
"commit": "d6a7cc530fa27d7cf19a0d3ef8594cf4e51a76bb",
"commit": "822b867218f174bad18a789d4fd6791ccfd2af34",
"scope": [
"Fleetbase API",
"Fleetbase Core API"
Expand All @@ -40,7 +40,7 @@
"fleetops": {
"repository": "https://github.com/fleetbase/fleetops",
"ref": "refs/pull/319/head",
"commit": "db671b6fac44b92757e9004896ac60c594917ce3"
"commit": "9f2ffe9873c16d4df20ea143839ff3f4425781c0"
}
}
}
6 changes: 3 additions & 3 deletions contracts/php-sdk-examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schema_version": 1,
"generated_from": {
"repository": "https://github.com/fleetbase/postman",
"ref": "d6a7cc530fa27d7cf19a0d3ef8594cf4e51a76bb",
"ref": "822b867218f174bad18a789d4fd6791ccfd2af34",
"collections": [
"Fleetbase API",
"Fleetbase Core API"
Expand Down Expand Up @@ -1087,8 +1087,8 @@
"name": "Submit an Inspection",
"implementation": "Fleetbase\\Sdk\\Services\\InspectionService::submitInspection",
"variables": [],
"call": "$result = $fleetbase->inspections->submitInspection(\n [\n 'inspection_form' => 'inspection_form_id-fixture',\n 'driver' => 'driver_id-fixture',\n 'vehicle' => 'vehicle_id-fixture',\n 'started_at' => '2026-09-09T07:10:00Z',\n 'odometer' => 120400,\n 'engine_hours' => 3100,\n 'location' => [\n 'latitude' => 1.3521,\n 'longitude' => 103.8198,\n ],\n 'custom_field_values' => [],\n 'item_results' => [\n [\n 'item_key' => 'brakes',\n 'label' => 'Brakes',\n 'category' => 'Safety',\n 'passed' => false,\n 'severity' => 'critical',\n 'comments' => 'Pedal is soft.',\n 'photos' => [\n 'proof_photo_base64-fixture',\n ],\n ],\n [\n 'item_key' => 'lights',\n 'label' => 'Lights',\n 'category' => 'Safety',\n 'passed' => true,\n ],\n ],\n ]\n);",
"code": "<?php\n\n$fleetbase = new \\Fleetbase\\Sdk\\Fleetbase('flb_live_…');\n\n$result = $fleetbase->inspections->submitInspection(\n [\n 'inspection_form' => 'inspection_form_id-fixture',\n 'driver' => 'driver_id-fixture',\n 'vehicle' => 'vehicle_id-fixture',\n 'started_at' => '2026-09-09T07:10:00Z',\n 'odometer' => 120400,\n 'engine_hours' => 3100,\n 'location' => [\n 'latitude' => 1.3521,\n 'longitude' => 103.8198,\n ],\n 'custom_field_values' => [],\n 'item_results' => [\n [\n 'item_key' => 'brakes',\n 'label' => 'Brakes',\n 'category' => 'Safety',\n 'passed' => false,\n 'severity' => 'critical',\n 'comments' => 'Pedal is soft.',\n 'photos' => [\n 'proof_photo_base64-fixture',\n ],\n ],\n [\n 'item_key' => 'lights',\n 'label' => 'Lights',\n 'category' => 'Safety',\n 'passed' => true,\n ],\n ],\n ]\n);"
"call": "$result = $fleetbase->inspections->submitInspection(\n [\n 'inspection_form' => 'inspection_form_id-fixture',\n 'driver' => 'driver_id-fixture',\n 'vehicle' => 'vehicle_id-fixture',\n 'started_at' => '2026-09-09T07:10:00Z',\n 'odometer' => 120400,\n 'engine_hours' => 3100,\n 'location' => [\n 'latitude' => 1.3521,\n 'longitude' => 103.8198,\n ],\n 'answers' => [\n [\n 'field' => 'inspection_pass_fail_field_id-fixture',\n 'value_type' => 'object',\n 'value' => [\n 'passed' => false,\n 'not_applicable' => false,\n 'severity' => 'critical',\n 'comments' => 'Pedal is soft.',\n 'photos' => [\n 'proof_photo_base64-fixture',\n ],\n 'unsafe' => true,\n ],\n ],\n [\n 'field' => 'inspection_number_field_id-fixture',\n 'value_type' => 'number',\n 'value' => 120400,\n ],\n ],\n 'item_results' => [\n [\n 'item_key' => 'brakes',\n 'label' => 'Brakes',\n 'category' => 'Safety',\n 'passed' => false,\n 'severity' => 'critical',\n 'comments' => 'Pedal is soft.',\n 'photos' => [\n 'proof_photo_base64-fixture',\n ],\n ],\n [\n 'item_key' => 'lights',\n 'label' => 'Lights',\n 'category' => 'Safety',\n 'passed' => true,\n ],\n ],\n ]\n);",
"code": "<?php\n\n$fleetbase = new \\Fleetbase\\Sdk\\Fleetbase('flb_live_…');\n\n$result = $fleetbase->inspections->submitInspection(\n [\n 'inspection_form' => 'inspection_form_id-fixture',\n 'driver' => 'driver_id-fixture',\n 'vehicle' => 'vehicle_id-fixture',\n 'started_at' => '2026-09-09T07:10:00Z',\n 'odometer' => 120400,\n 'engine_hours' => 3100,\n 'location' => [\n 'latitude' => 1.3521,\n 'longitude' => 103.8198,\n ],\n 'answers' => [\n [\n 'field' => 'inspection_pass_fail_field_id-fixture',\n 'value_type' => 'object',\n 'value' => [\n 'passed' => false,\n 'not_applicable' => false,\n 'severity' => 'critical',\n 'comments' => 'Pedal is soft.',\n 'photos' => [\n 'proof_photo_base64-fixture',\n ],\n 'unsafe' => true,\n ],\n ],\n [\n 'field' => 'inspection_number_field_id-fixture',\n 'value_type' => 'number',\n 'value' => 120400,\n ],\n ],\n 'item_results' => [\n [\n 'item_key' => 'brakes',\n 'label' => 'Brakes',\n 'category' => 'Safety',\n 'passed' => false,\n 'severity' => 'critical',\n 'comments' => 'Pedal is soft.',\n 'photos' => [\n 'proof_photo_base64-fixture',\n ],\n ],\n [\n 'item_key' => 'lights',\n 'label' => 'Lights',\n 'category' => 'Safety',\n 'passed' => true,\n ],\n ],\n ]\n);"
},
"fleetbase-api-issues-create-an-issue": {
"collection": "Fleetbase API",
Expand Down
32 changes: 26 additions & 6 deletions contracts/postman-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schema_version": 1,
"source": {
"repository": "https://github.com/fleetbase/postman",
"ref": "d6a7cc530fa27d7cf19a0d3ef8594cf4e51a76bb",
"ref": "822b867218f174bad18a789d4fd6791ccfd2af34",
"collections": [
"Fleetbase API",
"Fleetbase Core API"
Expand Down Expand Up @@ -3962,7 +3962,7 @@
"method": "GET",
"url": "{{base_url}}/{{namespace}}/inspections",
"source": "postman/collections/Fleetbase API/Inspections/List Inspections.request.yaml",
"description": "Lists filed inspections, newest first.\n\nNarrow by `driver` or `vehicle`, and by `type`, `result` and `status`, each as one value or a comma separated list. Defaults to a recent window rather than the organisation's whole history; use `limit` to widen it.\n\nEach row carries the same shape Retrieve an Inspection answers with: the answers as `custom_field_values`, the `item_results` derived from them, and the `files` filed with the inspection.",
"description": "Lists filed inspections, newest first.\n\nNarrow by `driver` or `vehicle`, and by `type`, `result` and `status`, each as one value or a comma separated list. Defaults to a recent window rather than the organisation's whole history; use `limit` to widen it.\n\nEach row carries the same shape Retrieve an Inspection answers with: the `answers`, the `item_results` derived from them, and the `files` filed with the inspection.",
"authentication": "fleetbase-api-key",
"request_fixture": {
"path_variables": [],
Expand Down Expand Up @@ -3995,7 +3995,7 @@
"method": "GET",
"url": "{{base_url}}/{{namespace}}/vehicles/:id/inspections",
"source": "postman/collections/Fleetbase API/Inspections/List Vehicle Inspections.request.yaml",
"description": "Lists a vehicle's inspection history, newest first \u2014 the same inspections List Inspections answers with `vehicle`, addressed the way the driver app holds them, from the vehicle's screen.\n\nNarrow by `type`, `result` and `status`, each as one value or a comma separated list.\n\nEach row carries the answers as `custom_field_values`, the `item_results` derived from them, and the `files` filed with the inspection.",
"description": "Lists a vehicle's inspection history, newest first \u2014 the same inspections List Inspections answers with `vehicle`, addressed the way the driver app holds them, from the vehicle's screen.\n\nNarrow by `type`, `result` and `status`, each as one value or a comma separated list.\n\nEach row carries the `answers`, the `item_results` derived from them, and the `files` filed with the inspection.",
"authentication": "fleetbase-api-key",
"request_fixture": {
"path_variables": {
Expand Down Expand Up @@ -4030,7 +4030,7 @@
"method": "GET",
"url": "{{base_url}}/{{namespace}}/inspections/:id",
"source": "postman/collections/Fleetbase API/Inspections/Retrieve an Inspection.request.yaml",
"description": "Retrieves one inspection with everything it produced: `custom_field_values` \u2014 the driver's answers, each beside the field's `name`, `label` and `type`, with every photo and signature resolved to `{ id, url, filename, content_type }` \u2014 the `item_results` derived from the `pass-fail` answers, the `files` filed with it, and the `issue` and `work_order` raised from any failed items.",
"description": "Retrieves one inspection with everything it produced: the `answers` \u2014 one per field the driver answered, each naming the `field` it answers beside that field's `name`, `label` and `type`, with every photo and signature resolved to `{ id, url, filename, content_type }` \u2014 the `item_results` derived from the `pass-fail` answers, the `files` filed with it, and the `issue` and `work_order` raised from any failed items.",
"authentication": "fleetbase-api-key",
"request_fixture": {
"path_variables": {
Expand Down Expand Up @@ -4100,7 +4100,7 @@
"method": "POST",
"url": "{{base_url}}/{{namespace}}/inspections",
"source": "postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml",
"description": "Files an inspection against a published form, as the driver app does at the end of a DVIR.\n\nA form built from typed fields is answered with `custom_field_values`: one entry per field the driver answered, naming the field by the `id` the form read gave it, with a `value_type` and a `value`. A `pass-fail` answer is an object \u2014 `passed`, `not_applicable`, `severity`, `comments`, `photos` and `unsafe`; a meter is a number, a signature or a photo is base64. The server stores every photo and signature as a file and answers with `file:` references resolved, and mirrors each `pass-fail` answer into an `item_results` row, which is what issues, work orders and the vehicle's history are built from.\n\nThe first cut's flat `item_results` body is still accepted, for the tokenised public link and for older app builds. When both arrive the field values win and the duplicated results are ignored \u2014 which is exactly what the app sends, so one body works against either cut.\n\nA failed `pass-fail` answer must carry whatever its field insists on: a form that sets `require_comment_on_fail` or `require_photo_on_fail` refuses the whole submission with a 422 rather than filing half an inspection.\n\nWithout `vehicle` the inspection is recorded against the vehicle the driver is currently assigned to. Without `started_at` the inspection is taken to have started when it was filed.\n\nThe app queues a submit while offline and replays it later. Send an `Idempotency-Key` header with each attempt: a replay with a key already used by the same driver answers with the inspection the first attempt filed rather than filing a second one.\n\nThe response is the inspection with its `custom_field_values`, `item_results` and `files`, and the `issue` and `work_order` the form's settings raised from any failed items.",
"description": "Files an inspection against a published form, as the driver app does at the end of a DVIR.\n\nA form built from typed fields is answered with `answers`: one entry per field the driver answered, naming the `field` by the `id` the form read gave it, with a `value` and, optionally, a `value_type`. `custom_field_values` is the previous name for this and is still accepted. A `pass-fail` answer is an object \u2014 `passed`, `not_applicable`, `severity`, `comments`, `photos` and `unsafe`; a meter is a number, a signature or a photo is base64. The server stores every photo and signature as a file and answers with `file:` references resolved, and mirrors each `pass-fail` answer into an `item_results` row, which is what issues, work orders and the vehicle's history are built from.\n\nThe first cut's flat `item_results` body is still accepted, for the tokenised public link and for older app builds. It is the older shape: an entry per checklist item rather than per field, naming the item by an `item_key` of its own instead of naming a field of the form. Send `answers` unless you are targeting an older server.\n\nThis request deliberately sends both, which is what the app does: when both arrive the answers win and the duplicated results are ignored, so one body works against either cut.\n\nA failed `pass-fail` answer must carry whatever its field insists on: a form that sets `require_comment_on_fail` or `require_photo_on_fail` refuses the whole submission with a 422 rather than filing half an inspection.\n\nWithout `vehicle` the inspection is recorded against the vehicle the driver is currently assigned to. Without `started_at` the inspection is taken to have started when it was filed.\n\nThe app queues a submit while offline and replays it later. Send an `Idempotency-Key` header with each attempt: a replay with a key already used by the same driver answers with the inspection the first attempt filed rather than filing a second one.\n\nThe response is the inspection with its `answers`, `item_results` and `files`, and the `issue` and `work_order` the form's settings raised from any failed items.",
"authentication": "fleetbase-api-key",
"request_fixture": {
"path_variables": [],
Expand All @@ -4117,7 +4117,27 @@
"latitude": 1.3521,
"longitude": 103.8198
},
"custom_field_values": [],
"answers": [
{
"field": "inspection_pass_fail_field_id-fixture",
"value_type": "object",
"value": {
"passed": false,
"not_applicable": false,
"severity": "critical",
"comments": "Pedal is soft.",
"photos": [
"proof_photo_base64-fixture"
],
"unsafe": true
}
},
{
"field": "inspection_number_field_id-fixture",
"value_type": "number",
"value": 120400
}
],
"item_results": [
{
"item_key": "brakes",
Expand Down
2 changes: 1 addition & 1 deletion contracts/service-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schema_version": 1,
"generated_from": {
"repository": "https://github.com/fleetbase/postman",
"ref": "d6a7cc530fa27d7cf19a0d3ef8594cf4e51a76bb",
"ref": "822b867218f174bad18a789d4fd6791ccfd2af34",
"collections": [
"Fleetbase API",
"Fleetbase Core API"
Expand Down
Loading
Loading