Cancel Operation
curl --request POST \
--url https://stage-api.getswitch.io/operations/routes/{route_id}/operations/{op_id}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "Vehicle not found at location"
}
'import requests
url = "https://stage-api.getswitch.io/operations/routes/{route_id}/operations/{op_id}/cancel"
payload = { "reason": "Vehicle not found at location" }
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({reason: 'Vehicle not found at location'})
};
fetch('https://stage-api.getswitch.io/operations/routes/{route_id}/operations/{op_id}/cancel', 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}/operations/{op_id}/cancel"
payload := strings.NewReader("{\n \"reason\": \"Vehicle not found at location\"\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))
}{
"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"
}
}Routing Operations
Cancel Operation
Cancel an operation with a reason (1-500 characters), stored in cancelled; clears completed_at.
Failure Modes:
- 401: Token is missing or invalid
- 403: Insufficient permissions, or you cannot manage the route’s company and are not one of its drivers
- 404: No route with this ID, or no such operation on it
- 422: Missing or empty reason, or longer than 500 characters
Required Auth Scopes:
routing-operations:manage
POST
/
operations
/
routes
/
{route_id}
/
operations
/
{op_id}
/
cancel
Cancel Operation
curl --request POST \
--url https://stage-api.getswitch.io/operations/routes/{route_id}/operations/{op_id}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "Vehicle not found at location"
}
'import requests
url = "https://stage-api.getswitch.io/operations/routes/{route_id}/operations/{op_id}/cancel"
payload = { "reason": "Vehicle not found at location" }
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({reason: 'Vehicle not found at location'})
};
fetch('https://stage-api.getswitch.io/operations/routes/{route_id}/operations/{op_id}/cancel', 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}/operations/{op_id}/cancel"
payload := strings.NewReader("{\n \"reason\": \"Vehicle not found at location\"\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))
}{
"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"
}
}Authorizations
HTTPBearerHTTPBearer
Path Parameters
Body
application/json
Response
Operation cancelled. Returns the updated operation.
Operation as returned in session detail responses.
