curl --request POST \
--url https://api.sandbox.usenash.com/v1/routes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"externalId": "rte_JphRWDiEosGpXuxwgaYfY3",
"name": "Route 1",
"stops": [
{
"arrival_time": "2025-04-25T08:00:00Z",
"depart_time": "2025-04-25T08:00:00Z",
"location": {
"lat": 40.7128,
"lng": -74.006
},
"object_ids": [
"stl_warehouse_123"
],
"service_time": 0,
"stop_type": "ROUTE_START"
},
{
"distance_from_previous": 5000,
"duration_from_previous": 1200,
"location": {
"lat": 40.7589,
"lng": -73.9851
},
"object_ids": [
"ord_123",
"ord_456"
],
"service_time": 600,
"stop_type": "PICKUP"
},
{
"arrival_time": "2025-04-25T10:00:00Z",
"depart_time": "2025-04-25T10:30:00Z",
"object_ids": [
"break_001"
],
"service_time": 1800,
"stop_type": "DRIVER_BREAK"
},
{
"distance_from_previous": 2000,
"duration_from_previous": 600,
"location": {
"lat": 40.7505,
"lng": -73.9934
},
"object_ids": [
"ord_123"
],
"service_time": 180,
"stop_type": "DROPOFF"
}
],
"routeMetadata": {
"priority": "high",
"source": "optimization_engine"
},
"vehicleId": "veh_4hL8pXq2sVn6RtY3wCbD9M",
"courierId": "cor_9dK2mNp7xVt3RfWzY8sLbQ",
"driverGroupId": "cntr_7mP3xVt9Nk8sRfWzY2hLbQ",
"autoDispatch": false
}
'import requests
url = "https://api.sandbox.usenash.com/v1/routes"
payload = {
"externalId": "rte_JphRWDiEosGpXuxwgaYfY3",
"name": "Route 1",
"stops": [
{
"arrival_time": "2025-04-25T08:00:00Z",
"depart_time": "2025-04-25T08:00:00Z",
"location": {
"lat": 40.7128,
"lng": -74.006
},
"object_ids": ["stl_warehouse_123"],
"service_time": 0,
"stop_type": "ROUTE_START"
},
{
"distance_from_previous": 5000,
"duration_from_previous": 1200,
"location": {
"lat": 40.7589,
"lng": -73.9851
},
"object_ids": ["ord_123", "ord_456"],
"service_time": 600,
"stop_type": "PICKUP"
},
{
"arrival_time": "2025-04-25T10:00:00Z",
"depart_time": "2025-04-25T10:30:00Z",
"object_ids": ["break_001"],
"service_time": 1800,
"stop_type": "DRIVER_BREAK"
},
{
"distance_from_previous": 2000,
"duration_from_previous": 600,
"location": {
"lat": 40.7505,
"lng": -73.9934
},
"object_ids": ["ord_123"],
"service_time": 180,
"stop_type": "DROPOFF"
}
],
"routeMetadata": {
"priority": "high",
"source": "optimization_engine"
},
"vehicleId": "veh_4hL8pXq2sVn6RtY3wCbD9M",
"courierId": "cor_9dK2mNp7xVt3RfWzY8sLbQ",
"driverGroupId": "cntr_7mP3xVt9Nk8sRfWzY2hLbQ",
"autoDispatch": False
}
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({
externalId: 'rte_JphRWDiEosGpXuxwgaYfY3',
name: 'Route 1',
stops: [
{
arrival_time: '2025-04-25T08:00:00Z',
depart_time: '2025-04-25T08:00:00Z',
location: {lat: 40.7128, lng: -74.006},
object_ids: ['stl_warehouse_123'],
service_time: 0,
stop_type: 'ROUTE_START'
},
{
distance_from_previous: 5000,
duration_from_previous: 1200,
location: {lat: 40.7589, lng: -73.9851},
object_ids: ['ord_123', 'ord_456'],
service_time: 600,
stop_type: 'PICKUP'
},
{
arrival_time: '2025-04-25T10:00:00Z',
depart_time: '2025-04-25T10:30:00Z',
object_ids: ['break_001'],
service_time: 1800,
stop_type: 'DRIVER_BREAK'
},
{
distance_from_previous: 2000,
duration_from_previous: 600,
location: {lat: 40.7505, lng: -73.9934},
object_ids: ['ord_123'],
service_time: 180,
stop_type: 'DROPOFF'
}
],
routeMetadata: {priority: 'high', source: 'optimization_engine'},
vehicleId: 'veh_4hL8pXq2sVn6RtY3wCbD9M',
courierId: 'cor_9dK2mNp7xVt3RfWzY8sLbQ',
driverGroupId: 'cntr_7mP3xVt9Nk8sRfWzY2hLbQ',
autoDispatch: false
})
};
fetch('https://api.sandbox.usenash.com/v1/routes', 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://api.sandbox.usenash.com/v1/routes",
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([
'externalId' => 'rte_JphRWDiEosGpXuxwgaYfY3',
'name' => 'Route 1',
'stops' => [
[
'arrival_time' => '2025-04-25T08:00:00Z',
'depart_time' => '2025-04-25T08:00:00Z',
'location' => [
'lat' => 40.7128,
'lng' => -74.006
],
'object_ids' => [
'stl_warehouse_123'
],
'service_time' => 0,
'stop_type' => 'ROUTE_START'
],
[
'distance_from_previous' => 5000,
'duration_from_previous' => 1200,
'location' => [
'lat' => 40.7589,
'lng' => -73.9851
],
'object_ids' => [
'ord_123',
'ord_456'
],
'service_time' => 600,
'stop_type' => 'PICKUP'
],
[
'arrival_time' => '2025-04-25T10:00:00Z',
'depart_time' => '2025-04-25T10:30:00Z',
'object_ids' => [
'break_001'
],
'service_time' => 1800,
'stop_type' => 'DRIVER_BREAK'
],
[
'distance_from_previous' => 2000,
'duration_from_previous' => 600,
'location' => [
'lat' => 40.7505,
'lng' => -73.9934
],
'object_ids' => [
'ord_123'
],
'service_time' => 180,
'stop_type' => 'DROPOFF'
]
],
'routeMetadata' => [
'priority' => 'high',
'source' => 'optimization_engine'
],
'vehicleId' => 'veh_4hL8pXq2sVn6RtY3wCbD9M',
'courierId' => 'cor_9dK2mNp7xVt3RfWzY8sLbQ',
'driverGroupId' => 'cntr_7mP3xVt9Nk8sRfWzY2hLbQ',
'autoDispatch' => false
]),
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://api.sandbox.usenash.com/v1/routes"
payload := strings.NewReader("{\n \"externalId\": \"rte_JphRWDiEosGpXuxwgaYfY3\",\n \"name\": \"Route 1\",\n \"stops\": [\n {\n \"arrival_time\": \"2025-04-25T08:00:00Z\",\n \"depart_time\": \"2025-04-25T08:00:00Z\",\n \"location\": {\n \"lat\": 40.7128,\n \"lng\": -74.006\n },\n \"object_ids\": [\n \"stl_warehouse_123\"\n ],\n \"service_time\": 0,\n \"stop_type\": \"ROUTE_START\"\n },\n {\n \"distance_from_previous\": 5000,\n \"duration_from_previous\": 1200,\n \"location\": {\n \"lat\": 40.7589,\n \"lng\": -73.9851\n },\n \"object_ids\": [\n \"ord_123\",\n \"ord_456\"\n ],\n \"service_time\": 600,\n \"stop_type\": \"PICKUP\"\n },\n {\n \"arrival_time\": \"2025-04-25T10:00:00Z\",\n \"depart_time\": \"2025-04-25T10:30:00Z\",\n \"object_ids\": [\n \"break_001\"\n ],\n \"service_time\": 1800,\n \"stop_type\": \"DRIVER_BREAK\"\n },\n {\n \"distance_from_previous\": 2000,\n \"duration_from_previous\": 600,\n \"location\": {\n \"lat\": 40.7505,\n \"lng\": -73.9934\n },\n \"object_ids\": [\n \"ord_123\"\n ],\n \"service_time\": 180,\n \"stop_type\": \"DROPOFF\"\n }\n ],\n \"routeMetadata\": {\n \"priority\": \"high\",\n \"source\": \"optimization_engine\"\n },\n \"vehicleId\": \"veh_4hL8pXq2sVn6RtY3wCbD9M\",\n \"courierId\": \"cor_9dK2mNp7xVt3RfWzY8sLbQ\",\n \"driverGroupId\": \"cntr_7mP3xVt9Nk8sRfWzY2hLbQ\",\n \"autoDispatch\": false\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://api.sandbox.usenash.com/v1/routes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"externalId\": \"rte_JphRWDiEosGpXuxwgaYfY3\",\n \"name\": \"Route 1\",\n \"stops\": [\n {\n \"arrival_time\": \"2025-04-25T08:00:00Z\",\n \"depart_time\": \"2025-04-25T08:00:00Z\",\n \"location\": {\n \"lat\": 40.7128,\n \"lng\": -74.006\n },\n \"object_ids\": [\n \"stl_warehouse_123\"\n ],\n \"service_time\": 0,\n \"stop_type\": \"ROUTE_START\"\n },\n {\n \"distance_from_previous\": 5000,\n \"duration_from_previous\": 1200,\n \"location\": {\n \"lat\": 40.7589,\n \"lng\": -73.9851\n },\n \"object_ids\": [\n \"ord_123\",\n \"ord_456\"\n ],\n \"service_time\": 600,\n \"stop_type\": \"PICKUP\"\n },\n {\n \"arrival_time\": \"2025-04-25T10:00:00Z\",\n \"depart_time\": \"2025-04-25T10:30:00Z\",\n \"object_ids\": [\n \"break_001\"\n ],\n \"service_time\": 1800,\n \"stop_type\": \"DRIVER_BREAK\"\n },\n {\n \"distance_from_previous\": 2000,\n \"duration_from_previous\": 600,\n \"location\": {\n \"lat\": 40.7505,\n \"lng\": -73.9934\n },\n \"object_ids\": [\n \"ord_123\"\n ],\n \"service_time\": 180,\n \"stop_type\": \"DROPOFF\"\n }\n ],\n \"routeMetadata\": {\n \"priority\": \"high\",\n \"source\": \"optimization_engine\"\n },\n \"vehicleId\": \"veh_4hL8pXq2sVn6RtY3wCbD9M\",\n \"courierId\": \"cor_9dK2mNp7xVt3RfWzY8sLbQ\",\n \"driverGroupId\": \"cntr_7mP3xVt9Nk8sRfWzY2hLbQ\",\n \"autoDispatch\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.usenash.com/v1/routes")
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 \"externalId\": \"rte_JphRWDiEosGpXuxwgaYfY3\",\n \"name\": \"Route 1\",\n \"stops\": [\n {\n \"arrival_time\": \"2025-04-25T08:00:00Z\",\n \"depart_time\": \"2025-04-25T08:00:00Z\",\n \"location\": {\n \"lat\": 40.7128,\n \"lng\": -74.006\n },\n \"object_ids\": [\n \"stl_warehouse_123\"\n ],\n \"service_time\": 0,\n \"stop_type\": \"ROUTE_START\"\n },\n {\n \"distance_from_previous\": 5000,\n \"duration_from_previous\": 1200,\n \"location\": {\n \"lat\": 40.7589,\n \"lng\": -73.9851\n },\n \"object_ids\": [\n \"ord_123\",\n \"ord_456\"\n ],\n \"service_time\": 600,\n \"stop_type\": \"PICKUP\"\n },\n {\n \"arrival_time\": \"2025-04-25T10:00:00Z\",\n \"depart_time\": \"2025-04-25T10:30:00Z\",\n \"object_ids\": [\n \"break_001\"\n ],\n \"service_time\": 1800,\n \"stop_type\": \"DRIVER_BREAK\"\n },\n {\n \"distance_from_previous\": 2000,\n \"duration_from_previous\": 600,\n \"location\": {\n \"lat\": 40.7505,\n \"lng\": -73.9934\n },\n \"object_ids\": [\n \"ord_123\"\n ],\n \"service_time\": 180,\n \"stop_type\": \"DROPOFF\"\n }\n ],\n \"routeMetadata\": {\n \"priority\": \"high\",\n \"source\": \"optimization_engine\"\n },\n \"vehicleId\": \"veh_4hL8pXq2sVn6RtY3wCbD9M\",\n \"courierId\": \"cor_9dK2mNp7xVt3RfWzY8sLbQ\",\n \"driverGroupId\": \"cntr_7mP3xVt9Nk8sRfWzY2hLbQ\",\n \"autoDispatch\": false\n}"
response = http.request(request)
puts response.read_body{
"route": {
"id": "rte_JphRWDiEosGpXuxwgaYfY3",
"portalUrl": "https://portal.usenash.com/routes/rte_JphRWDiEosGpXuxwgaYfY3",
"type": "SINGLE_PICKUP_MULTIPLE_DROPOFFS",
"stops": [
{
"stopType": "PICKUP",
"objectIds": [
"ord_Qr5bVt8WiByGh66z2g7xEu",
"ord_WJFuooSiRvFCaceGZjpbqs"
],
"location": {
"lat": 45.558214,
"lng": -122.587074
},
"arrivalTime": "2025-04-25T03:27:00",
"departTime": "2025-04-25T03:30:00",
"plannedArrivalTime": "2025-04-25T03:27:00",
"serviceTime": 360,
"distanceFromPrevious": 3376,
"durationFromPrevious": 420,
"status": "PENDING",
"statusDescription": "leave_unattended",
"statusHistory": [
{
"created_at": "2025-04-25T03:00:00Z",
"status": "PENDING"
},
{
"created_at": "2025-04-25T03:15:00Z",
"status": "ENROUTE"
},
{
"created_at": "2025-04-25T03:20:00Z",
"status": "COMPLETED",
"status_description": "leave_unattended"
}
],
"metadata": {},
"startedAt": "2025-04-25T03:27:00Z",
"breakDuration": 123,
"orders": [
{
"id": "ord_Qr5bVt8WiByGh66z2g7xEu",
"externalId": "<string>",
"publicTrackingUrl": "<string>",
"pod": [
{
"type": "<string>",
"url": "<string>",
"uploadedAt": "<string>"
}
],
"orderItems": [
{
"id": "item-001",
"description": "<string>",
"count": 123,
"valueCents": 123,
"barcode": "<string>",
"sku": "<string>",
"category": "<string>",
"status": "delivered",
"availableQuantity": 123,
"statusMetadata": {
"pickedAt": "<string>",
"deliveredAt": "<string>",
"failedAt": "<string>",
"returnedAt": "<string>",
"failureReason": "<string>",
"failureLocation": "dropoff"
},
"statusHistory": [
{
"status": "picked",
"createdAt": "2025-04-25T03:20:00"
}
],
"subItems": [
"<unknown>"
]
}
]
}
]
}
],
"externalId": "rte_JphRWDiEosGpXuxwgaYfY3",
"name": "Route 1",
"courierId": "cor_9dK2mNp7xVt3RfWzY8sLbQ",
"vehicleId": "veh_4hL8pXq2sVn6RtY3wCbD9M",
"courier": {
"id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phoneNumber": "<string>"
},
"driverGroup": {
"id": "<string>",
"externalId": "<string>"
},
"courierPosition": {
"lat": 123,
"lng": 123,
"updatedAt": "<string>",
"capturedAt": "<string>",
"accuracy": 123,
"heading": 123,
"speed": 123,
"altitude": 123,
"altitudeAccuracy": 123,
"batteryLevel": 123,
"batteryIsCharging": true,
"isMoving": true
},
"vehicle": {
"licensePlate": "<string>",
"make": "<string>",
"model": "<string>",
"color": "<string>",
"year": 123,
"type": "<string>"
},
"providerName": "<string>",
"shiftId": "shf_1234567890abcdef12345678",
"isDispatched": false,
"jobId": "job_1234567890abcdef12345678",
"routeMetadata": {
"priority": "high",
"source": "optimization_engine"
},
"validationErrors": {
"order_123": "Order 123 has pickup but no dropoff"
},
"encodedPolyline": "<string>",
"status": "CREATED",
"statusHistory": [
{
"created_at": "2025-04-25T03:00:00Z",
"status": "CREATED"
},
{
"created_at": "2025-04-25T03:10:00Z",
"status": "ASSIGNED"
},
{
"created_at": "2025-04-25T03:15:00Z",
"status": "STARTED"
}
]
}
}[
{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"response_status": "<string>",
"RequestID": "<string>"
}
]Create or Update Route
Create or update a route in Nash
curl --request POST \
--url https://api.sandbox.usenash.com/v1/routes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"externalId": "rte_JphRWDiEosGpXuxwgaYfY3",
"name": "Route 1",
"stops": [
{
"arrival_time": "2025-04-25T08:00:00Z",
"depart_time": "2025-04-25T08:00:00Z",
"location": {
"lat": 40.7128,
"lng": -74.006
},
"object_ids": [
"stl_warehouse_123"
],
"service_time": 0,
"stop_type": "ROUTE_START"
},
{
"distance_from_previous": 5000,
"duration_from_previous": 1200,
"location": {
"lat": 40.7589,
"lng": -73.9851
},
"object_ids": [
"ord_123",
"ord_456"
],
"service_time": 600,
"stop_type": "PICKUP"
},
{
"arrival_time": "2025-04-25T10:00:00Z",
"depart_time": "2025-04-25T10:30:00Z",
"object_ids": [
"break_001"
],
"service_time": 1800,
"stop_type": "DRIVER_BREAK"
},
{
"distance_from_previous": 2000,
"duration_from_previous": 600,
"location": {
"lat": 40.7505,
"lng": -73.9934
},
"object_ids": [
"ord_123"
],
"service_time": 180,
"stop_type": "DROPOFF"
}
],
"routeMetadata": {
"priority": "high",
"source": "optimization_engine"
},
"vehicleId": "veh_4hL8pXq2sVn6RtY3wCbD9M",
"courierId": "cor_9dK2mNp7xVt3RfWzY8sLbQ",
"driverGroupId": "cntr_7mP3xVt9Nk8sRfWzY2hLbQ",
"autoDispatch": false
}
'import requests
url = "https://api.sandbox.usenash.com/v1/routes"
payload = {
"externalId": "rte_JphRWDiEosGpXuxwgaYfY3",
"name": "Route 1",
"stops": [
{
"arrival_time": "2025-04-25T08:00:00Z",
"depart_time": "2025-04-25T08:00:00Z",
"location": {
"lat": 40.7128,
"lng": -74.006
},
"object_ids": ["stl_warehouse_123"],
"service_time": 0,
"stop_type": "ROUTE_START"
},
{
"distance_from_previous": 5000,
"duration_from_previous": 1200,
"location": {
"lat": 40.7589,
"lng": -73.9851
},
"object_ids": ["ord_123", "ord_456"],
"service_time": 600,
"stop_type": "PICKUP"
},
{
"arrival_time": "2025-04-25T10:00:00Z",
"depart_time": "2025-04-25T10:30:00Z",
"object_ids": ["break_001"],
"service_time": 1800,
"stop_type": "DRIVER_BREAK"
},
{
"distance_from_previous": 2000,
"duration_from_previous": 600,
"location": {
"lat": 40.7505,
"lng": -73.9934
},
"object_ids": ["ord_123"],
"service_time": 180,
"stop_type": "DROPOFF"
}
],
"routeMetadata": {
"priority": "high",
"source": "optimization_engine"
},
"vehicleId": "veh_4hL8pXq2sVn6RtY3wCbD9M",
"courierId": "cor_9dK2mNp7xVt3RfWzY8sLbQ",
"driverGroupId": "cntr_7mP3xVt9Nk8sRfWzY2hLbQ",
"autoDispatch": False
}
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({
externalId: 'rte_JphRWDiEosGpXuxwgaYfY3',
name: 'Route 1',
stops: [
{
arrival_time: '2025-04-25T08:00:00Z',
depart_time: '2025-04-25T08:00:00Z',
location: {lat: 40.7128, lng: -74.006},
object_ids: ['stl_warehouse_123'],
service_time: 0,
stop_type: 'ROUTE_START'
},
{
distance_from_previous: 5000,
duration_from_previous: 1200,
location: {lat: 40.7589, lng: -73.9851},
object_ids: ['ord_123', 'ord_456'],
service_time: 600,
stop_type: 'PICKUP'
},
{
arrival_time: '2025-04-25T10:00:00Z',
depart_time: '2025-04-25T10:30:00Z',
object_ids: ['break_001'],
service_time: 1800,
stop_type: 'DRIVER_BREAK'
},
{
distance_from_previous: 2000,
duration_from_previous: 600,
location: {lat: 40.7505, lng: -73.9934},
object_ids: ['ord_123'],
service_time: 180,
stop_type: 'DROPOFF'
}
],
routeMetadata: {priority: 'high', source: 'optimization_engine'},
vehicleId: 'veh_4hL8pXq2sVn6RtY3wCbD9M',
courierId: 'cor_9dK2mNp7xVt3RfWzY8sLbQ',
driverGroupId: 'cntr_7mP3xVt9Nk8sRfWzY2hLbQ',
autoDispatch: false
})
};
fetch('https://api.sandbox.usenash.com/v1/routes', 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://api.sandbox.usenash.com/v1/routes",
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([
'externalId' => 'rte_JphRWDiEosGpXuxwgaYfY3',
'name' => 'Route 1',
'stops' => [
[
'arrival_time' => '2025-04-25T08:00:00Z',
'depart_time' => '2025-04-25T08:00:00Z',
'location' => [
'lat' => 40.7128,
'lng' => -74.006
],
'object_ids' => [
'stl_warehouse_123'
],
'service_time' => 0,
'stop_type' => 'ROUTE_START'
],
[
'distance_from_previous' => 5000,
'duration_from_previous' => 1200,
'location' => [
'lat' => 40.7589,
'lng' => -73.9851
],
'object_ids' => [
'ord_123',
'ord_456'
],
'service_time' => 600,
'stop_type' => 'PICKUP'
],
[
'arrival_time' => '2025-04-25T10:00:00Z',
'depart_time' => '2025-04-25T10:30:00Z',
'object_ids' => [
'break_001'
],
'service_time' => 1800,
'stop_type' => 'DRIVER_BREAK'
],
[
'distance_from_previous' => 2000,
'duration_from_previous' => 600,
'location' => [
'lat' => 40.7505,
'lng' => -73.9934
],
'object_ids' => [
'ord_123'
],
'service_time' => 180,
'stop_type' => 'DROPOFF'
]
],
'routeMetadata' => [
'priority' => 'high',
'source' => 'optimization_engine'
],
'vehicleId' => 'veh_4hL8pXq2sVn6RtY3wCbD9M',
'courierId' => 'cor_9dK2mNp7xVt3RfWzY8sLbQ',
'driverGroupId' => 'cntr_7mP3xVt9Nk8sRfWzY2hLbQ',
'autoDispatch' => false
]),
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://api.sandbox.usenash.com/v1/routes"
payload := strings.NewReader("{\n \"externalId\": \"rte_JphRWDiEosGpXuxwgaYfY3\",\n \"name\": \"Route 1\",\n \"stops\": [\n {\n \"arrival_time\": \"2025-04-25T08:00:00Z\",\n \"depart_time\": \"2025-04-25T08:00:00Z\",\n \"location\": {\n \"lat\": 40.7128,\n \"lng\": -74.006\n },\n \"object_ids\": [\n \"stl_warehouse_123\"\n ],\n \"service_time\": 0,\n \"stop_type\": \"ROUTE_START\"\n },\n {\n \"distance_from_previous\": 5000,\n \"duration_from_previous\": 1200,\n \"location\": {\n \"lat\": 40.7589,\n \"lng\": -73.9851\n },\n \"object_ids\": [\n \"ord_123\",\n \"ord_456\"\n ],\n \"service_time\": 600,\n \"stop_type\": \"PICKUP\"\n },\n {\n \"arrival_time\": \"2025-04-25T10:00:00Z\",\n \"depart_time\": \"2025-04-25T10:30:00Z\",\n \"object_ids\": [\n \"break_001\"\n ],\n \"service_time\": 1800,\n \"stop_type\": \"DRIVER_BREAK\"\n },\n {\n \"distance_from_previous\": 2000,\n \"duration_from_previous\": 600,\n \"location\": {\n \"lat\": 40.7505,\n \"lng\": -73.9934\n },\n \"object_ids\": [\n \"ord_123\"\n ],\n \"service_time\": 180,\n \"stop_type\": \"DROPOFF\"\n }\n ],\n \"routeMetadata\": {\n \"priority\": \"high\",\n \"source\": \"optimization_engine\"\n },\n \"vehicleId\": \"veh_4hL8pXq2sVn6RtY3wCbD9M\",\n \"courierId\": \"cor_9dK2mNp7xVt3RfWzY8sLbQ\",\n \"driverGroupId\": \"cntr_7mP3xVt9Nk8sRfWzY2hLbQ\",\n \"autoDispatch\": false\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://api.sandbox.usenash.com/v1/routes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"externalId\": \"rte_JphRWDiEosGpXuxwgaYfY3\",\n \"name\": \"Route 1\",\n \"stops\": [\n {\n \"arrival_time\": \"2025-04-25T08:00:00Z\",\n \"depart_time\": \"2025-04-25T08:00:00Z\",\n \"location\": {\n \"lat\": 40.7128,\n \"lng\": -74.006\n },\n \"object_ids\": [\n \"stl_warehouse_123\"\n ],\n \"service_time\": 0,\n \"stop_type\": \"ROUTE_START\"\n },\n {\n \"distance_from_previous\": 5000,\n \"duration_from_previous\": 1200,\n \"location\": {\n \"lat\": 40.7589,\n \"lng\": -73.9851\n },\n \"object_ids\": [\n \"ord_123\",\n \"ord_456\"\n ],\n \"service_time\": 600,\n \"stop_type\": \"PICKUP\"\n },\n {\n \"arrival_time\": \"2025-04-25T10:00:00Z\",\n \"depart_time\": \"2025-04-25T10:30:00Z\",\n \"object_ids\": [\n \"break_001\"\n ],\n \"service_time\": 1800,\n \"stop_type\": \"DRIVER_BREAK\"\n },\n {\n \"distance_from_previous\": 2000,\n \"duration_from_previous\": 600,\n \"location\": {\n \"lat\": 40.7505,\n \"lng\": -73.9934\n },\n \"object_ids\": [\n \"ord_123\"\n ],\n \"service_time\": 180,\n \"stop_type\": \"DROPOFF\"\n }\n ],\n \"routeMetadata\": {\n \"priority\": \"high\",\n \"source\": \"optimization_engine\"\n },\n \"vehicleId\": \"veh_4hL8pXq2sVn6RtY3wCbD9M\",\n \"courierId\": \"cor_9dK2mNp7xVt3RfWzY8sLbQ\",\n \"driverGroupId\": \"cntr_7mP3xVt9Nk8sRfWzY2hLbQ\",\n \"autoDispatch\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.usenash.com/v1/routes")
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 \"externalId\": \"rte_JphRWDiEosGpXuxwgaYfY3\",\n \"name\": \"Route 1\",\n \"stops\": [\n {\n \"arrival_time\": \"2025-04-25T08:00:00Z\",\n \"depart_time\": \"2025-04-25T08:00:00Z\",\n \"location\": {\n \"lat\": 40.7128,\n \"lng\": -74.006\n },\n \"object_ids\": [\n \"stl_warehouse_123\"\n ],\n \"service_time\": 0,\n \"stop_type\": \"ROUTE_START\"\n },\n {\n \"distance_from_previous\": 5000,\n \"duration_from_previous\": 1200,\n \"location\": {\n \"lat\": 40.7589,\n \"lng\": -73.9851\n },\n \"object_ids\": [\n \"ord_123\",\n \"ord_456\"\n ],\n \"service_time\": 600,\n \"stop_type\": \"PICKUP\"\n },\n {\n \"arrival_time\": \"2025-04-25T10:00:00Z\",\n \"depart_time\": \"2025-04-25T10:30:00Z\",\n \"object_ids\": [\n \"break_001\"\n ],\n \"service_time\": 1800,\n \"stop_type\": \"DRIVER_BREAK\"\n },\n {\n \"distance_from_previous\": 2000,\n \"duration_from_previous\": 600,\n \"location\": {\n \"lat\": 40.7505,\n \"lng\": -73.9934\n },\n \"object_ids\": [\n \"ord_123\"\n ],\n \"service_time\": 180,\n \"stop_type\": \"DROPOFF\"\n }\n ],\n \"routeMetadata\": {\n \"priority\": \"high\",\n \"source\": \"optimization_engine\"\n },\n \"vehicleId\": \"veh_4hL8pXq2sVn6RtY3wCbD9M\",\n \"courierId\": \"cor_9dK2mNp7xVt3RfWzY8sLbQ\",\n \"driverGroupId\": \"cntr_7mP3xVt9Nk8sRfWzY2hLbQ\",\n \"autoDispatch\": false\n}"
response = http.request(request)
puts response.read_body{
"route": {
"id": "rte_JphRWDiEosGpXuxwgaYfY3",
"portalUrl": "https://portal.usenash.com/routes/rte_JphRWDiEosGpXuxwgaYfY3",
"type": "SINGLE_PICKUP_MULTIPLE_DROPOFFS",
"stops": [
{
"stopType": "PICKUP",
"objectIds": [
"ord_Qr5bVt8WiByGh66z2g7xEu",
"ord_WJFuooSiRvFCaceGZjpbqs"
],
"location": {
"lat": 45.558214,
"lng": -122.587074
},
"arrivalTime": "2025-04-25T03:27:00",
"departTime": "2025-04-25T03:30:00",
"plannedArrivalTime": "2025-04-25T03:27:00",
"serviceTime": 360,
"distanceFromPrevious": 3376,
"durationFromPrevious": 420,
"status": "PENDING",
"statusDescription": "leave_unattended",
"statusHistory": [
{
"created_at": "2025-04-25T03:00:00Z",
"status": "PENDING"
},
{
"created_at": "2025-04-25T03:15:00Z",
"status": "ENROUTE"
},
{
"created_at": "2025-04-25T03:20:00Z",
"status": "COMPLETED",
"status_description": "leave_unattended"
}
],
"metadata": {},
"startedAt": "2025-04-25T03:27:00Z",
"breakDuration": 123,
"orders": [
{
"id": "ord_Qr5bVt8WiByGh66z2g7xEu",
"externalId": "<string>",
"publicTrackingUrl": "<string>",
"pod": [
{
"type": "<string>",
"url": "<string>",
"uploadedAt": "<string>"
}
],
"orderItems": [
{
"id": "item-001",
"description": "<string>",
"count": 123,
"valueCents": 123,
"barcode": "<string>",
"sku": "<string>",
"category": "<string>",
"status": "delivered",
"availableQuantity": 123,
"statusMetadata": {
"pickedAt": "<string>",
"deliveredAt": "<string>",
"failedAt": "<string>",
"returnedAt": "<string>",
"failureReason": "<string>",
"failureLocation": "dropoff"
},
"statusHistory": [
{
"status": "picked",
"createdAt": "2025-04-25T03:20:00"
}
],
"subItems": [
"<unknown>"
]
}
]
}
]
}
],
"externalId": "rte_JphRWDiEosGpXuxwgaYfY3",
"name": "Route 1",
"courierId": "cor_9dK2mNp7xVt3RfWzY8sLbQ",
"vehicleId": "veh_4hL8pXq2sVn6RtY3wCbD9M",
"courier": {
"id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phoneNumber": "<string>"
},
"driverGroup": {
"id": "<string>",
"externalId": "<string>"
},
"courierPosition": {
"lat": 123,
"lng": 123,
"updatedAt": "<string>",
"capturedAt": "<string>",
"accuracy": 123,
"heading": 123,
"speed": 123,
"altitude": 123,
"altitudeAccuracy": 123,
"batteryLevel": 123,
"batteryIsCharging": true,
"isMoving": true
},
"vehicle": {
"licensePlate": "<string>",
"make": "<string>",
"model": "<string>",
"color": "<string>",
"year": 123,
"type": "<string>"
},
"providerName": "<string>",
"shiftId": "shf_1234567890abcdef12345678",
"isDispatched": false,
"jobId": "job_1234567890abcdef12345678",
"routeMetadata": {
"priority": "high",
"source": "optimization_engine"
},
"validationErrors": {
"order_123": "Order 123 has pickup but no dropoff"
},
"encodedPolyline": "<string>",
"status": "CREATED",
"statusHistory": [
{
"created_at": "2025-04-25T03:00:00Z",
"status": "CREATED"
},
{
"created_at": "2025-04-25T03:10:00Z",
"status": "ASSIGNED"
},
{
"created_at": "2025-04-25T03:15:00Z",
"status": "STARTED"
}
]
}
}[
{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"response_status": "<string>",
"RequestID": "<string>"
}
]Route object represents a planned sequence of stops for a vehicle or delivery agent.
The core of the Route is the stops array, which lists the specific locations to visit in order. Each stop within this array details:
- The actions to be performed (like
stopType). - Associated items (
objectIds). - Timing estimates (
arrivalTime,departTime,serviceTime). - Travel details from the prior stop (
distanceFromPrevious,durationFromPrevious). - The physical coordinates (
location).
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Input for creating or updating a route.
Route ID. If provided, the route will be updated. If not provided, a new route will be created.
"rte_JphRWDiEosGpXuxwgaYfY3"
Name of the route.
"Route 1"
Complete route stops structure with timing, location, and stop types. Supports all stop types including PICKUP, DROPOFF, ROUTE_START, ROUTE_END, and DRIVER_BREAK.
Show child attributes
Show child attributes
[
{
"arrival_time": "2025-04-25T08:00:00Z",
"depart_time": "2025-04-25T08:00:00Z",
"location": { "lat": 40.7128, "lng": -74.006 },
"object_ids": ["stl_warehouse_123"],
"service_time": 0,
"stop_type": "ROUTE_START"
},
{
"distance_from_previous": 5000,
"duration_from_previous": 1200,
"location": { "lat": 40.7589, "lng": -73.9851 },
"object_ids": ["ord_123", "ord_456"],
"service_time": 600,
"stop_type": "PICKUP"
},
{
"arrival_time": "2025-04-25T10:00:00Z",
"depart_time": "2025-04-25T10:30:00Z",
"object_ids": ["break_001"],
"service_time": 1800,
"stop_type": "DRIVER_BREAK"
},
{
"distance_from_previous": 2000,
"duration_from_previous": 600,
"location": { "lat": 40.7505, "lng": -73.9934 },
"object_ids": ["ord_123"],
"service_time": 180,
"stop_type": "DROPOFF"
}
]
Additional metadata for the route.
{
"priority": "high",
"source": "optimization_engine"
}
Vehicle ID (or external ID) to assign to this route.
"veh_4hL8pXq2sVn6RtY3wCbD9M"
Courier/Driver ID (or external ID) to assign to this route.
"cor_9dK2mNp7xVt3RfWzY8sLbQ"
Driver group/Contract ID (or external ID) to assign to this route. Required when assigning a courier or vehicle.
"cntr_7mP3xVt9Nk8sRfWzY2hLbQ"
If true, dispatch the route to providers in the same request after upsert. Default: false.
Response
OK
Response for route upsert operation.
The created or updated route.
Show child attributes
Show child attributes
Was this page helpful?