Skip to main content

Web API – Commute Table

Web API Documentation for Managing a User's Commute Table

Use these endpoints to read and manage the Commute Table for a user: the list of commute distances with effective dates on the user's Mileage tab (Manage > Users > select a user > Mileage).

Each row holds a commute distance and the date it takes effect. For each trip, TripLog uses the row whose effective date is on or before the trip date to calculate the commute deduction. When a user's commute changes, you add a new row with a new effective date. You don't overwrite the old value, so trips before the change keep the old commute.

Which accounts use the Commute Table?

Enterprise accounts that use the commute deduction and were created on or after December 1, 2026, and older Enterprise accounts that have been upgraded. Other accounts use legacy commute settings, set with dailyMileageExemption in Web API – Users.

On a Commute Table account, the Users endpoints still return dailyMileageExemption, but that value is no longer used to calculate the deduction. Read and write commute values with the endpoints below.

How Commute Table values work

  • Effective date: startDate is required, in the format yyyy-MM-dd. A row applies to trips on and after that date, until the next row's date.

  • One row per date: If you add a row with a startDate the user already has, that row is updated. No second row is created.

  • No edit endpoint: To change a row, add it again with the same startDate, or delete it and add a new one. PUT is not supported.

  • Distance unit: mileage is in your account's distance unit: miles, or kilometers if the account uses a metric unit. Changing the account's unit does not convert values already saved.

  • Distance from addresses: Instead of mileage, you can send homeAddress and workAddress. TripLog calculates the driving distance with Google Maps and saves it as mileage. The distance depends on the account's commute policy (Policies & Settings > Mileage > Commute & Distance > Deduct from):

    • Only the first trip, Only the last trip, or Both the first and the last trips of the day: one-way distance.

    • The total trip mileage of the day: round-trip distance.

  • Mileage takes priority: If you send both mileage and both addresses, mileage is used. If mileage is 0 or missing, the addresses are used.

  • Weekdays only: Set onlyWeekdays to true to apply the commute deduction on weekdays only.

List Commute Rows for a User

Request URL

Query parameters

  • userId – The user.id of the user.

  • userEmail – The email address of the user.

Note

When you use /userCommutes, you need to provide userId or userEmail.

Example

Sample response

{
"message": "OK",
"userCommutes": [
{
"id": 1668,
"userId": 456623,
"userEmail": "driver@company.com",
"mileage": 15.0,
"startDate": "2026-11-01",
"onlyWeekdays": false
},
{
"id": 1669,
"userId": 456623,
"userEmail": "driver@company.com",
"mileage": 12.5,
"startDate": "2027-01-01",
"onlyWeekdays": false
}
]
}

Find Single Commute Row

Request URL

Query parameters

None

Sample response

{
"message": "OK",
"userCommute": {
"id": 1668,
"userId": 456623,
"userEmail": "driver@company.com",
"mileage": 15.0,
"startDate": "2026-11-01",
"onlyWeekdays": false
}
}

Add or Update a Commute Row

Request URL

Query parameters

None

JSON request data

{
"userId" : Integer (required),
"startDate" : String (required), effective date, yyyy-MM-dd
"mileage" : Float (optional, default 0), 0 or more, in the account's distance unit
"homeAddress" : String (optional), used with workAddress to calculate the distance
"workAddress" : String (optional), used with homeAddress to calculate the distance
"onlyWeekdays" : boolean (optional, default false)
}

Note

If the user already has a row with the same startDate, that row is updated and its id stays the same.

Example: add a commute distance

{
"userId": 456623,
"mileage": 12.5,
"startDate": "2027-01-01",
"onlyWeekdays": false
}

Sample response

{
"message": "OK",
"userCommute": {
"id": 1669,
"userId": 456623,
"userEmail": "driver@company.com",
"mileage": 12.5,
"startDate": "2027-01-01",
"onlyWeekdays": false
}
}

Example: calculate the distance from two addresses

{
"userId": 456623,
"homeAddress": "600 4th Ave, Seattle, WA 98104",
"workAddress": "6200 Southcenter Blvd, Tukwila, WA 98188",
"startDate": "2027-02-01"
}

Sample response (account in miles, commute policy The total trip mileage of the day, so the round-trip distance is saved)

{
"message": "OK",
"userCommute": {
"id": 1670,
"userId": 456623,
"userEmail": "driver@company.com",
"mileage": 22.8,
"startDate": "2027-02-01",
"onlyWeekdays": false
}
}

With a first trip, last trip, or first and last trip policy, the same addresses save the one-way distance (11.4 miles, or 18.3 km on a metric account).

Delete a Commute Row

Request URL

Query parameters

None

Sample response

{
"message": "OK"
}

If the row doesn't exist, the response is 404 with "message": "Not found".

Example: A User's Commute Changes

A user has a commute row of 15 miles from November 1, 2026. They move on January 1, 2027, and their new commute is 12.5 miles. Add a row:

POST https://app.triplog.net/web/api/userCommutes
{
"userId": 456623,
"mileage": 12.5,
"startDate": "2027-01-01"
}

Trips from November 1 through December 31, 2026 still use 15 miles, including when a report for that period is run again later. Trips on and after January 1, 2027 use 12.5 miles. If a report period runs from December 15 to January 15, trips before January 1 use 15 miles and trips from January 1 use 12.5 miles.

Error Responses

Cause

Status

Message

GET /userCommutes without userId or userEmail

400

Please provide userId or userEmail.

startDate missing or not in yyyy-MM-dd format

400

startDate is required in yyyy-MM-dd format.

userId missing, unknown, or not in your organization

400

Cannot find user by id [userId] or that user does not belong to the organization.

PUT request

400

Unsupported HTTP method.

Commute row or user not found

404

Not found

For authentication and the base URL, see Web Services API Overview.

Did this answer your question?