Returns every registered target server. There's no single-server detail endpoint -- this list is the only way to read a target server's fields back.

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. Request the list.

The call

GET /api/target-servers

No route parameters, no query parameters, no request body.

Permission needed: TargetServer.View.

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: Request the list.
var servers = await client.GetFromJsonAsync<TargetServerSummary[]>("/api/target-servers", jsonOptions);
foreach (var server in servers!)
{
    Console.WriteLine($"{server.TargetServerId}: {server.ServerName} ({server.HostName}), active = {server.IsActive}");
}

record TargetServerSummary(int TargetServerId, string ServerName, string HostName, string? Description, bool IsActive);

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: Request the list. (-AllowUnencryptedAuthentication: PowerShell requires this for Windows auth over plain http to anything but localhost -- see "Network Access & Authentication Security".)
$servers = Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/target-servers" -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
$servers | ForEach-Object { "$($_.targetServerId): $($_.serverName) ($($_.hostName)), active = $($_.isActive)" }

What you get back

200 OK, an array, ordered by name:

[
    { "targetServerId": 7, "serverName": "SQLPROD01", "hostName": "sqlprod01.internal.example.com", "description": "Primary OLTP server", "isActive": true }
]

Codes this call can return

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

  • 200 -- the list, even if it's empty.
  • 403 -- you don't have TargetServer.View.

See also: Register a Target Server, Activate/Deactivate a Target Server.