Skip to main content
POST
https://agentgate.mynewapi.com
/
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>"
}
'
{
  "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

id
string
required
The work order ID to force kill (e.g., wo_abc123)
gracePeriodMs
number
default:"5000"
Milliseconds to wait for graceful shutdown before SIGKILL (0-30000)
immediate
boolean
default:"false"
If true, skip grace period and send SIGKILL immediately
reason
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

success
boolean
required
Indicates if the request was successful
data
object
required
Force kill result

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

ScenarioBehavior
immediate: trueSends SIGKILL immediately
immediate: falseSends SIGTERM, waits gracePeriodMs, then SIGKILL if needed
No running processReturns success with durationMs: 0
Process in containerTerminates container
Process in subprocessTerminates process tree

Difference from Cancel

AspectCancelForce Kill
SignalSIGTERM onlySIGTERM then SIGKILL
Wait timeSystem defaultConfigurable grace period
Use caseNormal shutdownStuck processes
Result statuscanceledfailed 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