{"record":{"id":"7442d6236e4ce230","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room","errorCode":"error-invalid-room","errorMessage":"error-invalid-room","messagePattern":"error-invalid-room","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/ee/server/api/v1/omnichannel/rooms.ts","lineNumber":29,"sourceCode":"API.v1.addRoute(\n\t'livechat/room.onHold',\n\t{\n\t\tauthRequired: true,\n\t\tpermissionsRequired: ['on-hold-livechat-room'],\n\t\tvalidateParams: isLivechatRoomOnHoldProps,\n\t\tlicense: ['livechat-enterprise'],\n\t},\n\t{\n\t\tasync post() {\n\t\t\tconst { roomId } = this.bodyParams;\n\n\t\t\ttype Room = Pick<IOmnichannelRoom, '_id' | 't' | 'open' | 'onHold' | 'u' | 'lastMessage' | 'servedBy'>;\n\n\t\t\tconst room = await LivechatRooms.findOneById<Room>(roomId, {\n\t\t\t\tprojection: { _id: 1, t: 1, open: 1, onHold: 1, u: 1, lastMessage: 1, servedBy: 1 },\n\t\t\t});\n\t\t\tif (!room) {\n\t\t\t\tthrow new Error('error-invalid-room');\n\t\t\t}\n\n\t\t\tconst subscription = await Subscriptions.findOneByRoomIdAndUserId(roomId, this.userId, { projection: { _id: 1 } });\n\t\t\tif (!subscription && !(await hasPermissionAsync(this.user, 'on-hold-others-livechat-room'))) {\n\t\t\t\tthrow new Error('Not_authorized');\n\t\t\t}\n\n\t\t\tconst onHoldBy = { _id: this.userId, username: this.user.username, name: this.user.name };\n\t\t\tconst comment = i18n.t('Omnichannel_On_Hold_manually', {\n\t\t\t\tuser: onHoldBy.name || `@${onHoldBy.username}`,\n\t\t\t});\n\n\t\t\tawait OmnichannelEEService.placeRoomOnHold(room, comment, this.user);\n\n\t\t\treturn API.v1.success();\n\t\t},\n\t},\n);","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/api/v1/omnichannel/rooms.ts#L11-L47","documentation":"POST livechat/room.onHold looks the room up by body roomId with LivechatRooms.findOneById; if no room matches, error-invalid-room is thrown before the subscription/permission check. The route itself requires the on-hold-livechat-room permission and an Enterprise license, so callers without those never reach this throw.","triggerScenarios":"POST /api/v1/livechat/room.onHold with {\"roomId\": \"<unknown id>\"} — typo, deleted room, non-livechat room id, or an id from another workspace.","commonSituations":"Automation holding rooms after they closed; passing a channel/group id for a non-omnichannel room; environment mismatch between where the id was read and where the call is made.","solutions":["Fetch the room fresh (livechat rooms list / rooms.info) and confirm it is an open omnichannel conversation before calling.","Verify the room type is 'l' — on-hold only applies to livechat rooms.","Check workspace/environment when ids come from external configuration."],"exampleFix":"// before\nawait api.post('/v1/livechat/room.onHold', { roomId: rid });\n\n// after\nconst info = await api.get('/v1/rooms.info', { params: { roomId: rid } });\nif (info?.room?.t === 'l' && info.room.open) {\n  await api.post('/v1/livechat/room.onHold', { roomId: rid });\n}","handlingStrategy":"validation","validationCode":"const info = await api.get('/v1/rooms.info', { params: { roomId } });\nif (info?.room?.t === 'l' && info.room.open && !info.room.onHold) {\n  await api.post('/v1/livechat/room.onHold', { roomId });\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.post('/v1/livechat/room.onHold', { roomId });\n} catch (e) {\n  if (e?.response?.data?.errorType === 'error-invalid-room') {\n    // drop the room from the queue; it no longer exists\n  } else throw e;\n}","preventionTips":["Confirm the room is an open livechat conversation before offering the hold action.","Refresh room existence for ids older than the current session.","Keep room ids environment-scoped in configuration."],"tags":["omnichannel","livechat","on-hold","room","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}