Key

Value

x-total-usage

true

Retrieve resource consumption

This header forces the API to return the total usage across all accounts associated with the current product assignment.

Example

Method GET

https://dk-co.keepit.com/users/r4hsnr-ktb74l-bsq8ka/resources

Response

Code: 200 OK

Response body (partial):

…
 <resource>
        <evaluated>2024-12-20T11:58:30Z</evaluated>
        <name>o365-mailboxes</name>
        <type>integer</type>
        <limit>20</limit>
        <usage>15</usage>
        <violated>false</violated>
    </resource>
…

PowerShell script

try {
    $username = '<Token username>'
    $password = '<Token password>'
    $userId = '<Account ID>'

    $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/resources"

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

    [xml]$xmlContent = $response.Content

    foreach ($resource in $xmlContent.SelectNodes("//resource")) {
        foreach ($node in $resource.ChildNodes) {
            Write-Host "$($node.Name): $($node.InnerText)"
        }
        Write-Host "--------------------------"
    }
}
catch {
    $line = $_.InvocationInfo.ScriptLineNumber
    Write-Host "Cannot query Keepit API due to: $_"
    Write-Host "at line $line"
}

Additional information

  • This request is used to retrieve the resource consumption for a given account ID, including all subaccounts.
    Important: Usage data is returned only for accounts with products assigned directly. If subaccounts have their own assigned products, their usage data will not be included.
  • The response includes a resource record for each resource defined in the active configuration of the product assigned to the account.
  • Typically, each resource record contains the following elements: limit, usage, violated, and evaluated.