Add users in bulk to a private workspace using an API

Hi VIKTOR community,

I am busy creating an option to add users in bulk to a private workspace using VIKTOR’s external API. I note that the documentation does not explicitly define this yet (if it does, then please share the link). In trying to figure this out, I came this far:

import requests
import json

url = "https://<environment>"

payload = json.dumps({
  "access_group": 999,
  "id": 111,
  "is_ws_admin": False
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': '<API_KEY_VALUE>'

response = requests.request("POST", url, headers=headers, data=payload)


My questions:

  • Which payload variables are required, and which are nullable?
  • What would be an easy way to obtain the access_group id? And if this is a nullable variable, will this by default add the user to the default group?
  • It is not entirely clear what the variable id represents. Could this be explained.

Thanks in advance!

PS this post is made to share and promote questions, requests, or conversations held outside the community to make this knowledge sharable for the broader community. @TH-MDR , this post is relevant for you.

By the way, if anyone is looking for handy API tools, check out this repository:

With the development tools you can for example add users in bulk to the VIKTOR environment, copy entities, etc.

If it’s not in the documentation it’s not officially supported. This means that it can change without prior notice so be careful in depending on this.

To point you in the right direction:

  • there is another endpoint to get the usergroups, these will give you the ids you need, im not sure sending null works
  • the id means the user id, the identifier of that specific user

It would be good if this usecase does not necessitate the API. Do i understand it correctly that you need to:

  • add users in bulk to the environment
  • add those users in bulk to a private workspace

BTW, i just checked and saw that it is unfortunately not possible to copy paste a list of users to be added to private workspace, will checkout if this is something we can easily add and create an internal ticket for this

In case you simply want to add these users to the Default User Group of the specific Workspace:

The API docs for fetching Workspaces shows the response containing a "default_group" key, which provides the id of the User Group that is currently set as default. You could use that for the access_group

we have picked up the implementation of this feature (allowing copy-pasting a list of users in the workspace-invite)

1 Like