RocketChat/Rocket.Chat · error · Error
invalid-room
Error message
invalid-room
What it means
Thrown by GET /api/v1/livechat/transfer.history/:rid when no livechat room exists with the given rid (projection {_id: 1} returns nothing). It is a plain not-found guard before paging through the room's transfer history; requires the view-livechat-rooms permission.
Solutions
- Verify the rid exists first via GET /api/v1/livechat/rooms (filter by roomName) or wherever you obtained it
- Trim/validate the rid format before calling (Rocket.Chat ids are 17-char alphanumeric)
- If rooms are being retention-deleted, capture transfer history before retention runs
Defensive patterns
Strategy: validation
Validate before calling
const exists = await (await fetch(`${server}/api/v1/livechat/rooms?roomName=${encodeURIComponent(name)}`, { headers })).json();
const rid = exists?.rooms?.[0]?._id;
if (rid) await fetch(`${server}/api/v1/livechat/transfer.history/${rid}`, { headers }); Type guard
const isRocketChatId = (id: unknown): id is string => typeof id === 'string' && /^[A-Za-z0-9]{17}$/.test(id); Try / catch
const body = await (await fetch(url, { headers })).json();
if (!body.success && body.error === 'invalid-room') { /* drop cached rid, re-resolve room, or skip */ } Prevention
- Never hardcode rids across environments — resolve them at runtime
- Validate the 17-char id shape before building the URL
When it happens
Trigger: GET /api/v1/livechat/transfer.history/<wrong-or-closed-then-deleted-rid>; rid copied with trailing whitespace or quotes; room id from another workspace/environment; room deleted by retention.
Common situations: Integrations that cache rids across environments (dev vs prod); retention policies removing old livechat rooms while analytics exports still reference them; URL encoding issues mangling the id.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/8f3b570a950fd888.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/server/api/v1/omnichannel/transfer.ts:16
import { LivechatRooms } from '@rocket.chat/models';
import { API } from '../..';
import { findLivechatTransferHistory } from './lib/transfer';
import { getPaginationItems } from '../../lib/getPaginationItems';
API.v1.addRoute(
'livechat/transfer.history/:rid',
{ authRequired: true, permissionsRequired: ['view-livechat-rooms'] },
{
async get() {
const { rid } = this.urlParams;
const room = await LivechatRooms.findOneById(rid, { projection: { _id: 1 } });
if (!room) {
throw new Error('invalid-room');
}
const { offset, count } = await getPaginationItems(this.queryParams);
const { sort } = await this.parseJsonQuery();
const history = await findLivechatTransferHistory({
rid,
pagination: {
offset,
count,
sort,
},
});
return API.v1.success(history);
},
},
);
View on GitHub (pinned to b2c16d5842)