User · API Reference

API — User

Tài liệu các endpoint của module user. Mỗi endpoint có request format, response format, lỗi có thể xảy ra và ví dụ thực tế.

Tóm tắt endpoint

MethodPathMô tảAuthRate limit
GET/api/v1/me/followersFollowers của user hiện tại.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
POST/api/v1/me/:username/friend-requestsGửi friend request.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
PATCH/api/v1/me/friend-requests/:username/cancelHủy request.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
PATCH/api/v1/me/friend-requests/:username/acceptAccept/reject request.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/me/friend-requests/receivedRequest nhận được.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/me/friend-requests/sentRequest đã gửi.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/users/mentionSearch username để mention.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/users/:usernameProfile by username.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/users/me/karmaKarma. [CẦN XÁC NHẬN] response mock.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/users/me/badgesBadges. [CẦN XÁC NHẬN] response mock.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/user/:username/followersFollowers public.PublicGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/user/:username/followingFollowing public.PublicGlobal apiLimiter; một số flow có Redis/domain limit riêng.
POST/api/v1/user/:username/followerToggle follow.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.

GET /api/v1/me/followers

GET Auth required apiLimiter

Endpoint này dùng để followers của user hiện tại. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/me/followers \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/me/followers"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

POST /api/v1/me/:username/friend-requests

POST Auth required apiLimiter

Endpoint này dùng để gửi friend request. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectTùy endpointTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X POST http://localhost:3302/api/v1/me/alice/friend-requests \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/me/:username/friend-requests"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

PATCH /api/v1/me/friend-requests/:username/cancel

PATCH Auth required apiLimiter

Endpoint này dùng để hủy request. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectTùy endpointTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X PATCH http://localhost:3302/api/v1/me/friend-requests/alice/cancel \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/me/friend-requests/:username/cancel"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

PATCH /api/v1/me/friend-requests/:username/accept

PATCH Auth required apiLimiter

Endpoint này dùng để accept/reject request. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectTùy endpointTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X PATCH http://localhost:3302/api/v1/me/friend-requests/alice/accept \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/me/friend-requests/:username/accept"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/me/friend-requests/received

GET Auth required apiLimiter

Endpoint này dùng để request nhận được. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/me/friend-requests/received \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/me/friend-requests/received"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/me/friend-requests/sent

GET Auth required apiLimiter

Endpoint này dùng để request đã gửi. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/me/friend-requests/sent \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/me/friend-requests/sent"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/users/mention

GET Auth required apiLimiter

Endpoint này dùng để search username để mention. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/mention \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/users/mention"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/users/:username

GET Auth required apiLimiter

Endpoint này dùng để profile by username. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/alice \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/users/:username"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/users/me/karma

GET Auth required apiLimiter

Endpoint này dùng để karma. [CẦN XÁC NHẬN] response mock. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/me/karma \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/users/me/karma"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/users/me/badges

GET Auth required apiLimiter

Endpoint này dùng để badges. [CẦN XÁC NHẬN] response mock. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/users/me/badges \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/users/me/badges"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/user/:username/followers

GET Auth varies apiLimiter

Endpoint này dùng để followers public. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenKhông/Tùy routeJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/user/alice/followers \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/user/:username/followers"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/user/:username/following

GET Auth varies apiLimiter

Endpoint này dùng để following public. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenKhông/Tùy routeJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/user/alice/following \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/user/:username/following"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

POST /api/v1/user/:username/follower

POST Auth required apiLimiter

Endpoint này dùng để toggle follow. Gọi endpoint này khi client cần thao tác đúng phạm vi module user.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectTùy endpointTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X POST http://localhost:3302/api/v1/user/alice/follower \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "user",
    "endpoint": "/api/v1/user/:username/follower"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú