馃摌
Blog API
  • Documentation
  • API References
  • Root
  • Authentication
  • Users
  • Blogs
  • Likes
  • Comments
  • Models
Powered by GitBook

漏 2025 codewithsadee

On this page

Was this helpful?

Export as PDF

Users

PreviousAuthenticationNextBlogs

Was this helpful?

User management operations

Delete Current User Account

delete

Deletes the account of the currently authenticated user and their associated data.

Authorizations
Responses
204
Request successful, no response body.
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
500
An unexpected error occurred on the server.
application/json
delete
DELETE /api/v1/users/current HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*

No content

Get All Users (Admin)

get

Retrieves a paginated list of all users. Admin role required.

Authorizations
Query parameters
limitinteger 路 min: 1 路 max: 50Optional

Maximum number of items to return.

Default: 20
offsetintegerOptional

Number of items to skip for pagination.

Default: 0
Responses
200
A list of users.
application/json
400
Invalid input data provided. See errors object for details.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
403
Access denied due to insufficient permissions.
application/json
500
An unexpected error occurred on the server.
application/json
get
GET /api/v1/users/ HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
  "limit": 1,
  "offset": 1,
  "total": 1,
  "users": [
    {
      "_id": "text",
      "username": "text",
      "email": "name@gmail.com",
      "role": "user",
      "firstName": "text",
      "lastName": "text",
      "socialLinks": {
        "website": "text",
        "facebook": "text",
        "instagram": "text",
        "linkedin": "text",
        "x": "text",
        "youtube": "text"
      },
      "createdAt": "2025-06-07T21:00:04.094Z",
      "updatedAt": "2025-06-07T21:00:04.094Z"
    }
  ]
}

Get User by ID (Admin)

get

Retrieves profile information for a specific user. Admin role required.

Authorizations
Path parameters
userIdstring 路 objectidRequired

ID of the user.

Responses
200
Specific user profile data.
application/json
400
Invalid input data provided. See errors object for details.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
403
Access denied due to insufficient permissions.
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
get
GET /api/v1/users/{userId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
  "user": {
    "_id": "text",
    "username": "text",
    "email": "name@gmail.com",
    "role": "user",
    "firstName": "text",
    "lastName": "text",
    "socialLinks": {
      "website": "text",
      "facebook": "text",
      "instagram": "text",
      "linkedin": "text",
      "x": "text",
      "youtube": "text"
    },
    "createdAt": "2025-06-07T21:00:04.094Z",
    "updatedAt": "2025-06-07T21:00:04.094Z"
  }
}

Delete User by ID (Admin)

delete

Deletes a specific user account and their associated data. Admin role required.

Authorizations
Path parameters
userIdstring 路 objectidRequired

ID of the user.

Responses
204
Request successful, no response body.
400
Invalid input data provided. See errors object for details.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
403
Access denied due to insufficient permissions.
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
delete
DELETE /api/v1/users/{userId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*

No content

  • GETGet Current User Profile
  • PUTUpdate Current User Profile
  • DELETEDelete Current User Account
  • GETGet All Users (Admin)
  • GETGet User by ID (Admin)
  • DELETEDelete User by ID (Admin)

Get Current User Profile

get

Retrieves the profile of the currently authenticated user.

Authorizations
Responses
200
Current user profile data.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
500
An unexpected error occurred on the server.
application/json
get
GET /api/v1/users/current HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
  "user": {
    "_id": "text",
    "username": "text",
    "email": "name@gmail.com",
    "role": "user",
    "firstName": "text",
    "lastName": "text",
    "socialLinks": {
      "website": "text",
      "facebook": "text",
      "instagram": "text",
      "linkedin": "text",
      "x": "text",
      "youtube": "text"
    },
    "createdAt": "2025-06-07T21:00:04.094Z",
    "updatedAt": "2025-06-07T21:00:04.094Z"
  }
}

Update Current User Profile

put

Updates the profile of the currently authenticated user.

Authorizations
Body
usernamestring 路 max: 20Optional

User's unique username

emailstring 路 email 路 max: 50Optional

User's unique email address

passwordstring 路 min: 8Write-onlyOptional

New password (min 8 chars)

first_namestring 路 max: 20Optional

User's first name

last_namestring 路 max: 20Optional

User's last name

websitestring 路 url 路 max: 100Optional
facebookstring 路 url 路 max: 100Optional
instagramstring 路 url 路 max: 100Optional
linkedinstring 路 url 路 max: 100Optional
xstring 路 url 路 max: 100Optional
youtubestring 路 url 路 max: 100Optional
Responses
200
User profile updated successfully.
application/json
400
Invalid input data provided. See errors object for details.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
put
PUT /api/v1/users/current HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 201

{
  "username": "text",
  "email": "name@gmail.com",
  "password": "text",
  "first_name": "text",
  "last_name": "text",
  "website": "text",
  "facebook": "text",
  "instagram": "text",
  "linkedin": "text",
  "x": "text",
  "youtube": "text"
}
{
  "user": {
    "_id": "text",
    "username": "text",
    "email": "name@gmail.com",
    "role": "user",
    "firstName": "text",
    "lastName": "text",
    "socialLinks": {
      "website": "text",
      "facebook": "text",
      "instagram": "text",
      "linkedin": "text",
      "x": "text",
      "youtube": "text"
    },
    "createdAt": "2025-06-07T21:00:04.094Z",
    "updatedAt": "2025-06-07T21:00:04.094Z"
  }
}