Force Kill Work Order
curl --request POST \
--url https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"gracePeriodMs": 123,
"immediate": true,
"reason": "<string>"
}
'import requests
url = "https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill"
payload = {
"gracePeriodMs": 123,
"immediate": True,
"reason": "<string>"
}
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({gracePeriodMs: 123, immediate: true, reason: '<string>'})
};
fetch('https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill', 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}/kill",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'gracePeriodMs' => 123,
'immediate' => true,
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill"
payload := strings.NewReader("{\n \"gracePeriodMs\": 123,\n \"immediate\": true,\n \"reason\": \"<string>\"\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))
}HttpResponse<String> response = Unirest.post("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"gracePeriodMs\": 123,\n \"immediate\": true,\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"gracePeriodMs\": 123,\n \"immediate\": true,\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"success": true,
"forcedKill": true,
"durationMs": 123,
"status": "<string>",
"message": "<string>",
"error": "<string>"
}
}Work Orders
Force Kill Work Order
Forcefully terminate a work order’s agent process
POST
/
api
/
v1
/
work-orders
/
{id}
/
kill
Force Kill Work Order
curl --request POST \
--url https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"gracePeriodMs": 123,
"immediate": true,
"reason": "<string>"
}
'import requests
url = "https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill"
payload = {
"gracePeriodMs": 123,
"immediate": True,
"reason": "<string>"
}
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({gracePeriodMs: 123, immediate: true, reason: '<string>'})
};
fetch('https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill', 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}/kill",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'gracePeriodMs' => 123,
'immediate' => true,
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill"
payload := strings.NewReader("{\n \"gracePeriodMs\": 123,\n \"immediate\": true,\n \"reason\": \"<string>\"\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))
}HttpResponse<String> response = Unirest.post("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"gracePeriodMs\": 123,\n \"immediate\": true,\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/work-orders/{id}/kill")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"gracePeriodMs\": 123,\n \"immediate\": true,\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"success": true,
"forcedKill": true,
"durationMs": 123,
"status": "<string>",
"message": "<string>",
"error": "<string>"
}
}Force Kill Work Order
Forcefully terminates a work order’s agent process. This is more aggressive than Cancel and should be used when graceful shutdown is not working.Force kill sends SIGKILL to the agent process, which may result in lost work. Use Cancel for graceful shutdown when possible.
Request
string
required
The work order ID to force kill (e.g.,
wo_abc123)number
default:"5000"
Milliseconds to wait for graceful shutdown before SIGKILL (0-30000)
boolean
default:"false"
If true, skip grace period and send SIGKILL immediately
string
Optional reason for force kill (logged for audit)
curl -X POST https://agentgate.mynewapi.com/api/v1/work-orders/wo_abc123/kill \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"gracePeriodMs": 3000,
"reason": "Agent stuck in infinite loop"
}'
Immediate Kill
curl -X POST https://agentgate.mynewapi.com/api/v1/work-orders/wo_abc123/kill \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"immediate": true,
"reason": "Emergency shutdown required"
}'
Response
boolean
required
Indicates if the request was successful
object
required
Force kill result
Show properties
Show properties
string
required
Work order ID
boolean
required
Whether the kill operation succeeded
boolean
required
Whether SIGKILL was used (true) or graceful shutdown worked (false)
number
Time taken to terminate the process in milliseconds
string
required
New work order status:
failed or canceledstring
required
Human-readable result message
string
Error message if kill failed
Example Responses
Graceful Termination
{
"success": true,
"data": {
"id": "wo_abc123",
"success": true,
"forcedKill": false,
"durationMs": 1523,
"status": "canceled",
"message": "Work order agent process terminated gracefully"
},
"requestId": "req_xyz789"
}
Forced Kill (SIGKILL)
{
"success": true,
"data": {
"id": "wo_abc123",
"success": true,
"forcedKill": true,
"durationMs": 5123,
"status": "failed",
"message": "Work order agent process force killed (SIGKILL)"
},
"requestId": "req_xyz789"
}
Already Terminated
{
"success": true,
"data": {
"id": "wo_abc123",
"success": true,
"forcedKill": false,
"durationMs": 0,
"status": "failed",
"message": "Work order was already in terminal state"
},
"requestId": "req_xyz789"
}
Error Responses
Work Order Not Found
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Work order not found: wo_invalid"
},
"requestId": "req_xyz789"
}
Kill Behavior
| Scenario | Behavior |
|---|---|
immediate: true | Sends SIGKILL immediately |
immediate: false | Sends SIGTERM, waits gracePeriodMs, then SIGKILL if needed |
| No running process | Returns success with durationMs: 0 |
| Process in container | Terminates container |
| Process in subprocess | Terminates process tree |
Difference from Cancel
| Aspect | Cancel | Force Kill |
|---|---|---|
| Signal | SIGTERM only | SIGTERM then SIGKILL |
| Wait time | System default | Configurable grace period |
| Use case | Normal shutdown | Stuck processes |
| Result status | canceled | failed or canceled |
Use force kill when:
- The agent is stuck in an infinite loop
- Cancel has been attempted but the process won’t stop
- Emergency shutdown is required
- Resources need to be freed immediately
Related
- Cancel Work Order - Graceful cancellation
- Get Work Order - Check work order status