User Management

Number of APIs: 7

πŸ‘€ Get started here

This collection demonstrates how to structure a user management REST API that contains endpoints for user registration, login, profile management, and more.

Users created using this API can perform tasks like registering, logging in, and updating their profiles. Users who are assigned an 'admin' role can perform all tasks, including getting a list of all users and deleting user profiles.

πŸ” Authentication and authorization

You must have a valid bearer token to use the API added in this template. When you send the Register request, you will receive a token in the response. The Register request also contains a test script that sets the token in the accessToken collection variable so you can reuse it in other requests easily.

To send the requests in the Admin folder, you need to have admin permissions. You can grant yourself admin permissions using the Register request by adding a key named role with admin as the value in the request body.

πŸ”– How to use this collection?

Step 1: Send the requests

Check out the different parts of the requests, including the request body, documentation, headers, tests, and URL parameters. Send the requests to view the response returned by the API.

Here’s the order of requests in which you can explore this API to understand it better without running into any hiccups:

Register β†’ Log in β†’ Get profile β†’ Update profile β†’ Change user role β†’ Get all users β†’ Delete user

Step 2: Customize the requests

Add your API’s base URL in the url collection variable. Update the request body wherever needed and send the requests to test your API.

Step 3: Continue building the collection

Create requests in this collection to test the new API endpoints you develop.

ℹ️ Resources

[Creating a REST API with Node.js and Express]
GitHub repo for the Node.js tutorial
[Building requests]
[Authorizing requests]
[Using variables]
[Creating your first collection]

  1. Authentication - Register POST {{url}}/signup

  2. Authentication - Log in POST {{url}}/login

  3. User - Get profile GET {{url}}/user

  4. User - Update profile PATCH {{url}}/user

  5. Admin - Change user role PATCH {{url}}/user/change-role/:userId

  6. Admin - Delete user DELETE {{url}}/user/:userId

  7. Admin - Get all users GET {{url}}/user/all