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

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
200
Successful response. Returns an object containing the API key.
application/json
post
POST /auth/register HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 70

{
  "name": "john doe",
  "email": "john_doe12@gmail.com",
  "password": "123456"
}
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cBGlR1fkzXQKgxLshzVL2lcajQNXEUTH09N-csr98"
}

Get an API key

post

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
200
Successful response. Returns an object containing the API key and the information about the user.
application/json
post
POST /auth/login HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 52

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

Validate API key

get

This endpoint allows you to validate your API key.

Authorizations
Responses
200
Successful response. Returns an object containing information related to the user's access privilege.
application/json
get
GET /auth/validate HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
{
  "authenticate": true,
  "admin": false
}

Get Users

get

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

Authorizations
Path parameters
pageinteger · min: 1Required

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

Responses
200
Successful response. Returns an object with users statistics in the application.
application/json
get
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": "first_account@gmail.com",
      "password": "$2a$10$jK1bvjH7D/pdjI6mVb9uSuXMeWwcFwhlBYIh7Wqf0CLsey9I3Epx2",
      "admin": false,
      "__v": 0
    }
  ]
}

Edit User Details

post

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

Authorizations
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
200
Successful response. Returns an object containing user information.
application/json
post
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": "jane_example@gmail.com",
  "newAdminStatus": true
}
{
  "user": {
    "_id": "674605a2a18c2f38f2148601",
    "name": "Jane Doe",
    "email": "jane_example@gmail.com",
    "password": "$2a$10$eaixU5.H3PFYW.9V6NM8A.A.CPnFHtbcWPWsp/I1NWsfxqIG6s87K",
    "admin": false,
    "__v": 0
  }
}

Last updated