Generate Reroute Preview
curl --request POST \
--url https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operations_parameters": {
"strategies": [
{
"slug": "battery-threshold",
"strat_params": {
"threshold": 25
}
}
]
}
}
'import requests
url = "https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate"
payload = { "operations_parameters": { "strategies": [
{
"slug": "battery-threshold",
"strat_params": { "threshold": 25 }
}
] } }
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({
operations_parameters: {strategies: [{slug: 'battery-threshold', strat_params: {threshold: 25}}]}
})
};
fetch('https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate"
payload := strings.NewReader("{\n \"operations_parameters\": {\n \"strategies\": [\n {\n \"slug\": \"battery-threshold\",\n \"strat_params\": {\n \"threshold\": 25\n }\n }\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))
}{
"kept_operations": 1,
"new_operations": [
{
"additional_notes": "Zone surplus 1.0 vehicles (threshold: 1.5)",
"address": "Via Mazzini 9, 20123 Milano MI",
"estimated_arrive": "2026-11-30T08:21:00Z",
"latitude": 45.4671,
"longitude": 9.1883,
"provider": "acme-mobility",
"routing_parameters": {
"capacity_delta": {
"vehicles": 1
},
"profit": 2.1
},
"step": 2,
"task_type": "pickup"
}
],
"route_id": 412,
"total_distance": 3.1,
"total_duration": 21.5
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Routing Operations
Generate Reroute Preview
Re-plan the open operations of a running route (neither completed nor cancelled) and return the proposed order, without changing the route. The plan uses the route’s routing_parameters (start and end point, start time, maximum duration, capacities); without a start or end point it starts at the first open operation and ends at the last. Send the returned new_operations to reroute/apply to use it. The route must have reroute_enabled.
Failure Modes:
- 401: Token is missing or invalid
- 400: Rerouting is not enabled on the route, or it has no open operations
- 403: Insufficient permissions, or you cannot manage the route’s company
- 404: No route with this ID, or its session was deleted
Required Auth Scopes:
routing-operations:manage
POST
/
operations
/
routes
/
{route_id}
/
reroute
/
generate
Generate Reroute Preview
curl --request POST \
--url https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operations_parameters": {
"strategies": [
{
"slug": "battery-threshold",
"strat_params": {
"threshold": 25
}
}
]
}
}
'import requests
url = "https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate"
payload = { "operations_parameters": { "strategies": [
{
"slug": "battery-threshold",
"strat_params": { "threshold": 25 }
}
] } }
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({
operations_parameters: {strategies: [{slug: 'battery-threshold', strat_params: {threshold: 25}}]}
})
};
fetch('https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/generate"
payload := strings.NewReader("{\n \"operations_parameters\": {\n \"strategies\": [\n {\n \"slug\": \"battery-threshold\",\n \"strat_params\": {\n \"threshold\": 25\n }\n }\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))
}{
"kept_operations": 1,
"new_operations": [
{
"additional_notes": "Zone surplus 1.0 vehicles (threshold: 1.5)",
"address": "Via Mazzini 9, 20123 Milano MI",
"estimated_arrive": "2026-11-30T08:21:00Z",
"latitude": 45.4671,
"longitude": 9.1883,
"provider": "acme-mobility",
"routing_parameters": {
"capacity_delta": {
"vehicles": 1
},
"profit": 2.1
},
"step": 2,
"task_type": "pickup"
}
],
"route_id": 412,
"total_distance": 3.1,
"total_duration": 21.5
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
HTTPBearerHTTPBearer
Body
application/json
Response
Reroute preview generated. Returns proposed operations.
Preview of a reroute result — proposed operations to replace pending ones.
