Account

This page contains the documentation for the account endpoints.

The account endpoints allow you to register an account, get an API key, validate your key, get users' details, and edit a user's details.

Register an Account

post
/auth/register

This endpoint allows you to register a user. Once registered, it will return an API key.

Body
namestringRequired

The name of the user.

emailstring · emailRequired

The email address of the user.

passwordstringRequired

The password for the account.

adminbooleanOptional

Specifies whether the user has administrative privileges.

Default: false
Responses
post
/auth/register
POST /auth/register HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 70

{
  "name": "john doe",
  "email": "[email protected]",
  "password": "123456"
}
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cBGlR1fkzXQKgxLshzVL2lcajQNXEUTH09N-csr98"
}

Get an API key

post
/auth/login

This endpoint allows you to login to an account and retrieve an API key.

Body
emailstring · emailRequired

The email address of the user.

passwordstringRequired

The password of the account.

Responses
post
/auth/login
POST /auth/login HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 52

{
  "email": "[email protected]",
  "password": "123456"
}
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNjc0ODhjYWE4ZGQxZmYzZDNlYjk0NTQxIiwiYWRtaW4iOnRydWV9LCJpYXQiOjE3MzI4MDc4ODEsImV4cCI6MTczMjg0Mzg4MX0.aFBDj34nuuNkt95G71QbL7KJTotLyNE0Lu9BKe4Zv0s",
  "user": {
    "_id": "67488caa8dd1ff3d3eb94541",
    "name": "test name",
    "email": "[email protected]",
    "password": "$2a$10$767ZSzTiC0Jm.8p/Jmyx1eqnciqWn7GCUDA/I7AbiTgmqHfJc/mfC",
    "admin": true,
    "__v": 0
  }
}

Validate API key

get
/auth/validate

This endpoint allows you to validate your API key.

Authorizations
AuthorizationstringRequired

Provide your API key.

Responses
get
/auth/validate
GET /auth/validate HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
{
  "authenticate": true,
  "admin": false
}

Get Users

get
/users/get_all/{page}

This endpoint allows you to get the info about the users in the application.

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired

Provide your API key.

Path parameters
pageinteger · min: 1Required

The page number to retrieve (1-based index). Each page returns 20 users.

Responses
get
/users/get_all/{page}
GET /users/get_all/{page} HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
{
  "totalUsers": 51,
  "adminUsers": 11,
  "regularUsers": 40,
  "users": [
    {
      "_id": "6555a0f89feeac7dccd9b1dd",
      "name": "first account",
      "email": "[email protected]",
      "password": "$2a$10$jK1bvjH7D/pdjI6mVb9uSuXMeWwcFwhlBYIh7Wqf0CLsey9I3Epx2",
      "admin": false,
      "__v": 0
    }
  ]
}

Edit User Details

post
/users/edit

This endpoint allows you to edit a user's details. This requires admin privileges.

Required scopes
This endpoint requires the following scopes:
Authorizations
AuthorizationstringRequired

Provide your API key.

Body
userIdstringOptional

The user ID of the account to modify. You can get the list of user ID by using the POST /users/get_all/{page} endpoint.

newNamestringOptional

The new name for the user.

newEmailstring · emailOptional

The new email for the user.

newAdminStatusbooleanOptional

The new admin status for the user.

  • true: The user has admin privileges.
  • false: The user does not have admin previleges.
Responses
post
/users/edit
POST /users/edit HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 116

{
  "userId": "674605a2a18c2f38f2148601",
  "newName": "Jane Doe",
  "newEmail": "[email protected]",
  "newAdminStatus": true
}
{
  "user": {
    "_id": "674605a2a18c2f38f2148601",
    "name": "Jane Doe",
    "email": "[email protected]",
    "password": "$2a$10$eaixU5.H3PFYW.9V6NM8A.A.CPnFHtbcWPWsp/I1NWsfxqIG6s87K",
    "admin": false,
    "__v": 0
  }
}

Last updated