Update Session
curl --request PUT \
--url https://api.getswitch.io/operations/sessions/{slug} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"company_slug": "acme-mobility::milan"
}
'import requests
url = "https://api.getswitch.io/operations/sessions/{slug}"
payload = { "company_slug": "acme-mobility::milan" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({company_slug: 'acme-mobility::milan'})
};
fetch('https://api.getswitch.io/operations/sessions/{slug}', 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://api.getswitch.io/operations/sessions/{slug}"
payload := strings.NewReader("{\n \"company_slug\": \"acme-mobility::milan\"\n}")
req, _ := http.NewRequest("PUT", 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))
}{
"company_slug": "acme-mobility",
"created_at": "2026-11-30T07:58:10Z",
"routes": [
{
"drivers": [
{
"email": "marco.bianchi@acme-mobility.com",
"full_name": "Marco Bianchi",
"id": 57
}
],
"end_at": "2026-11-30T09:40:00Z",
"id": 412,
"operations": [
{
"additional_notes": "Battery level (12.0%) below threshold (20.0%)",
"address": "Via Torino 2, 20123 Milano MI",
"completed_at": "2026-11-30T08:17:42Z",
"estimated_arrive": "2026-11-30T08:14:00Z",
"id": 9031,
"latitude": 45.4642,
"longitude": 9.1856,
"provider": "acme-mobility",
"routing_parameters": {
"capacity_delta": {
"charged_battery": -1,
"empty_battery": 1
},
"profit": 2.4
},
"step": 1,
"task_type": "battery_swap",
"vehicle_properties": {
"battery_level": 12,
"id": "acme-sc-0193",
"last_moved": "2026-11-30T06:41:03Z",
"last_seen": "2026-11-30T07:50:12Z",
"lat": 45.4642,
"licence_plate": "SC0193",
"lon": 9.1856,
"status": "available",
"vehicle_model": "S-200",
"vehicle_type": "scooter"
}
},
{
"additional_notes": "Zone surplus 1.0 vehicles (threshold: 1.5)",
"address": "Via Mazzini 9, 20123 Milano MI",
"estimated_arrive": "2026-11-30T08:23:00Z",
"id": 9032,
"latitude": 45.4671,
"longitude": 9.1883,
"provider": "acme-mobility",
"routing_parameters": {
"capacity_delta": {
"vehicles": 1
},
"profit": 2.1
},
"step": 2,
"task_type": "pickup"
}
],
"operations_parameters": {
"strategies": [
{
"slug": "battery-threshold",
"strat_params": {
"threshold": 20
}
}
]
},
"reroute_enabled": true,
"route_identifier": "R1",
"routing_parameters": {
"end_coords": {
"latitude": 45.4887,
"longitude": 9.2415
},
"max_capacities": {
"charged_battery": 40,
"empty_battery": 40,
"vehicles": 12
},
"max_duration": 120,
"start_capacities": {
"charged_battery": 40,
"empty_battery": 0,
"vehicles": 0
},
"start_coords": {
"latitude": 45.4887,
"longitude": 9.2415
},
"start_time": "2026-11-30T08:00:00Z"
},
"start_at": "2026-11-30T08:00:00Z",
"total_distance": 14.2
}
],
"slug": "3f6c2a9e-8d41-4b7a-9c2e-5a1f0e7d9b13"
}Routing Sessions
Update Session
Update a routing session. Today only its owning company can be changed.
Failure Modes:
- 401: Token is missing or invalid
- 403: Insufficient permissions, or you cannot manage the session’s company or the new
company_slug - 404: No session with this slug
- 422: Invalid request body
Required Auth Scopes:
routing-sessions:manage
PUT
/
operations
/
sessions
/
{slug}
Update Session
curl --request PUT \
--url https://api.getswitch.io/operations/sessions/{slug} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"company_slug": "acme-mobility::milan"
}
'import requests
url = "https://api.getswitch.io/operations/sessions/{slug}"
payload = { "company_slug": "acme-mobility::milan" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({company_slug: 'acme-mobility::milan'})
};
fetch('https://api.getswitch.io/operations/sessions/{slug}', 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://api.getswitch.io/operations/sessions/{slug}"
payload := strings.NewReader("{\n \"company_slug\": \"acme-mobility::milan\"\n}")
req, _ := http.NewRequest("PUT", 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))
}{
"company_slug": "acme-mobility",
"created_at": "2026-11-30T07:58:10Z",
"routes": [
{
"drivers": [
{
"email": "marco.bianchi@acme-mobility.com",
"full_name": "Marco Bianchi",
"id": 57
}
],
"end_at": "2026-11-30T09:40:00Z",
"id": 412,
"operations": [
{
"additional_notes": "Battery level (12.0%) below threshold (20.0%)",
"address": "Via Torino 2, 20123 Milano MI",
"completed_at": "2026-11-30T08:17:42Z",
"estimated_arrive": "2026-11-30T08:14:00Z",
"id": 9031,
"latitude": 45.4642,
"longitude": 9.1856,
"provider": "acme-mobility",
"routing_parameters": {
"capacity_delta": {
"charged_battery": -1,
"empty_battery": 1
},
"profit": 2.4
},
"step": 1,
"task_type": "battery_swap",
"vehicle_properties": {
"battery_level": 12,
"id": "acme-sc-0193",
"last_moved": "2026-11-30T06:41:03Z",
"last_seen": "2026-11-30T07:50:12Z",
"lat": 45.4642,
"licence_plate": "SC0193",
"lon": 9.1856,
"status": "available",
"vehicle_model": "S-200",
"vehicle_type": "scooter"
}
},
{
"additional_notes": "Zone surplus 1.0 vehicles (threshold: 1.5)",
"address": "Via Mazzini 9, 20123 Milano MI",
"estimated_arrive": "2026-11-30T08:23:00Z",
"id": 9032,
"latitude": 45.4671,
"longitude": 9.1883,
"provider": "acme-mobility",
"routing_parameters": {
"capacity_delta": {
"vehicles": 1
},
"profit": 2.1
},
"step": 2,
"task_type": "pickup"
}
],
"operations_parameters": {
"strategies": [
{
"slug": "battery-threshold",
"strat_params": {
"threshold": 20
}
}
]
},
"reroute_enabled": true,
"route_identifier": "R1",
"routing_parameters": {
"end_coords": {
"latitude": 45.4887,
"longitude": 9.2415
},
"max_capacities": {
"charged_battery": 40,
"empty_battery": 40,
"vehicles": 12
},
"max_duration": 120,
"start_capacities": {
"charged_battery": 40,
"empty_battery": 0,
"vehicles": 0
},
"start_coords": {
"latitude": 45.4887,
"longitude": 9.2415
},
"start_time": "2026-11-30T08:00:00Z"
},
"start_at": "2026-11-30T08:00:00Z",
"total_distance": 14.2
}
],
"slug": "3f6c2a9e-8d41-4b7a-9c2e-5a1f0e7d9b13"
}Authorizations
HTTPBearerHTTPBearer
Body
application/json
Response
Session updated. Returns the updated session.
Full session detail response (includes routes + operations).
