Block a user
Chat
Block a user
Idempotent block. Severs the chat surface in both directions between the caller and the blocked user.
POST
Block a user
Overview
Records a directed block (callerUserId → blockedUserId) in the blocks collection. Block is directed, but every server-side gate uses areBlockedEither — a single block in either direction is enough to prevent contact. Consequences:
- The handshake endpoint (create conversation from match) returns
403 CONVERSATION_BLOCKEDfor any existing match between the two users. - Send message (and the equivalent
chat:message:sendsocket event) returns403 CONVERSATION_BLOCKEDif either side of an existing conversation tries to send. - The matcher (Phase 3+) treats a
blocksrow as a hard filter so no new match between the two users is ever produced.
blockedUserId is a no-op on the second call. The unique (blockerId, blockedId) index collapses the second insert into an update; the response is identical.
Authentication
Bearer <accessToken> required. requireOnboarded middleware applied.
Path parameters
None.Query parameters
None.Request body
| Field | Type | Required | Allowed values | Example |
|---|---|---|---|---|
blockedUserId | string | yes | 24-char hex ObjectId of the user to block. MUST differ from the caller — blocking yourself returns 400 VALIDATION_FAILED. | 66400a8f1c2b4d5e6f7a8b01 |
Example payload
Response — 200 OK
| Field | Type | Notes | Example |
|---|---|---|---|
blocked | boolean | Always true on success. Present as a positive ack for the mobile client. | true |
Example response
Error responses
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_FAILED | blockedUserId missing, not a 24-char hex ObjectId, or equal to the caller’s id (cannot block yourself). |
| 401 | UNAUTHENTICATED | Missing, malformed, or expired access token. |
| 403 | ONBOARDING_INCOMPLETE | Caller has not finished onboarding. |
Example error — 400 (self-block)
Side effects
- A
blocksrow is upserted withblockerId = caller,blockedId = blockedUserId. Re-calling with the same pair is a no-op. - Future calls to send message between the two users return
403 CONVERSATION_BLOCKED. - The matcher will not produce new matches between the two users.
See also
- Unblock user — the inverse.
- Report user — record a moderation report alongside (or instead of) a block.
- Match → Conversation handshake — explains the
CONVERSATION_BLOCKEDgate.