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",
"distance": "<string>",
"trip_date": "2023-12-25",
"external_id": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<string>",
"description": "<string>"
}
'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips"
payload = {
"vehicle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"distance": "<string>",
"trip_date": "2023-12-25",
"external_id": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<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',
distance: '<string>',
trip_date: '2023-12-25',
external_id: '<string>',
purpose: 'UNREVIEWED',
start_address: '<string>',
end_address: '<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',
'distance' => '<string>',
'trip_date' => '2023-12-25',
'external_id' => '<string>',
'purpose' => 'UNREVIEWED',
'start_address' => '<string>',
'end_address' => '<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 \"distance\": \"<string>\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<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 \"distance\": \"<string>\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<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 \"distance\": \"<string>\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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",
"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",
"purpose": "UNREVIEWED",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}{
"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",
"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",
"purpose": "UNREVIEWED",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}""""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",
"distance": "<string>",
"trip_date": "2023-12-25",
"external_id": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<string>",
"description": "<string>"
}
'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips"
payload = {
"vehicle_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"distance": "<string>",
"trip_date": "2023-12-25",
"external_id": "<string>",
"purpose": "UNREVIEWED",
"start_address": "<string>",
"end_address": "<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',
distance: '<string>',
trip_date: '2023-12-25',
external_id: '<string>',
purpose: 'UNREVIEWED',
start_address: '<string>',
end_address: '<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',
'distance' => '<string>',
'trip_date' => '2023-12-25',
'external_id' => '<string>',
'purpose' => 'UNREVIEWED',
'start_address' => '<string>',
'end_address' => '<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 \"distance\": \"<string>\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<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 \"distance\": \"<string>\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<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 \"distance\": \"<string>\",\n \"trip_date\": \"2023-12-25\",\n \"external_id\": \"<string>\",\n \"purpose\": \"UNREVIEWED\",\n \"start_address\": \"<string>\",\n \"end_address\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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",
"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",
"purpose": "UNREVIEWED",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}{
"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",
"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",
"purpose": "UNREVIEWED",
"mileage_deduction_rate": "<string>",
"estimated_deduction": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"external_id": "<string>",
"start_address": "<string>",
"end_address": "<string>",
"description": "<string>",
"deleted_at": "2023-11-07T05:31:56Z"
}""""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 distance traveled in miles, as a decimal string
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 purpose classification of the trip
UNREVIEWED, BUSINESS, PERSONAL The starting address of the trip
The ending address of the trip
An optional description or notes about the trip
Response
Existing trip with matching external_id was updated
The unique identifier of the trip
The vehicle used for this trip
Show child attributes
Show child attributes
The distance traveled in miles, as a decimal string
The date of the trip (YYYY-MM-DD)
The purpose classification of the trip
UNREVIEWED, BUSINESS, PERSONAL The IRS standard mileage rate in cents per mile applicable for the trip date
The estimated tax deduction in cents. Only calculated for BUSINESS trips; returns 0 for PERSONAL and UNREVIEWED trips.
Timestamp when the trip was created
Timestamp when the trip was last updated
An optional external identifier for the trip, used for idempotency
The starting address of the trip
The ending address of the trip
An optional description or notes about the trip
Timestamp when the trip was deleted, or null if not deleted