ModerationBlock UserBlock User

Block a User

Overview

Block a specified user to prevent them from having direct chats with the current user. After blocking, the blocked user will be unable to send private messages to the blocker, but this will not affect interactions in group chatrooms. This feature is suitable for preventing harassment and managing personal privacy.


API Endpoint

Block a Specified User

Add the specified user to the block list to prevent direct chatting.

POST /blockStatus/my/{blockee}

Headers

ParameterTypeRequiredDescription
IM-CLIENT-KEYstringClient Key
IM-AuthorizationstringClient Token

Path Parameters

ParameterTypeRequiredDescription
blockeestringID of the user to block

Example Request

Block a specific user

POST /blockStatus/my/ccc HTTP/1.1
IM-CLIENT-KEY: {IM-CLIENT-KEY}
IM-Authorization: {IM-Authorization}
Host: your-app.imkit.io
Connection: close

Block another user

POST /blockStatus/my/user123 HTTP/1.1
IM-CLIENT-KEY: {IM-CLIENT-KEY}
IM-Authorization: {IM-Authorization}
Host: your-app.imkit.io
Connection: close

JavaScript Example:

const response = await axios.post(
  `https://your-app.imkit.io/blockStatus/my/${blockee}`,
  {},
  {
    headers: {
      "IM-CLIENT-KEY": IM_CLIENT_KEY,
      "IM-Authorization": TOKEN,
    },
  }
);

cURL Example:

curl -X "POST" "https://your-app.imkit.io/blockStatus/my/{blockee}" \
     -H 'IM-CLIENT-KEY: {IM-CLIENT-KEY}' \
     -H 'IM-Authorization: {IM-Authorization}'

Response

Success Response (200 OK)

ParameterTypeDescription
RCnumberResponse code (0 indicates success)
RMstringResponse message
resultobjectBlock status information

Block Status Object Structure

ParameterTypeDescription
appIDstringApplication ID
blockeeobjectDetailed information of blocked user
blockerstringID of the user who performed the block
roomstringAssociated chatroom ID
createdAtstringBlock creation time
updatedAtstringBlock update time

Blocked User Object Structure

ParameterTypeDescription
_idstringUser unique ID
nicknamestringUser nickname
avatarUrlstringUser avatar URL
lastLoginTimeMSnumberLast login time (millisecond timestamp)

Example Response

{
  "RC": 0,
  "RM": "OK",
  "result": {
    "appID": "SampleApp",
    "blockee": {
      "_id": "ccc",
      "avatarUrl": "http://loremflickr.com/240/240/style?1628093667",
      "nickname": "Cathy",
      "id": "ccc",
      "lastLoginTimeMS": 1600006869368
    },
    "blocker": "aaa",
    "room": "2bec603e94a210092439e83ff2d79ac1",
    "createdAt": "2021-08-04T15:18:10.735Z",
    "updatedAt": "2021-08-04T16:35:41.341Z"
  }
}

Error Response

401 Unauthorized - Authentication failed

{
  "RC": 401,
  "RM": "Unauthorized",
  "error": {
    "code": "INVALID_TOKEN",
    "message": "Invalid or expired token"
  }
}

404 Not Found - User does not exist

{
  "RC": 404,
  "RM": "User not found",
  "error": {
    "code": "USER_NOT_FOUND",
    "message": "The specified user does not exist"
  }
}

400 Bad Request - Cannot block yourself

{
  "RC": 400,
  "RM": "Cannot block yourself",
  "error": {
    "code": "SELF_BLOCK_FORBIDDEN",
    "message": "Users cannot block themselves"
  }
}

409 Conflict - User is already blocked

{
  "RC": 409,
  "RM": "User already blocked",
  "error": {
    "code": "USER_ALREADY_BLOCKED",
    "message": "This user is already in your block list"
  }
}

Use Cases

Personal Privacy Protection

  • Prevent Harassment: Block inappropriate users from sending private messages
  • Privacy Management: Control who can directly contact you
  • Safety Protection: Guard against persistent harassment from malicious users

User Experience Improvement

  • Content Filtering: Avoid receiving unwanted message content
  • Environment Cleanup: Create a more comfortable chat environment
  • Focus on Work: Reduce unnecessary disturbances and interruptions

Community Management

  • Behavioral Standards: Take personal-level protective measures against rule-violating users
  • Conflict Resolution: Handle personal conflicts between users
  • Self-Management: Allow users to manage their own social circle

Notes

  • Direct Chat Only: Blocking only affects private chats and does not affect interactions in group chatrooms
  • Bidirectional Effect: After blocking takes effect, neither party can send private messages
  • Automatic Chatroom Creation: Blocking is associated with the corresponding direct chatroom
  • Cannot Block Self: Users cannot block their own account
  • Duplicate Blocking: Blocking an already blocked user will return a conflict error
  • Persistent Status: The block status persists until manually unblocked
© 2026 FUNTEK Software Inc. All rights reserved.