Bulk create trips
curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips/bulk \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"trips": [
{
"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/bulk"
payload = { "trips": [
{
"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({
trips: [
{
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/bulk', 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/bulk",
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([
'trips' => [
[
'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/bulk"
payload := strings.NewReader("{\n \"trips\": [\n {\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 }\n ]\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/bulk")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"trips\": [\n {\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 }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips/bulk")
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 \"trips\": [\n {\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 }\n ]\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"
}
]
}{
"description": "<string>",
"meta": {}
}{
"description": "<string>",
"meta": {}
}Trips
Bulk create trips
Creates multiple trips for the specified business in a single request. Maximum of 100 trips per request. This endpoint is idempotent using the external_id field as the idempotency key for each trip.
POST
/
v1
/
businesses
/
{businessId}
/
mileage
/
trips
/
bulk
Bulk create trips
curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips/bulk \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"trips": [
{
"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/bulk"
payload = { "trips": [
{
"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({
trips: [
{
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/bulk', 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/bulk",
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([
'trips' => [
[
'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/bulk"
payload := strings.NewReader("{\n \"trips\": [\n {\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 }\n ]\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/bulk")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"trips\": [\n {\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 }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/mileage/trips/bulk")
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 \"trips\": [\n {\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 }\n ]\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"
}
]
}{
"description": "<string>",
"meta": {}
}{
"description": "<string>",
"meta": {}
}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
application/json
List of trips to create. Maximum of 100 trips per request.
Maximum array length:
100Show child attributes
Show child attributes
Response
Trips created successfully.
Show child attributes
Show child attributes
⌘I