Admin API


The Admin API provides interfaces for user management.

Authentification

In order to call the Admin APIs such a client must be registrated in the primedocs.config, for this see .

After registration, an AccessToken can be requested from the IdS.

This PowerShell example shows the AccessToken’s request:

# Configuration $datasourceId = "b78c3707-d7c7-4fc7-b97f-87d70f63c1ac" $tokenUrl = "https://customerserver.local/ids/connect/token" $clientID = "CustomApiClient" $clientSecret = "CustomClient_Secret_123" $scope = "pd_AdminWebApi" $tokenRequestHeaders = @{ "Content-Type" = "application/x-www-form-urlencoded" } $tokenRequestBody = @{ client_id = $clientID client_secret = $clientSecret grant_type = "client_credentials" scope = $scope } # Request the access token try { $tokenResponse = Invoke-RestMethod -Uri $tokenUrl -Method POST -Headers $tokenRequestHeaders -Body $tokenRequestBody } catch { Write-Error "Error making the request: $_" exit 1; } if (-not $tokenResponse.access_token) { Write-Error "Failed to obtain an access token!" exit 1 } # Access token information Write-Host "Access Token: $($tokenResponse.access_token)" $accessToken = $tokenResponse.access_token

Examples

This AccessToken must be included in the Authorization header for all calls. The API currently allows users to be listed, created and edited. Examples can be found below

List users

This lists existing users:

# Prepare headers for request $apiRequestHeaders = @{ "Authorization" = "Bearer $accessToken" } Write-Host "Getting users..." $pageSize = Read-Host "Enter pagesize" $page = Read-Host "Enter page" try { $apiUrl = "https://customerserver.local/webapi/api/v3/$($datasourceId)/Admin/Users?pageSize=$($pageSize)&page=$($page)" $response = Invoke-RestMethod -Uri $apiUrl -Method GET -Headers $apiRequestHeaders foreach ($user in $response.data) { Write-Output "$($user.id): '$($user.title)'" } Write-Output "Page: $($response.pagingDetails.page) / $($response.pagingDetails.totalPages)" } catch { Write-Error "Error making the request: $_" exit 1; }

User onboarding

This call can be used to add a new user using the SID. The process is then run automatically.

# Prepare headers for request $apiRequestHeaders = @{ "Authorization" = "Bearer $accessToken" } $sid = Read-Host "Enter SID" Write-Host "Creating and onboarding user with SID: $sid" try { $apiUrl = "https://customerserver.local/webapi/api/v3/$($datasourceId)/Admin/Users?sid=" + $sid; $user = Invoke-RestMethod -Uri $apiUrl -Method POST -Headers $apiRequestHeaders Write-Output "Onboarded '$($user.title)' with id '$($user.id)'"; } catch { Write-Error "Error making the request: $_" exit 1; }

Swagger / Open API

The current Admin API Open API looks like the following in the version 4.0.20122.

You can visualize this description for example via the Swagger Editor.

PrimeSoft AG, Bahnhofstrasse 4, 8360 Eschlikon, Switzerland