Layer 220
method Users
messages.deleteHistory#b08f922a flags:# just_clear:flags.0?true revoke:flags.1?true peer:InputPeer max_id:int min_date:flags.2?int max_date:flags.3?int = messages.AffectedHistory;

Parameters

Name Type Description
Flags # Flags, see TL conditional fields
JustClear flags.0?true Just clear history for the current user, without actually removing messages for every chat user
Revoke flags.1?true Whether to delete the message history for all chat participants
Peer InputPeer User or chat, communication history of which will be deleted
MaxId int Maximum ID of message to delete
MinDate flags.2?int Delete all messages newer than this UNIX timestamp
MaxDate flags.3?int Delete all messages older than this UNIX timestamp

Possible Errors

Code Type Description
400 CHANNEL_PRIVATE You haven't joined this channel/supergroup.
400 CHAT_ADMIN_REQUIRED You must be an admin in this chat to do this.
400 CHAT_ID_INVALID The provided chat id is invalid.
400 CHAT_REVOKE_DATE_UNSUPPORTED min_date and max_date are not available for using with non-user peers.
400 MAX_DATE_INVALID The specified maximum date is invalid.
400 MESSAGE_ID_INVALID The provided message id is invalid.
400 MIN_DATE_INVALID The specified minimum date is invalid.
400 MSG_ID_INVALID Invalid message ID provided.
400 PEER_ID_INVALID The provided peer id is invalid.

Gogram Example

// MessagesDeleteHistory - using Params struct
result, err := client.MessagesDeleteHistory(&tg.MessagesDeleteHistoryParams{
    Peer: &tg.InputPeerUser{UserID: int64(123456789)},
    MaxId: 0,

    // Optional fields:
    // JustClear: true,
    // Revoke: true,
    // MinDate: 0,
    // MaxDate: 0,
})
if err != nil {
    // handle error
}
// result is *tg.MessagesAffectedHistory