> ## 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. # Export Room > Export room messages to a file or email. When exporting to a file, the ZIP file is stored in the `/tmp` directory on the Rocket.Chat server, and its details are recorded in the `rocketchat_user_data_files` collection in MongoDB. Permission required: `mail-messages` ### Changelog | Version | Description | | ------- | ------------------------------------ | | 3.8.0 | Added | ## OpenAPI ````json POST /api/v1/rooms.export { "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.export": { "post": { "tags": [ "Rooms" ], "summary": "Export Room", "description": "Export room messages to a file or email. When exporting to a file, the ZIP file is stored in the `/tmp` directory on the Rocket.Chat server, and its details are recorded in the `rocketchat_user_data_files` collection in MongoDB.\n\nPermission required: `mail-messages`\n\n### Changelog\n\n| Version | Description |\n| ------- | ------------------------------------ |\n| 3.8.0 | Added |\n", "operationId": "post-api-v1-rooms.export", "parameters": [ { "$ref": "#/components/parameters/Auth-Token" }, { "$ref": "#/components/parameters/UserId" } ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "rid": { "type": "string", "description": "The room ID." }, "type": { "type": "string", "description": "How you want the room to be exported. The type of export selected determines the remaining required parameters. It can be either `email` or `file`." }, "dateFrom": { "type": "string", "description": "Start date to begin fetching. Use `dateFrom` if the type is `file`. By default, it selects the oldest possible date." }, "dateTo": { "type": "string", "description": "End date for fetching. By default it selects the current date. Use `dateTo` if the `type` is `file`." }, "format": { "type": "string", "description": "The file type to export as. It can either be `html` or `json`. Use `format` if the `type` is `file`." }, "toUsers": { "type": "array", "items": { "type": "string" }, "description": "An array of users that should recieve the export. ecieve the export. It is required if `type` is `email`." }, "toEmails": { "type": "array", "items": { "type": "string" }, "description": "An array of any additional emails that should recieve the export. It is required if `type` is `email`. " }, "messages": { "type": "array", "items": { "type": "string" }, "description": "An array of messageId for the messages that should be exported. It is required if `type` is `email`. " }, "subject": { "type": "string", "description": "The subject of the email. It is required if `type` is `email`. " } }, "required": [ "rid", "type" ] }, "examples": { "Example": { "value": { "rid": "iu7jtPAhvEeAS5tNq", "type": "file", "dateFrom": "2000-01-01", "dateTo": "2021-11-25", "format": "html", "toUsers": [ "test.user" ], "toEmails": [ "test@test.com" ], "messages": [ "yd6NBgNoiWATgDoFt", "BoCjicj9DdYoMHHeo", "tajMB3aX3sawFWe8W" ], "subject": "Test Subject " } } } } } }, "responses": { "200": { "$ref": "#/components/responses/trueSuccess" }, "400": { "description": "Bad Request", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "error": { "type": "string" }, "errorType": { "type": "string" } } }, "examples": { "Invalid Room ID": { "value": { "success": false, "error": "[error-invalid-room]", "errorType": "error-invalid-room" } }, "Invalid Format": { "value": { "success": false, "error": "[error-invalid-format]", "errorType": "error-invalid-format" } }, "Invalid Params": { "value": { "success": false, "error": "[error-invalid-params]", "errorType": "error-invalid-params" } } } } } }, "401": { "$ref": "#/components/responses/authorizationError" }, "403": { "$ref": "#/components/responses/forbiddenError" } } } } }, "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." } } } } } }, "forbiddenError": { "description": "Forbidden", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "error": { "type": "string" }, "errorType": { "type": "string" } } }, "examples": { "Permission Error": { "value": { "success": false, "error": "User does not have the permissions required for this action", "errorType": "error-forbidden" } } } } } } } } } ````