Skip to main content
Create and manage mileage expense claims using the dynamic Fields system in the Expense API. Create mileage expense claims (car specifications) using the dynamic Fields system. This guide covers initializing fields, handling the route and vehicle type selection, managing trip details, and saving mileage expenses.

Overview

Mileage expenses use the CarSpecification expense type. They allow users to claim reimbursement for business travel based on distance driven, vehicle type, and optional extras like passengers, road tolls, and trailer usage. The Fields system handles the complexity of mileage calculations — including country-specific reimbursement rates, vehicle type multipliers, and distance computation from routes. Your client renders the fields and lets the server do the math.

Key concepts

API endpoints

All mileage field operations use the standard Fields endpoints with expenseType=CarSpecification:

Step 1: Initialize fields

Fetch the field structure for a new mileage expense:
bash
To load an existing mileage expense for editing, pass the expense record ID:
bash

Field structure overview

The response contains these key fields:

Step 2: Handle the route

The travel route is a FIELD_GROUP containing several nested fields:
Not all trip detail fields are visible by default. Their visibility depends on the organization’s configuration and country-specific rules. Only render fields where visible: true.

Route data format

The MILEAGE_ROUTE field holds an array of waypoints:
The first entry is the origin, the last is the destination, and any entries in between are via points. When the route changes and requiresUpdate is true, the server recalculates the distance and generates a map image.

Adding via points

Routes can include intermediate stops. A route with two via points:

Route commands

The travel route field group includes a commands array for clearing the route:
Execute by appending the command to the PUT URL:

Map image

After a route update, the server generates a map image. The URL is stored in the hidden field virtual.mileageMap:
Use this URL to display a visual route preview in your UI. The server also provides a virtual.mileageMapChecksum field for cache validation. Both fields are hidden and read-only.

Step 3: Vehicle type and category

Both the category (categoryId) and vehicle type (verification.carType) have requiresUpdate: true. Changing either triggers a server round-trip that may update reimbursement calculations and visible fields.

Fetching vehicle types

Vehicle types are scoped to the selected category:
Common vehicle types include:
The full list of vehicle types depends on the organization’s country and configuration. Always fetch from the API rather than hardcoding values.

Step 4: The update cycle

Mileage expenses have several fields with requiresUpdate: true. When the user changes any of these, send the full fields array back to the server:
Fields that trigger an update:

Example update request

bash
Always send the complete fields array — including hidden fields and fields you didn’t modify. The server uses the full state to compute the response.

Step 5: Save the expense

Once the user is finished, save the mileage expense:

Using fields format

Send the full fields payload as the request body. The server validates all fields and returns the created expense.

Using standard JSON format

Alternatively, extract values from the fields and use the standard expense format:
bash

Example response

Commuting variant

Some organizations configure mileage categories for commuting. Commuting expenses replace the route-based travel with a year/month/day selection: Fetch the available values from these endpoints:
The route field group is still present in commuting mode but with a simplified structure — the vehicle type is typically locked (e.g., PRIVATE_CAR with disabled: true).

Named passengers

Some organizations require named passengers instead of just a count. When enabled, the passengers array contains individual entries:
Each passenger has a name and the distance they traveled. This is used for per-passenger reimbursement calculations in some countries.

Fleet management integration

Organizations with fleet management integrations can link mileage expenses to tracked vehicle trips:
Fetch available trips from:
In the fields format, fleet management trips appear as a LIST field with multiSelect: true at verification.fleetManagementTripIds.

Toll cost data

For Norwegian organizations using AutoPASS or similar toll systems, toll cost data can be included:
The tollCostFuelType affects the toll rate calculation and supports: PETROL, DIESEL, ELECTRIC, HYBRID, and HYDROGEN.

Common integration patterns

Use the route suggestions endpoint to provide autocomplete when users type a place name:
Returns a list of matching places. After the user selects origin and destination, call the directions endpoint to get coordinates and calculated distance:
With a body of [{ "place": "Stockholm" }, { "place": "Gothenburg" }].
When the user toggles verification.manualDistance to true, the verification.distance field becomes editable and the verification.route field is no longer required. Send a PUT to update the fields — the server will adjust field visibility accordingly. When toggled back to false, the distance is recalculated from the route.
When verification.roundTrip is toggled to true, the server doubles the calculated distance. This is a requiresUpdate field — send a PUT to get the updated distance value. The route itself stays the same; only the distance is doubled.
The travel route FIELD_GROUP includes a summary array for displaying a compact preview:
Use the image type to display the map from virtual.mileageMap, and property_value entries to show key metrics like distance.

Error handling

Common errors when working with mileage expenses:

Next steps

Last modified on August 31, 2026