Block / Unblock User
Overview
Block or unblock another chat participant from the signed-in user's perspective. Blocking stops messaging that person without deleting either chat account.
Send the target userId and a type of block or unblock. Typical chat actions: safety menu on a contact profile, or unblock from settings.
When to use this endpoint?
Use Block / Unblock when:
- A chat participant taps Block on a contact or conversation.
- Your report / safety flow ends in stopping messages from that peer.
- They reverse a previous block (
type: "unblock"). - You need a reversible restriction instead of deleting a chat account.
Part of the Chat UserAPIs. Requires the chat user Bearer token for the acting participant. Pass the other person's id - you cannot block yourself.
{baseUrl}/api/{apiVersion}/user/block-unblock- Authentication
- Required (Bearer token)
- Tenant-scoped
- Yes (tenant DB - requires x-client-id)
Request Headers
Request Payload
Both fields are required on every call:
Block
{ "userId": "694b...a1", "type": "block"}Unblock
{ "userId": "694b...a1", "type": "unblock"}Success Response (HTTP 200 OK)
On success, the API confirms the action. data may be null; rely on message for UI feedback.
{ "success": true, "message": "User blocked successfully", "data": null, "error": null}Common Errors
Block / unblock fails when the token is missing or the target user does not exist.
HTTP 401 Unauthorized - No token
{ "success": false, "message": "No token, authorization denied", "data": null, "error": "Unauthorized"}HTTP 404 Not Found - User missing
{ "success": false, "message": "User not found", "data": null, "error": "User not found"}Best Practices
- Optimistic UI: toggle Block in the chat profile menu immediately, then roll back if the API errors.
- Hide or disable the message composer for blocked peers after a successful block.
- Block is personal to the acting chat user - it is not a tenant-wide ban and not the same as Delete User.
- Always send tenant headers with the chat user Bearer token over HTTPS.
Block state updated
Update conversation lists and contact menus to reflect the new state, then offer unblock from chat settings when needed.