curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vehicle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"trip_date": "2023-12-25",
"external_id": "<string>",
"distance": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>"
}
'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips"
payload = {
"vehicle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"trip_date": "2023-12-25",
"external_id": "<string>",
"distance": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
vehicle_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
trip_date: '2023-12-25',
external_id: '<string>',
distance: '<string>',
purpose: 'UNREVIEWED',
start_address: '<string>',
end_address: '<string>',
google_start_place_id: '<string>',
google_end_place_id: '<string>',
start_latitude: '<string>',
start_longitude: '<string>',
end_latitude: '<string>',
end_longitude: '<string>',
description: '<string>'
})
};
fetch('https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'vehicle_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'trip_date' => '2023-12-25',
'external_id' => '<string>',
'distance' => '<string>',
'purpose' => 'UNREVIEWED',
'start_address' => '<string>',
'end_address' => '<string>',
'google_start_place_id' => '<string>',
'google_end_place_id' => '<string>',
'start_latitude' => '<string>',
'start_longitude' => '<string>',
'end_latitude' => '<string>',
'end_longitude' => '<string>',
'description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips"
payload := strings.NewReader("{\n \"vehicle_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"distance\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"google_start_place_id\": \"<string>\",\n \"google_end_place_id\": \"<string>\",\n \"start_latitude\": \"<string>\",\n \"start_longitude\": \"<string>\",\n \"end_latitude\": \"<string>\",\n \"end_longitude\": \"<string>\",\n \"description\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vehicle_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"distance\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"google_start_place_id\": \"<string>\",\n \"google_end_place_id\": \"<string>\",\n \"start_latitude\": \"<string>\",\n \"start_longitude\": \"<string>\",\n \"end_latitude\": \"<string>\",\n \"end_longitude\": \"<string>\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vehicle_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"distance\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"google_start_place_id\": \"<string>\",\n \"google_end_place_id\": \"<string>\",\n \"start_latitude\": \"<string>\",\n \"start_longitude\": \"<string>\",\n \"end_latitude\": \"<string>\",\n \"end_longitude\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vehicle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"business_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"make_and_model": "<string>",
"year": 123,
"is_primary": true,
"is_eligible_for_deletion": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiVehicle",
"external_id": "<string>",
"license_plate": "<string>",
"vin": "<string>",
"description": "<string>",
"archived_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"distance": "<string>",
"trip_date": "2023-12-25",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiTrip",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vehicle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"business_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"make_and_model": "<string>",
"year": 123,
"is_primary": true,
"is_eligible_for_deletion": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiVehicle",
"external_id": "<string>",
"license_plate": "<string>",
"vin": "<string>",
"description": "<string>",
"archived_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"distance": "<string>",
"trip_date": "2023-12-25",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiTrip",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}
}{
"description": "<string>",
"meta": {}
}{
"description": "<string>",
"meta": {}
}Create trip
Creates a new trip for the specified business. This endpoint is idempotent using the external_id field as the idempotency key.
curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vehicle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"trip_date": "2023-12-25",
"external_id": "<string>",
"distance": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>"
}
'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips"
payload = {
"vehicle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"trip_date": "2023-12-25",
"external_id": "<string>",
"distance": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
vehicle_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
trip_date: '2023-12-25',
external_id: '<string>',
distance: '<string>',
purpose: 'UNREVIEWED',
start_address: '<string>',
end_address: '<string>',
google_start_place_id: '<string>',
google_end_place_id: '<string>',
start_latitude: '<string>',
start_longitude: '<string>',
end_latitude: '<string>',
end_longitude: '<string>',
description: '<string>'
})
};
fetch('https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'vehicle_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'trip_date' => '2023-12-25',
'external_id' => '<string>',
'distance' => '<string>',
'purpose' => 'UNREVIEWED',
'start_address' => '<string>',
'end_address' => '<string>',
'google_start_place_id' => '<string>',
'google_end_place_id' => '<string>',
'start_latitude' => '<string>',
'start_longitude' => '<string>',
'end_latitude' => '<string>',
'end_longitude' => '<string>',
'description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips"
payload := strings.NewReader("{\n \"vehicle_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"distance\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"google_start_place_id\": \"<string>\",\n \"google_end_place_id\": \"<string>\",\n \"start_latitude\": \"<string>\",\n \"start_longitude\": \"<string>\",\n \"end_latitude\": \"<string>\",\n \"end_longitude\": \"<string>\",\n \"description\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vehicle_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"distance\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"google_start_place_id\": \"<string>\",\n \"google_end_place_id\": \"<string>\",\n \"start_latitude\": \"<string>\",\n \"start_longitude\": \"<string>\",\n \"end_latitude\": \"<string>\",\n \"end_longitude\": \"<string>\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vehicle_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"distance\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"google_start_place_id\": \"<string>\",\n \"google_end_place_id\": \"<string>\",\n \"start_latitude\": \"<string>\",\n \"start_longitude\": \"<string>\",\n \"end_latitude\": \"<string>\",\n \"end_longitude\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vehicle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"business_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"make_and_model": "<string>",
"year": 123,
"is_primary": true,
"is_eligible_for_deletion": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiVehicle",
"external_id": "<string>",
"license_plate": "<string>",
"vin": "<string>",
"description": "<string>",
"archived_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"distance": "<string>",
"trip_date": "2023-12-25",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiTrip",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vehicle": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"business_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"make_and_model": "<string>",
"year": 123,
"is_primary": true,
"is_eligible_for_deletion": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiVehicle",
"external_id": "<string>",
"license_plate": "<string>",
"vin": "<string>",
"description": "<string>",
"archived_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"distance": "<string>",
"trip_date": "2023-12-25",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"type": "com.layerfi.routers.ApiTrip",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"google_start_place_id": "<string>",
"google_end_place_id": "<string>",
"start_latitude": "<string>",
"start_longitude": "<string>",
"end_latitude": "<string>",
"end_longitude": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}
}{
"description": "<string>",
"meta": {}
}{
"description": "<string>",
"meta": {}
}distance is optional when both google_start_place_id and google_end_place_id are provided (from the address suggestions endpoints); the driving distance between them is then computed automatically and the trip’s distance_source is COMPUTED. Providing an explicit distance always takes precedence and sets distance_source to MANUAL. A request with neither a distance nor both place IDs returns a 400.
When updating an existing trip via external_id, the distance is recomputed only if the place IDs change; if they are unchanged, the existing distance is kept.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Content-Type must be set to application/json.
Path Parameters
The UUID of the business.
Body
The UUID of the vehicle used for this trip.
The date of the trip (YYYY-MM-DD).
An optional external identifier for the trip. If provided and a trip with this external_id already exists, the existing trip will be updated instead of creating a new one.
The distance traveled in miles, as a decimal string. Optional when both google_start_place_id and google_end_place_id are provided; the driving distance is then computed automatically. Providing a distance always takes precedence and marks the trip distance as MANUAL.
The purpose classification of the trip.
UNREVIEWED, BUSINESS, PERSONAL The starting address of the trip.
The ending address of the trip.
Google Maps place ID of the trip start address, from the address suggestion endpoints.
Google Maps place ID of the trip end address, from the address suggestion endpoints.
Latitude of the start address, as a decimal string.
Longitude of the start address, as a decimal string.
Latitude of the end address, as a decimal string.
Longitude of the end address, as a decimal string.
An optional description or notes about the trip.
Response
Existing trip with matching external_id was updated.
Show child attributes
Show child attributes