Users

User management operations

Get Current User Profile

get

Retrieves the profile of the currently authenticated user.

Authorizations
Responses
200
Current user profile data.
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": "[email protected]",
    "role": "user",
    "firstName": "text",
    "lastName": "text",
    "socialLinks": {
      "website": "text",
      "facebook": "text",
      "instagram": "text",
      "linkedin": "text",
      "x": "text",
      "youtube": "text"
    },
    "createdAt": "2025-07-28T18:46:02.088Z",
    "updatedAt": "2025-07-28T18:46:02.088Z"
  }
}

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
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": "[email protected]",
  "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": "[email protected]",
    "role": "user",
    "firstName": "text",
    "lastName": "text",
    "socialLinks": {
      "website": "text",
      "facebook": "text",
      "instagram": "text",
      "linkedin": "text",
      "x": "text",
      "youtube": "text"
    },
    "createdAt": "2025-07-28T18:46:02.088Z",
    "updatedAt": "2025-07-28T18:46:02.088Z"
  }
}

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.
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
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": "[email protected]",
      "role": "user",
      "firstName": "text",
      "lastName": "text",
      "socialLinks": {
        "website": "text",
        "facebook": "text",
        "instagram": "text",
        "linkedin": "text",
        "x": "text",
        "youtube": "text"
      },
      "createdAt": "2025-07-28T18:46:02.088Z",
      "updatedAt": "2025-07-28T18:46:02.088Z"
    }
  ]
}

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
get
GET /api/v1/users/{userId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
  "user": {
    "_id": "text",
    "username": "text",
    "email": "[email protected]",
    "role": "user",
    "firstName": "text",
    "lastName": "text",
    "socialLinks": {
      "website": "text",
      "facebook": "text",
      "instagram": "text",
      "linkedin": "text",
      "x": "text",
      "youtube": "text"
    },
    "createdAt": "2025-07-28T18:46:02.088Z",
    "updatedAt": "2025-07-28T18:46:02.088Z"
  }
}

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.
delete
DELETE /api/v1/users/{userId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*

No content

Was this helpful?