Brings a job back out of the trash, exactly as it was when it was deleted.

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 from List Deleted Jobs.
  3. Request the restore.

The call

POST /api/jobs/{jobId}/restore

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: You already have the jobId from List Deleted Jobs.
var jobId = 19;

// Step 3: Request the restore.
var response = await client.PostAsync($"/api/jobs/{jobId}/restore", content: null);

if (response.StatusCode == System.Net.HttpStatusCode.Conflict)
{
    Console.WriteLine("An active job already has this name -- rename one of them first.");
}
else
{
    response.EnsureSuccessStatusCode();
    Console.WriteLine("Restored.");
}

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 jobId from List Deleted Jobs.
$jobId = 19

# Step 3: Request the restore. (-AllowUnencryptedAuthentication: PowerShell requires this for Windows auth over plain http to anything but localhost -- see "Network Access & Authentication Security".)
try {
    Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/jobs/$jobId/restore" `
        -Method Post -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
    "Restored."
}
catch [Microsoft.PowerShell.Commands.HttpResponseException] {
    if ($_.Exception.Response.StatusCode -eq 409) {
        "An active job already has this name -- rename one of them first."
    } else {
        throw
    }
}

What you get back

204 No Content on success -- no body.

Codes this call can return

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

  • 204 -- restored.
  • 403 -- you don't have Job.Edit on this job.
  • 404 -- this job isn't in the trash (already restored, or never deleted).
  • 409 -- an active job already has this name. Rename one of them, then retry.

See also: List Deleted Jobs, Delete a Job.