Cancel Work Order
curl --request DELETE \
--url https://agentgate.mynewapi.com/api/v1/work-orders/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/work-orders/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentgate.mynewapi.com/api/v1/work-orders/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agentgate.mynewapi.com/api/v1/work-orders/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agentgate.mynewapi.com/api/v1/work-orders/{id}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://agentgate.mynewapi.com/api/v1/work-orders/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/work-orders/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"status": "<string>",
"message": "<string>",
"wasRunning": true
}
}Work Orders
Cancel Work Order
Cancel a queued or running work order
DELETE
/
api
/
v1
/
work-orders
/
{id}
Cancel Work Order
curl --request DELETE \
--url https://agentgate.mynewapi.com/api/v1/work-orders/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/work-orders/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentgate.mynewapi.com/api/v1/work-orders/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agentgate.mynewapi.com/api/v1/work-orders/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agentgate.mynewapi.com/api/v1/work-orders/{id}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://agentgate.mynewapi.com/api/v1/work-orders/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/work-orders/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"status": "<string>",
"message": "<string>",
"wasRunning": true
}
}Cancel Work Order
Cancels a work order that is currently queued or running. This endpoint supports graceful cancellation of active work orders.Cancellation is irreversible. A canceled work order cannot be resumed.
Request
The work order ID to cancel (e.g.,
wo_abc123)curl -X DELETE https://agentgate.mynewapi.com/api/v1/work-orders/wo_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
Response
Indicates if the request was successful
Example Response
Successful Cancellation
{
"success": true,
"data": {
"id": "wo_abc123",
"status": "canceled",
"message": "Work order canceled successfully",
"wasRunning": true
},
"requestId": "req_xyz789"
}
Queued Work Order Cancellation
{
"success": true,
"data": {
"id": "wo_def456",
"status": "canceled",
"message": "Work order canceled successfully",
"wasRunning": false
},
"requestId": "req_abc123"
}
Error Responses
Work Order Not Found
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Work order not found: wo_invalid"
},
"requestId": "req_xyz789"
}
Already Completed
Returns 409 Conflict if the work order is already in a terminal state.{
"success": false,
"error": {
"code": "CONFLICT",
"message": "Cannot cancel work order in status 'succeeded'"
},
"requestId": "req_xyz789"
}
Behavior
| Original Status | Behavior |
|---|---|
queued | Immediately marked as canceled |
running | Graceful shutdown initiated, then marked canceled |
succeeded | Returns 409 Conflict |
failed | Returns 409 Conflict |
canceled | Returns 409 Conflict |
For running work orders, the agent process is given time to clean up before the work order is marked as canceled. Use the Force Kill endpoint if you need immediate termination.
Related
- Force Kill Work Order - Immediately terminate a work order
- Get Work Order - Check work order status
- List Work Orders - List all work orders
⌘I