Retrieve a list of subaccount IDs
This command retrieves a list of subaccount IDs under the specified parent account. In other words, it returns the direct subaccounts for the given account ID.
The account ID provided to run the request must belong to the authenticated token or be a descendant of it.
API request
Method GET
/users/{parent_account_id}/users
Example
Method GET
https://dk-co.keepit.com/users/nq2v51-5mx23m-qb7sah/users
Response
<users> <id>psmqd-3nqijs-9qi26x</id> <id>r8gxbr-kqw14l-isn2kq</id> </users>
PowerShell script
try { # Define the API credentials and user ID $username = '<API Token username>' $password = '<API Token password>' $userID = '<Account GUID>' # Create the Basic Authentication header $basicauth = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${username}:${password}")) $headers = @{ "User-Agent" = "PowerShell-Keepit-API-Agent-1.0" "Authorization" = "Basic $basicauth" } # Construct the URL with the user ID $url = "https://dk-co.keepit.com/users/$userID/users" # Send the GET request $response = Invoke-WebRequest -UseBasicParsing -Uri $url -Method Get -Headers $headers -ErrorAction Stop -TimeoutSec 10 # Parse the response content as XML $userlist = [xml]$response.Content # Extract and print all user IDs $ids = $userlist.users.id foreach ($id in $ids) { Write-Host $id } } catch { # Handle errors and provide line number and error message $line = $_.InvocationInfo.ScriptLineNumber Write-Host "Cannot query Keepit API due to: $_" Write-Host "at line $line" }