Stops a run that's already in progress -- either a graceful stop (finish the current step, don't start the next one) or a hard stop (kill it immediately).
Having trouble reaching the API, or logging in from another machine? See Network Access & Authentication Security -- by default the Api only answers
localhost, and PowerShell needs an extra flag once it does answer elsewhere.
Order of Operations
- Authenticate to the API.
- Get the running job's
manualJobRunId(from Check a Job Run's Status). - Request the cancel.
The call
POST /api/manual-job-runs/{manualJobRunId}/cancel?hard={true|false}
{manualJobRunId} is the value manualJobRunId from Check a Job Run's Status's response -- not the runCorrelationId from Run a Job. hard is an optional query parameter (defaults to false -- a graceful stop) with no request body.
Permission needed: Job.Run on the job this run belongs to.
C# example
// Step 1: Authenticate to the API.
using var handler = new HttpClientHandler { UseDefaultCredentials = true };
using var client = new HttpClient(handler) { BaseAddress = new Uri("http://your-minion-agent-server:5443") };
client.DefaultRequestHeaders.Add("X-App-Name", "MyIntegration");
// Step 2: You already have the manualJobRunId from Check a Job Run's Status.
var manualJobRunId = 8817;
// Step 3: Request the cancel (hard = true kills it immediately).
var response = await client.PostAsync($"/api/manual-job-runs/{manualJobRunId}/cancel?hard=false", content: null);
response.EnsureSuccessStatusCode();
Console.WriteLine("Cancel requested.");
Not on a domain machine? Swap in the app-account login from Calling the API From Your Own Code.
PowerShell example
# Step 1: Authenticate to the API.
$headers = @{ "X-App-Name" = "MyIntegration" }
# Step 2: You already have the manualJobRunId from Check a Job Run's Status.
$manualJobRunId = 8817
# Step 3: Request the cancel (hard = $true kills it immediately). (-AllowUnencryptedAuthentication: PowerShell requires this for Windows auth over plain http to anything but localhost -- see "Network Access & Authentication Security".)
Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/manual-job-runs/$manualJobRunId/cancel?hard=false" `
-Method Post -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
"Cancel requested."
What you get back
204 No Content -- the cancel request was recorded. This doesn't mean the run has actually stopped yet: a graceful cancel (hard=false) waits for the current step to finish first. Check back with Check a Job Run's Status to see when it actually ends.
Codes this call can return
See API Response Codes for what each one means in general. For this specific call:
- 204 -- cancel requested.
- 403 -- you don't have
Job.Runon this run's job. - 404 -- no run exists with that
manualJobRunId.
See also: Check a Job Run's Status, Run a Job.