Element

Type

Requirement

Description

Additional note

start

ISO 8601 Timestamp

Mandatory

The time of range start.

 

span

ISO 8601 Timespan

Mandatory

The duration of the range.

 

count

Integer

Mandatory

Max number of entries to return.

Must be less than 100.

resolution

ISO 8601 Timespan

Optional

Minimum interval between returned snapshots.

 

type

Enum

Optional

Return only partial ("p") or complete ("c") snapshots.

Possible values: "p" or "c".

reverse

Boolean

Optional

If present, reverse the query.

Cannot be used if resolution is present.

Monitor timestamps and snapshot sizes

Example

Method PUT

 https://dk-co.keepit.com/users/5t1sbe-s6zsgx-rtutxq/devices/11ptlk-st7sly-ggba4c/history/range

Body

<range>
    <start>2024-11-23T08:12:14Z</start>
    <span>P1M</span>
    <count>99</count>
</range>

Response

Code: 200 OK

Response body:

 <backup>
        <tstamp>2024-12-21T21:29:31Z</tstamp>
        <root>23v1b6fasdfg1e23r32sdfsafd1a4382b62c919855cf4953a72959555f35d</root>
        <type>c</type>
        <size>2023899411</size>
        <account>5t1sbe-s6zsgx-rtutxq </account>
    </backup>
    <backup>
        <tstamp>2024-12-22T09:29:38Z </tstamp>
        <root>588331ebecd7e2986a5ccb42c3180c3d344b6fddc7ac2d89aee06bdf947242c4</root>
        <type>c</type>
        <size>2025304567</size>
        <account>5t1sbe-s6zsgx-rtutxq </account>
    </backup>
</history>

PowerShell script

try {
    $username = '<API Token username>'
    $password = '<API Token password>'
    $userId = '<Account GUID>'
    $connectorId = '<Connector GUID>'
    $hostname = 'dk-co.keepit.com'

    $xmlBody = @"
<range>
    <start>2024-11-23T08:12:14Z</start>
    <span>P1M</span>
    <count>99</count>
</range>
"@

    $headers = @{
        "User-Agent"    = "PowerShell-Keepit-API-Agent-1.0"
        "Authorization" = "Basic $basicauth"
        "Content-Type"  = "application/xml"
    }

    $basicauth = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${username}:${password}"))

    $response = Invoke-WebRequest -UseBasicParsing `
      -Uri "https://${hostname}/users/${userId}/devices/${connectorId}/history/range" `
      -Method Put -Headers $headers -Body $xmlBody -ErrorAction Stop -TimeoutSec 10

    $xmlContent = [xml]$response.Content

    $xmlContent.SelectNodes("//tstamp") | ForEach-Object {
        $tstamp = $_.InnerText
        $type = $_.ParentNode.SelectSingleNode("type").InnerText
        $size = $_.ParentNode.SelectSingleNode("size").InnerText

        Write-Host "Timestamp: $tstamp, Type: $type, Size: $size"
    }
}
catch {
        $line = $_.InvocationInfo.ScriptLineNumber
        Write-Host "Cannot query Keepit API due to: $_"
        Write-Host "at line $line"
}

Script result

Timestamp: 2024-12-21T21:29:31Z, Type: c, Size: 2023899411
Timestamp: 2024-12-22T09:29:38Z, Type: c, Size: 2025304567
Timestamp: 2024-12-22T21:29:44Z, Type: c, Size: 2025304567

Additional information

The <span> element should use the ISO_8601 format:

  • M — the month designator, indicating the number of calendar months.
  • W — the week designator, indicating the number of weeks.
  • D — the day designator, indicating the number of calendar days.

Each designator follows the numeric value that represents the duration.

In this example, the period is one month – P1M.