Adds or removes one peer from an existing sync group, without recreating the whole group.
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 group's id (from Manage Job Sync Groups) and the peer's id (from Manage Sync Peers).
- Add or remove the membership.
The calls
POST /api/job-sync-groups/{jobSyncGroupId}/members/{syncPeerId}
DELETE /api/job-sync-groups/{jobSyncGroupId}/members/{syncPeerId}
No request body for either -- both ids are in the route.
Permission needed: Security.Manage for both.
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 group's id and the peer's id.
var jobSyncGroupId = Guid.Parse("8f1b2c3d-4e5f-6789-a0b1-c2d3e4f56789");
var syncPeerId = 5;
// Step 3: Add the membership.
var addResponse = await client.PostAsync($"/api/job-sync-groups/{jobSyncGroupId}/members/{syncPeerId}", null);
addResponse.EnsureSuccessStatusCode();
Console.WriteLine("Added.");
// -- later --
// Step 3: Remove the membership.
var removeResponse = await client.DeleteAsync($"/api/job-sync-groups/{jobSyncGroupId}/members/{syncPeerId}");
removeResponse.EnsureSuccessStatusCode();
Console.WriteLine("Removed.");
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 group's id and the peer's id.
$jobSyncGroupId = "8f1b2c3d-4e5f-6789-a0b1-c2d3e4f56789"
$syncPeerId = 5
# Step 3: Add the membership. (-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/job-sync-groups/$jobSyncGroupId/members/$syncPeerId" -Method Post -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
"Added."
# -- later --
# Step 3: Remove the membership.
Invoke-RestMethod -Uri "http://your-minion-agent-server:5443/api/job-sync-groups/$jobSyncGroupId/members/$syncPeerId" -Method Delete -UseDefaultCredentials -AllowUnencryptedAuthentication -Headers $headers
"Removed."
What you get back
204 No Content for both -- no body.
Codes this call can return
See API Response Codes for what each one means in general. For this specific call:
- 204 -- added or removed.
- 403 -- you don't have
Security.Manage.
Neither call checks that the group or peer actually exists, or that the membership is already there/not there -- both are unconditional writes, so a typo'd id silently succeeds without changing anything real. Double-check ids against Manage Job Sync Groups and Manage Sync Peers first.
What gets audited
Add is recorded as JobSyncGroup / Add Job Sync Group Member, remove as JobSyncGroup / Remove Job Sync Group Member, each with the resolved group name and peer name in the audit label where they can be looked up.
See also: Manage Job Sync Groups, Manage Sync Peers.