> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.
# Clear Room History
> Cleans up a room by removing messages from the provided time range. For details, see the Prune messages from a room section.
Permission required: `clean-channel-history`
### Changelog
| Version | Description |
| ------- | ---------------------- |
| 0.64.0 | Added |
| 0.67.0 | Added fields `limit`, `excludePinned`, `filesOnly` and `users` |
## OpenAPI
````json POST /api/v1/rooms.cleanHistory
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Rooms"
},
"servers": [
{
"url": "https://apiexplorer.support.rocket.chat"
}
],
"tags": [
{
"name": "Channels"
},
{
"name": "Directory"
},
{
"name": "Groups"
},
{
"name": "Rooms"
},
{
"name": "Teams"
},
{
"name": "Room Invites"
},
{
"name": "Subscriptions"
},
{
"name": "ABAC"
}
],
"paths": {
"/api/v1/rooms.cleanHistory": {
"post": {
"tags": [
"Rooms"
],
"summary": "Clear Room History",
"description": "Cleans up a room by removing messages from the provided time range. For details, see the Prune messages from a room section.\n\nPermission required: `clean-channel-history`\n\n### Changelog\n| Version | Description |\n| ------- | ---------------------- |\n| 0.64.0 | Added |\n| 0.67.0 | Added fields `limit`, `excludePinned`, `filesOnly` and `users` |",
"operationId": "get-api-v1-rooms.cleanHistory",
"parameters": [
{
"$ref": "#/components/parameters/Auth-Token"
},
{
"$ref": "#/components/parameters/UserId"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"roomId": {
"type": "string",
"description": "The room ID."
},
"latest": {
"type": "string",
"description": "The end of time range of messages."
},
"oldest": {
"type": "string",
"description": "The start of the time range of messages."
},
"inclusive": {
"type": "boolean",
"description": "Whether messages which land on the latest and oldest dates should be included. By default, the value is false."
},
"excludePinned": {
"type": "boolean",
"description": "Whether pinned messages should be deleted. By default, the value is false."
},
"filesOnly": {
"type": "boolean",
"description": "Whether to only delete files and keep messages intact. By default, the value is false."
},
"users": {
"type": "array",
"items": {
"type": "string"
},
"description": "Specific set of users whose content to delete. By default, the value is [], that is, everyone."
},
"limit": {
"type": "integer",
"description": "The amount of messages to prune. By default, the value is 0 (all)."
},
"ignoreDiscussion": {
"type": "boolean",
"description": "Determines if messages from discussions should be pruned. By default, the value is true."
},
"ignoreThreads": {
"type": "boolean",
"description": "Determines if messages from threads should be pruned. By default, the value is true."
}
},
"required": [
"roomId",
"latest",
"oldest"
]
},
"examples": {
"Example": {
"value": {
"roomId": "roomId",
"latest": "2016-12-09T13:42:25.304Z",
"oldest": "2016-08-30T13:42:25.304Z"
}
}
}
}
}
},
"responses": {
"200": {
"$ref": "#/components/responses/trueSuccess"
},
"401": {
"$ref": "#/components/responses/authorizationError"
}
}
}
}
},
"components": {
"parameters": {
"Auth-Token": {
"name": "X-Auth-Token",
"in": "header",
"description": "The `authToken` of the authenticated user.",
"required": true,
"schema": {
"type": "string"
},
"example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
},
"UserId": {
"name": "X-User-Id",
"in": "header",
"description": "The `userId` of the authenticated user.",
"required": true,
"schema": {
"type": "string"
},
"example": "rbAXPnMktTFbNpwtJ"
}
},
"responses": {
"trueSuccess": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
},
"examples": {
"Success": {
"value": {
"success": true
}
}
}
}
}
},
"authorizationError": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
}
}
},
"examples": {
"Authorization Error": {
"value": {
"success": false,
"error": "You must be logged in to do this."
}
}
}
}
}
}
}
}
}
````