API Docs
Users Model
Assign Users to Workspaces (and Groups)
12min
api endpoint documentation /api/users/workspace assign description this endpoint allows you to assign multiple users to one or more workspaces and groups by sending a post request the request body contains user ids, workspace ids, and group ids to establish these assignments endpoint post https //admin \<your site> com/api/users/workspace assign headers accept application/json specifies that the request expects a json response authorization bearer \<jwt token> a json web token (jwt) that authenticates the request replace \<jwt token> with a valid token content type application/json specifies that the request body is in json format request body the request body should be in json format, containing the following fields workspaces array an array of workspace ids to which the users will be assigned userids array an array of user ids to be assigned to the workspaces groups array (optional) an array of group ids to which the users will be assigned within the workspaces example request body { "workspaces" \["67fc8f559c24f8e146543697"], "userids" \[ "6762c9a8dea46c90b1d924ec", "67a350d93e2da4d0491687f0", "6633bd2b946db532e13a7286" ], "groups" \[ "6804317449913c261b1b3c6f", "6806af86ee8f019a1266b9ed" ] } method post sends a request to assign the specified users to the specified workspaces and groups example request (node js) const fetch = require('node fetch'); const url = 'https //admin \<your site> com/api/users/workspace assign'; const options = { method 'post', headers { 'accept' 'application/json', 'authorization' 'bearer eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9 ', 'content type' 'application/json' }, body json stringify({ workspaces \["67fc8f559c24f8e146543697"], userids \[ "6762c9a8dea46c90b1d924ec", "67a350d93e2da4d0491687f0", "6633bd2b946db532e13a7286" ], groups \[ "6804317449913c261b1b3c6f", "6806af86ee8f019a1266b9ed" ] }) }; fetch(url, options) then(response => response json()) then(data => console log(data)) catch(error => console error('error ', error)); response the api will return a json response indicating the success or failure of the operation success response (200) { "status" 200, "message" "users successfully assigned to workspaces " } error response (400) { "status" 400, "message" "please select at least one user " } or { "status" 400, "message" "please select a valid user " } authentication this api requires a valid jwt token for authentication and admin privileges ensure that the token is included in the authorization header as bearer \<jwt token> usage notes this endpoint requires admin privileges to use you can assign multiple users to multiple workspaces in a single request the system will automatically update the user's type based on their permissions if no users are selected, the request will fail with a 400 error if an invalid user id is provided, the request will fail with a 400 error