Apply Rerouted Operations
curl --request POST \
--url https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/apply \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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"
}
]
}
'import requests
url = "https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/apply"
payload = { "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"
}
] }
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({
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'
}
]
})
};
fetch('https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/apply', 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/apply"
payload := strings.NewReader("{\n \"new_operations\": [\n {\n \"additional_notes\": \"Zone surplus 1.0 vehicles (threshold: 1.5)\",\n \"address\": \"Via Mazzini 9, 20123 Milano MI\",\n \"estimated_arrive\": \"2026-11-30T08:21:00Z\",\n \"latitude\": 45.4671,\n \"longitude\": 9.1883,\n \"provider\": \"acme-mobility\",\n \"routing_parameters\": {\n \"capacity_delta\": {\n \"vehicles\": 1\n },\n \"profit\": 2.1\n },\n \"step\": 2,\n \"task_type\": \"pickup\"\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))
}{
"inserted_operations": 1,
"removed_operations": 1,
"route_id": 412
}Routing Operations
Apply Rerouted Operations
Replace the open operations of a route with new_operations, usually from reroute/generate. Completed and cancelled operations stay; the new ones follow them in the given order. All or nothing.
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
- 422: Missing or empty
new_operations
Required Auth Scopes:
routing-operations:manage
POST
/
operations
/
routes
/
{route_id}
/
reroute
/
apply
Apply Rerouted Operations
curl --request POST \
--url https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/apply \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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"
}
]
}
'import requests
url = "https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/apply"
payload = { "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"
}
] }
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({
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'
}
]
})
};
fetch('https://stage-api.getswitch.io/operations/routes/{route_id}/reroute/apply', 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/apply"
payload := strings.NewReader("{\n \"new_operations\": [\n {\n \"additional_notes\": \"Zone surplus 1.0 vehicles (threshold: 1.5)\",\n \"address\": \"Via Mazzini 9, 20123 Milano MI\",\n \"estimated_arrive\": \"2026-11-30T08:21:00Z\",\n \"latitude\": 45.4671,\n \"longitude\": 9.1883,\n \"provider\": \"acme-mobility\",\n \"routing_parameters\": {\n \"capacity_delta\": {\n \"vehicles\": 1\n },\n \"profit\": 2.1\n },\n \"step\": 2,\n \"task_type\": \"pickup\"\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))
}{
"inserted_operations": 1,
"removed_operations": 1,
"route_id": 412
}Authorizations
HTTPBearerHTTPBearer
Body
application/json
Request body for applying a reroute preview.
Contains the new operations to insert. This is the output of generate/optimize, sent back to apply.
