API Docs
Users

Add a User

11min

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:

Text


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:

JSON


Method:

  • POST: Sends a request to add the specified user(s) to the system.

Example Request (Node.js):

JS


Response:

The API will return a JSON response indicating the success or failure of the operation.

Success Response (200):

JSON


Error Response (400/401):

JSON


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.



Updated 09 Oct 2024
Doc contributor
Did this page help you?