API Docs
Users Model
Add a User
11 min
api endpoint documentation /api/users/add description this endpoint allows you to add one or more users to the system by sending a post request the request body contains user details such as name, email, password, and associated groups endpoint post https //admin \<your site> com/api/users/add 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 an array of user objects to be added each user object contains the following fields name string the name of the user email string the email address of the user password string (optional) the password for the user confirm password string (optional) the password confirmation for the user image string (optional) the url of the user's profile image type string the role or type of the user (e g , user , admin ) notifications boolean specifies whether the user will receive notifications update boolean indicates if the user's information should be updated groups array an array of group objects associated with the user each group contains id string the group id workspace id object the workspace object associated with the group id string the workspace id name string the workspace name name string the group name permissions array an array of permission objects associated with the group token string a valid authentication token (jwt) for adding users example request body { "users" \[ { "name" "matthew kastner", "email" "matthew\@clearsquare co", "password" "", "confirm password" "", "image" "", "type" "user", "notifications" false, "update" true, "groups" \[ { " id" "756676a679549784d96514a2", "workspace id" { " id" "6567745179549784d96513ae", "name" "internal employees" }, "name" "basic users", "permissions" \[ { " id" "656faf7879549784d967e2bv", "page id" "656faa7c79549784d967dfab", "filters" \[] } ] } ] } ], "token" "eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9 " } method post sends a request to add the specified user(s) to the system example request (node js) const fetch = require('node fetch'); const url = 'https //admin \<your site> com/api/users/add'; const options = { method 'post', headers { 'accept' 'application/json', 'accept language' 'en us,en;q=0 9', 'authorization' 'bearer eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9 ', 'content type' 'application/json' }, body json stringify({ users \[ { name "matthew kastner", email "matthewkastner\@gmail com", password "", confirm password "", image "", type "user", // options \["user", "editor"", "admin"] notifications false, update true, groups \[ // assign the user to a group within a workspace { id "756676a679549784d96514a2", // group id workspace id { id "6567745179549784d96513ae", name "internal employees" }, name "basic users", // group name permissions \[ { id "656faf7879549784d967e2bv", page id "656faa7c79549784d967dfab", filters \[] } ] } ] } ], token "eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9 " }) }; 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) { "message" "user(s) added successfully", "status" "success" } error response (400/401) { "message" "invalid token or request body", "status" "error" } authentication this api requires a valid jwt token for authentication ensure that the token is included in the authorization header as bearer \<jwt token> usage notes the users array can contain multiple users to be added in one request ensure that each user has a unique email address in the system a valid jwt token must be included in the authorization header, otherwise the request will fail