Controls which steps have to reach a certain status before another step is allowed to run. There's no "update" for an existing dependency -- to change one, remove it and add the new one.
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 two steps' ids involved.
- Add (or remove) the dependency.
Add a dependency
POST /api/job-versions/{jobVersionId}/step-dependencies
Permission needed: Job.Edit on the job this version belongs to.
C# example
var jsonOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
// 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 both step ids (from List a Job's Steps).
var jobVersionId = 7;
var stepId = 101;
var dependsOnStepId = 100;
// Step 3: Add the dependency. RequiredStatusCode 2 = "Succeeded".
var dep = new AddDependencyRequest(JobStepId: stepId, DependsOnJobStepId: dependsOnStepId, RequiredStatusCode: 2);
var response = await client.PostAsJsonAsync($"/api/job-versions/{jobVersionId}/step-dependencies", dep, jsonOptions);
response.EnsureSuccessStatusCode();
var created = await response.Content.ReadFromJsonAsync<CreatedId>(jsonOptions);
Console.WriteLine($"Dependency id: {created!.Id}");
record AddDependencyRequest(int JobStepId, int DependsOnJobStepId, byte RequiredStatusCode);
record CreatedId(int Id);
PowerShell example
# Step 1: Authenticate to the API.
$headers = @{ "X-App-Name" = "MyIntegration" }
# Step 2: You already have both step ids (from List a Job's Steps).
$jobVersionId = 7
$stepId = 101
$dependsOnStepId = 100
# Step 3: Add the dependency. RequiredStatusCode 2 = "Succeeded". (-AllowUnencryptedAuthentication: PowerShell requires this for Windows auth over plain http to anything but localhost -- see "Network Access & Authentication Security".)
$dep = @{ JobStepId = $stepId; DependsOnJobStepId = $dependsOnStepId; RequiredStatusCode = 2 } | ConvertTo-Json
$created = Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/job-versions/$jobVersionId/step-dependencies" `
-Method Post -Body $dep -ContentType "application/json" -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
"Dependency id: $($created.id)"
What you get back
201 Created: { "Id": 12 }.
Remove a dependency
DELETE /api/job-step-dependencies/{jobStepDependencyId}
{jobStepDependencyId} is the Id Add a dependency handed back.
Permission needed: Job.Edit on the step that owns this dependency.
C# example
// Step 1: Authenticate (same client setup as above).
// Step 2: You already have the dependency id from when you created it.
var jobStepDependencyId = 12;
// Step 3: Remove it.
var response = await client.DeleteAsync($"/api/job-step-dependencies/{jobStepDependencyId}");
response.EnsureSuccessStatusCode();
Console.WriteLine("Removed.");
PowerShell example
# Step 1: Authenticate (same headers as above).
# Step 2: You already have the dependency id from when you created it.
$jobStepDependencyId = 12
# Step 3: Remove it.
Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/job-step-dependencies/$jobStepDependencyId" `
-Method Delete -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
"Removed."
What you get back
204 No Content -- no body. A nonexistent jobStepDependencyId still returns 204 rather than a 404.
Codes these calls can return
See API Response Codes for what each one means in general.
- 201 -- (add) created.
- 204 -- (remove) removed.
- 403 -- you don't have
Job.Editon the relevant step/job.
RequiredStatusCode values worth knowing: 2 = Succeeded, and others matching whatever dbo.RunStatus lists (check Get a Job Run's Status response for the full set of run-status codes/names).
See also: Create a Job Step, List a Job's Steps.