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

Code: 200 OK

Response body:

<users> 
    <id>psmqd-3nqijs-9qi26x</id> 
    <id>r8gxbr-kqw14l-isn2kq</id> 
</users> 

PowerShell script

try {
    $username = '<Token username>'
    $password = '<Token password>'
    $userID = '<Account GUID>'

    $basicauth = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${username}:${password}"))
    $headers = @{
        "User-Agent" = "PowerShell-Keepit-API-Agent-1.0"
        "Authorization" = "Basic $basicauth"
    }

    $url = "https://dk-co.keepit.com/users/$userID/users"

    $response = Invoke-WebRequest -UseBasicParsing -Uri $url -Method Get -Headers $headers -ErrorAction Stop -TimeoutSec 10

    $userlist = [xml]$response.Content

    $ids = $userlist.users.id
    foreach ($id in $ids) {
        Write-Host $id
    }
}
catch {
    $line = $_.InvocationInfo.ScriptLineNumber
    Write-Host "Cannot query Keepit API due to: $_"
    Write-Host "at line $line"
}