API Documentation

Update account settings

This command updates the settings of an account. It can be executed either directly at the account level or from the parent account.

API request 

Method PUT 

/users/{user-id}

Elements schema

element user_update { 
 element enabled { boolean }? 
 & element subscribed { boolean }? 
 & element product { text }? # 
 & element grace-expires { iso8601-datetime or empty }? 
 & element parent { text }?
} 

Field names and descriptions

product - ID of the product. Empty value removes product assignment from the account.
parent - GUID of the new parent account

Example

Method PUT

https://dk-co.keepit.com/users/psmqd-3nqijs-9qi26x/

Body

<user_update>
<product>a9y02y-qngj1m-yvh5r8</product>
</user_update>

Result

PowerShell script

try { 
    # Define the API credentials 
    $username = '<API Token username>' 
    $password = '<API Token password>' 


    # Define the subaccount ID and product ID 
    $subaccountID = '<Subaccount GUID>' 
    $productID = '<Product ID>' 

     
    # 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" 
        "Content-Type" = "application/xml" 
    } 


    # Construct the URL with the subaccount ID 
    $url = "https://dk-co.keepit.com/users/$subaccountID/" 

 
    # Define the body of the PUT request as XML, using the provided ProductID 
    $xmlBody = @" 
<user_update> 
    <product>$productID</product> 
</user_update> 
"@ 
 

    # Send the PUT request with the XML body 
    $response = Invoke-WebRequest -Uri $url -Method Put -Headers $headers -Body $xmlBody -ErrorAction Stop -TimeoutSec 10 

 
    # Display the response 
    Write-Host $response.Content 
} 
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" 
} 

Additional information

  • This allows an account to be enabled or disabled, and it allows the product to be changed and the external_id to be changed. To clear the product, supply an empty string for the product.
  • When an account is disabled, authentication for that account will fail.
  • Only system-type tokens can set grace-expires. If grace-expires element is empty, grace time will be unset for this account.
  • If the parent element is set, this will move the account to the new parent GUID. Only an administrator or partner token can move an account, and the parent can only be set to an account at or beneath the authenticated account.