# Clearing private message chats via API

**URL:** <https://forums.rocket.chat/t/clearing-private-message-chats-via-api/21681>\
**Category:** Community Support\
**Created:** [February 22, 2025, 1:46pm UTC](https://forums.rocket.chat/t/clearing-private-message-chats-via-api/21681 "2025-02-22T13:46:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vladimir](https://avatars.discourse-cdn.com/v4/letter/v/94ad74/32.png) [@Vladimir](https://forums.rocket.chat/u/Vladimir)\
**Post date:** [February 22, 2025, 1:46pm UTC](https://forums.rocket.chat/t/clearing-private-message-chats-via-api/21681/1 "2025-02-22T13:46:18Z")

</div>

### Description

Good day.  
Please help, does the (/api/v1/rooms.cleanHistory) not work in RocketChat 7 for direct messages?

In version 6 we used it to clean up some people’s messages in direct chats. Is this not allowed now?

Now when I call it, I get an error:  
{“success”:false,“error”:“User does not have access to the room [error-not-allowed]”

The permissions “clean-channel-history” are on.

### Server Setup Information

- Version of Rocket.Chat Server: 7.3.1
- Operating System: ubuntu 20
- Deployment Method: snap

---

<div class="post-metadata">

**Author:** ![reetp](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/reetp/32/5546_2.png) [@reetp](https://forums.rocket.chat/u/reetp)\
**Post date:** [February 22, 2025, 2:47pm UTC](https://forums.rocket.chat/t/clearing-private-message-chats-via-api/21681/2 "2025-02-22T14:47:00Z")

</div>

Hmmm - not sure. I know they have tried to stop a lot of stuff with rooms in the name of ‘security’ but forget that some of us have responsibilities, and laws to follow.

Personally I think it is madness - it’s my server, I am responsible for the content and I should be able to do what I want.

I’m not sure exactly what/when - please check properly in the docs and let us know what you think is missing.

[https://developer.rocket.chat/apidocs/deprecatedendpoints](https://developer.rocket.chat/apidocs/deprecatedendpoints)

This?

[https://developer.rocket.chat/apidocs/clear-room-history](https://developer.rocket.chat/apidocs/clear-room-history)

---

<div class="post-metadata">

**Author:** ![Vladimir](https://avatars.discourse-cdn.com/v4/letter/v/94ad74/32.png) [@Vladimir](https://forums.rocket.chat/u/Vladimir)\
**Post date:** [February 23, 2025, 7:24am UTC](https://forums.rocket.chat/t/clearing-private-message-chats-via-api/21681/3 "2025-02-23T07:24:59Z")

</div>

Thanks, I read the documentation, but none of the commands (chat.delete, rooms.cleanHistory) to clear direct chats work(

---

<div class="post-metadata">

**Author:** ![reetp](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/reetp/32/5546_2.png) [@reetp](https://forums.rocket.chat/u/reetp)\
**Post date:** [February 25, 2025, 9:38am UTC](https://forums.rocket.chat/t/clearing-private-message-chats-via-api/21681/4 "2025-02-25T09:38:52Z")

</div>

Don’t do this.

You duplicate work for me, and I don’t get paid to do this.

> <https://github.com/RocketChat/Rocket.Chat/issues/35329>
>
> \### Description:
> 
> The API call does not work in direct chats. When requesting \*\*…rooms.cleanHistory\*\* to clear personal chats, I get the error:
> 
> {"success":false,"error":"User does not have access to the room \[error-not-allowed\]","errorType":"error-not-allowed"}
> 
> In version 6.13.0 and earlier, this call worked correctly and allowed deleting user messages in direct chats. I make the request via admin account.
> 
> \### Steps to reproduce:
> Call API request to some direct chat room:
> curl --request POST \\
> --url https://$site/api/v1/rooms.cleanHistory \\
> --header 'Content-Type: application/json' \\
> --header "X-Auth-Token: $authToken" \\
> --header "X-User-Id: $userId" 
> 
> \### Expected behavior:
> 
> Successfully cleared the direct chat room.
> 
> \### Actual behavior:
> 
> {"success":false,"error":"User does not have access to the room \[error-not-allowed\]","errorType":"error-not-allowed"}
> 
> \### Server Setup Information:
> 
> \- Version of Rocket.Chat Server: 7.3.1
> \- License Type: Community
> \- Number of Users: 100
> \- Operating System: Ubuntu 22
> \- Deployment Method: snap
