Attaches a tag to a job, creating the tag first if the name doesn't already exist. There's no untag call -- removing a tag from a job isn't possible through the API today.

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

  1. Authenticate to the API.
  2. Get the job's id (by name or from the list).
  3. Send the tag name (and optionally a color, if this might be a brand-new tag).

The call

POST /api/jobs/{jobId}/tags

Permission needed: Job.Edit on this job.

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: Get the job's id by name.
var jobName = Uri.EscapeDataString("Nightly ETL Load");
var job = await (await client.GetAsync($"/api/jobs/by-name/{jobName}")).Content.ReadFromJsonAsync<JobRef>(jsonOptions);

// Step 3: Send the tag name. Color only matters if this tag doesn't exist yet.
var tag = new AddTagRequest(TagName: "prod", Color: "#c0392b");
var response = await client.PostAsJsonAsync($"/api/jobs/{job!.JobID}/tags", tag, jsonOptions);
response.EnsureSuccessStatusCode();
Console.WriteLine("Tagged.");

record JobRef(int JobID);
record AddTagRequest(string TagName, string? Color);

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: Get the job's id by name. (-AllowUnencryptedAuthentication: PowerShell requires this for Windows auth over plain http to anything but localhost -- see "Network Access & Authentication Security".)
$jobName = [Uri]::EscapeDataString("Nightly ETL Load")
$job = Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/jobs/by-name/$jobName" -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers

# Step 3: Send the tag name. Color only matters if this tag doesn't exist yet.
$body = @{ TagName = "prod"; Color = "#c0392b" } | ConvertTo-Json
Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/jobs/$($job.jobID)/tags" `
    -Method Post -Body $body -ContentType "application/json" -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers

"Tagged."

What you get back

204 No Content -- no body.

Codes this call can return

See API Response Codes for what each one means in general. For this specific call:

  • 204 -- tagged (whether the tag already existed or was just created).
  • 403 -- you don't have Job.Edit on this job.

See also: Get a Job (its tags/inheritedTags fields show what's on it), List Tags, Tag a Job Step.