PUT /api/v1/routing

Update an existing Route model. This will update and also add stops and users to an existing route model. This can also be used to update the gps locations of existing vehicles.

Request parameters:

routeModelId

Part of the url is the route mode Id that was returned from the POST route endpoint.

SaveRoutingModelRequest Object
  • Updates for  the route, This can update and add new stops

Sample Json:

{
  "settings": {
    "startTime": "2024-03-20T22:55:02.573Z",
    "endTime": "2024-03-24T07:55:02.573Z",
    "startLocation": {
      "latitude": -33.8706672,
      "longitude": 151.192487
    },
    "endLocation": {
      "latitude": -33.8706672,
      "longitude": 151.192487
    }
  },
  "stops": [
    {
      "sourceReference": "12331A",
      "quantities": [
        1
      ],
      "durationMinutes": 15,
      "name": "ABC Stop",
      "location": {
       "latitude": -33.8706672,
       "longitude": 151.192487
      },
	"assignedPublicUserId": "608b34bb-8b9a-4f0a-9184-414fde9ff5f7",
    },
     {
      "sourceReference": "12331B",
      "quantities": [
        1
      ],
      "durationMinutes": 15,
      "name": "ABC Stop2",
      "location": {
        "latitude": -33.8743446,
        "longitude": 151.2131667
      }
    }
  ],
  "users": [
    {
      "publicUserId": "608b34bb-8b9a-4f0a-9184-414fde9ff5f7",
      "vehicleCapacities": [
        30
      ],
      "startLocation": {
        "latitude": -33.8743446,
        "longitude": 151.2131667
      },
      "endLocation": {
        "latitude": -33.8706672,
        "longitude": 151.192487
      }
    }
  ]
}
  1. settings (Object): Configuration settings for the route.
    • startTime (String): The start time of the route in ISO 8601 format.
    • endTime (String): The end time of the route in ISO 8601 format.
    • startLocation (Object): The starting location of the route.
      • latitude (Number): The latitude coordinate of the starting location.
      • longitude (Number): The longitude coordinate of the starting location.
    • endLocation (Object): The ending location of the route.
      • latitude (Number): The latitude coordinate of the ending location.
      • longitude (Number): The longitude coordinate of the ending location.
    • deleteModelAfter (String): Time after which the model associated with this route will be deleted, in ISO 8601 format.
  2. stops (Array): List of stops along the route.
    • sourceReference (String): Unique identifier/reference for the stop.
    • quantities (Array): Quantities associated with the stop.
    • durationMinutes (Number): The duration of the stop in minutes.
    • name (String): Name or label for the stop.
    • location (Object): Geographic location of the stop.
      • latitude (Number): The latitude coordinate of the stop.
      • longitude (Number): The longitude coordinate of the stop.
  3. users (Array): List of users (team members or drivers) associated with the route.
    • publicUserId (String): Public identifier for the user.
    • vehicleCapacities (Array): Capacities associated with the user’s vehicle.
    • startLocation (Object): Starting location for the user.
      • latitude (Number): The latitude coordinate of the starting location.
      • longitude (Number): The longitude coordinate of the starting location.
    • endLocation (Object): Ending location for the user.
      • latitude (Number): The latitude coordinate of the ending location.
      • longitude (Number): The longitude coordinate of the ending location.

Sample code

C#
Java
NodeJS
PHP
Python
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Define the endpoint URL
        string endpoint = "https://api.locate2u.com/api/v1/routing";

        // Define the JSON payload
        string jsonPayload = @"
        {
            ""settings"": {
                ""startTime"": ""2024-03-20T22:55:02.573Z"",
                ""endTime"": ""2024-03-24T07:55:02.573Z"",
                ""startLocation"": {
                    ""latitude"": -33.8706672,
                    ""longitude"": 151.192487
                },
                ""endLocation"": {
                    ""latitude"": -33.8706672,
                    ""longitude"": 151.192487
                }
            },
            ""stops"": [
                {
                    ""sourceReference"": ""12331A"",
                    ""quantities"": [1],
                    ""durationMinutes"": 15,
                    ""name"": ""ABC Stop"",
                    ""location"": {
                        ""latitude"": -33.8706672,
                        ""longitude"": 151.192487
                    },
                    ""assignedPublicUserId"": ""608b34bb-8b9a-4f0a-9184-414fde9ff5f7""
                },
                {
                    ""sourceReference"": ""12331B"",
                    ""quantities"": [1],
                    ""durationMinutes"": 15,
                    ""name"": ""ABC Stop2"",
                    ""location"": {
                        ""latitude"": -33.8743446,
                        ""longitude"": 151.2131667
                    }
                }
            ],
            ""users"": [
                {
                    ""publicUserId"": ""608b34bb-8b9a-4f0a-9184-414fde9ff5f7"",
                    ""vehicleCapacities"": [30],
                    ""startLocation"": {
                        ""latitude"": -33.8743446,
                        ""longitude"": 151.2131667
                    },
                    ""endLocation"": {
                        ""latitude"": -33.8706672,
                        ""longitude"": 151.192487
                    }
                }
            ]
        }";

        // Define the bearer token
        string bearerToken = "YOUR_BEARER_TOKEN_HERE";

        // Create HttpClient instance
        using (HttpClient client = new HttpClient())
        {
            // Add bearer token to the request headers
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", bearerToken);

            // Create the content from JSON payload
            HttpContent content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");

            // Send the PUT request
            HttpResponseMessage response = await client.PutAsync(endpoint, content);

            // Check if request was successful
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine("Request successful");
            }
            else
            {
                Console.WriteLine($"Request failed with status code {response.StatusCode}");
            }
        }
    }
}

Response

Example response

Reponse
Http 200
Http 422
Array of ErrorResponse Object