Moderation lock a user

This endpoint is only available to organization administrators.

POST https://orientir.chat.lgprk.ru/api/v1/users/{user_id}/moderation-lock

Organization administrators can immediately deactivate a user and/or delete messages they sent in a recent time window.

Designed for abuse incidents (e.g. a user posting insults in public channels): stop their access first, then purge channel messages from the last N hours. Direct messages are not deleted unless include_direct_messages is explicitly set to true.

Message deletion is processed in batches. If there are too many matching messages to finish in one request, the response will have complete set to false; call the endpoint again with the same parameters (typically with deactivate set to false if the user is already deactivated) until complete is true.

Deleted messages are archived on the server for the usual retention window and can be restored by a server administrator.

This is a custom LGPRK extension (not part of upstream Zulip).

Changes: Custom endpoint.

Usage examples

curl -sSX POST https://orientir.chat.lgprk.ru/api/v1/users/12/moderation-lock \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY \
    --data-urlencode deactivate=true \
    --data-urlencode delete_messages=true \
    --data-urlencode hours_ago=1 \
    --data-urlencode include_channels=true \
    --data-urlencode include_direct_messages=false \
    --data-urlencode 'deactivation_notification_comment=Your account was deactivated due to a policy violation.
'

Parameters

user_id integer required in path

Example: 12

The target user's ID.


deactivate boolean optional

Example: true

Whether to deactivate the user. Defaults to true.

Same rules as DELETE /users/{user_id}: organization administrators cannot deactivate organization owners, and the only organization owner cannot be deactivated.

Defaults to true.


delete_messages boolean optional

Example: true

Whether to delete messages sent by the user in the time window defined by hours_ago. Defaults to false.

When true, hours_ago is required, and at least one of include_channels or include_direct_messages must be true.

Defaults to false.


hours_ago integer optional

Example: 1

Delete messages sent by the user in the last N hours (server time). Required when delete_messages is true.

Must be an integer between 1 and 720 (30 days).


include_channels boolean optional

Example: true

Include channel (stream) messages in the deletion. Defaults to true.

Defaults to true.


include_direct_messages boolean optional

Example: false

Include 1:1 and group direct messages in the deletion. Defaults to false so private work conversations are not removed by accident.

Defaults to false.


deactivation_notification_comment string optional

Example: "Your account was deactivated due to a policy violation.\n"

If not null, and the user is deactivated by this request, send them a notification email about account deactivation. If not "", includes this custom comment.

Same semantics as on DELETE /users/{user_id}.


Response

Return values

  • deactivated: boolean

    Whether this request deactivated the user. false if deactivate was false, or the user was already deactivated.

  • channel_messages_deleted: integer

    Number of channel messages deleted in this request.

  • direct_messages_deleted: integer

    Number of direct messages deleted in this request.

  • messages_deleted: integer

    Total messages deleted in this request (channel_messages_deleted + direct_messages_deleted).

  • complete: boolean

    Whether all matching messages were deleted. If false, repeat the request to continue deletion.

  • hours_ago: integer | null

    Echo of the hours_ago parameter, or null when messages were not deleted.

  • since: string | null

    ISO 8601 timestamp used as the lower bound for message deletion, or null when messages were not deleted.

Example response(s)

Changes: As of Zulip 7.0 (feature level 167), if any parameters sent in the request are not supported by this endpoint, a successful JSON response will include an ignored_parameters_unsupported array.

A typical successful JSON response may look like:

{
    "channel_messages_deleted": 17,
    "complete": true,
    "deactivated": true,
    "direct_messages_deleted": 0,
    "hours_ago": 1,
    "messages_deleted": 17,
    "msg": "",
    "result": "success",
    "since": "2026-08-26T07:21:00.000000+00:00"
}

Example error when delete_messages is set without hours_ago.

{
    "code": "BAD_REQUEST",
    "msg": "hours_ago is required when delete_messages is true",
    "result": "error"
}