For the complete documentation index, see llms.txt. This page is also available as Markdown.

Authentication

User authentication operations

Register New User

post

Creates a new user account. Admin registration requires whitelisted email.

Body
emailstring ยท email ยท max: 50Required

User's email address

passwordstring ยท min: 8Write-onlyRequired

User's password

rolestring ยท enumOptional

User role (optional for registration)

Possible values:
Responses
201

User registered successfully. Sets refreshToken cookie.

application/json
accessTokenstringOptional

JWT Access Token

post/auth/register
POST /api/v1/auth/register HTTP/1.1
Host: blog-api.codewithsadee.com
Content-Type: application/json
Accept: */*
Content-Length: 59

{
  "email": "name@gmail.com",
  "password": "text",
  "role": "admin"
}
{
  "accessToken": "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": "2026-01-01T00:00:00.000Z",
    "updatedAt": "2026-01-01T00:00:00.000Z"
  }
}

Login User

post

Authenticates a user and returns tokens.

Body
emailstring ยท email ยท max: 50Required

User's email address

passwordstring ยท min: 8Write-onlyRequired

User's password

rolestring ยท enumOptional

User role (optional for registration)

Possible values:
Responses
200

Login successful. Sets refreshToken cookie.

application/json
accessTokenstringOptional

JWT Access Token

post/auth/login
POST /api/v1/auth/login HTTP/1.1
Host: blog-api.codewithsadee.com
Content-Type: application/json
Accept: */*
Content-Length: 59

{
  "email": "name@gmail.com",
  "password": "text",
  "role": "admin"
}
{
  "accessToken": "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": "2026-01-01T00:00:00.000Z",
    "updatedAt": "2026-01-01T00:00:00.000Z"
  }
}

Refresh Access Token

post

Generates a new access token using the refresh token cookie.

cookie
refreshTokenstring ยท jwtRequired

HTTP-only refresh token cookie.

Responses
200

Access token refreshed successfully.

application/json
accessTokenstringOptional

JWT Access Token

post/auth/refresh-token
POST /api/v1/auth/refresh-token HTTP/1.1
Host: blog-api.codewithsadee.com
Accept: */*
{
  "accessToken": "text"
}

Logout User

post

Invalidates the refresh token and clears the cookie. Requires both access and refresh tokens.

Authorizations
AuthorizationstringRequired

JWT Access Token obtained via login/register/refresh

cookie
refreshTokenstring ยท jwtRequired

HTTP-only refresh token cookie.

Responses
200

Logout successful. Clears refreshToken cookie.

application/json
messagestringOptional
post/auth/logout
POST /api/v1/auth/logout HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "message": "Logged out successfully"
}

Last updated

Was this helpful?