{"record":{"id":"9a73e4815d6ca82f","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-9a73e4","errorCode":null,"errorMessage":"error-invalid-user","messagePattern":"error-invalid-user","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/transcript.ts","lineNumber":65,"sourceCode":"\n\t\t\tif (!(await Omnichannel.isWithinMACLimit(room))) {\n\t\t\t\tthrow new Error('error-mac-limit-reached');\n\t\t\t}\n\n\t\t\tawait LivechatRooms.unsetEmailTranscriptRequestedByRoomId(rid);\n\n\t\t\treturn API.v1.success();\n\t\t},\n\t\tasync post() {\n\t\t\tconst { rid } = this.urlParams;\n\t\t\tconst { email, subject } = this.bodyParams;\n\n\t\t\tconst user = await Users.findOneById(this.userId, {\n\t\t\t\tprojection: { _id: 1, username: 1, name: 1, utcOffset: 1 },\n\t\t\t});\n\n\t\t\tif (!user) {\n\t\t\t\tthrow new Error('error-invalid-user');\n\t\t\t}\n\n\t\t\tawait requestTranscript({ rid, email, subject, user });\n\n\t\t\treturn API.v1.success();\n\t\t},\n\t},\n);\n","sourceCodeStart":47,"sourceCodeEnd":74,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/api/v1/omnichannel/transcript.ts#L47-L74","documentation":"Thrown by POST /api/v1/livechat/transcript/:rid when the authenticated user id (from the auth token headers) does not resolve to a document in the Users collection. The endpoint loads the requesting user to attach them to the transcript request; a null result means the credentials point at a deleted or otherwise missing user.","triggerScenarios":"The user was deleted (or merged into another user) after the REST session/token was issued, and a client keeps sending the old X-User-Id/X-Auth-Token pair; a token minted in one environment used against another.","commonSituations":"Long-lived integration credentials whose owner account was removed during offboarding; restored database where users collection and tokens are out of sync; scripts with a hardcoded user id after a re-install.","solutions":["Re-login and obtain a fresh X-Auth-Token/X-User-Id pair (POST /api/v1/login) for an existing user with view-livechat-manager permission","Verify the credentials work at all with GET /api/v1/me — if that also fails the account/token is gone","If the user was deleted by mistake, restore it or create a dedicated service account for the integration and use its token"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const me = await (await fetch(`${server}/api/v1/me`, { headers })).json();\nif (!me?.success) await relogin(); // token/user no longer valid — do not call transcript yet\nawait requestTranscript(rid);","typeGuard":null,"tryCatchPattern":"const body = await (await fetch(url, { method: 'POST', headers })).json();\nif (!body.success && body.error === 'error-invalid-user') { /* credentials stale: re-login and retry once with a fresh token */ }","preventionTips":["Use a dedicated, non-deletable service account for integrations","Refresh tokens on schedule instead of caching them forever","Health-check credentials with /api/v1/me at startup"],"tags":["rest-api","livechat","transcript","authentication","user-management"],"backgroundTag":"user-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}