{"record":{"id":"d7f221152cc71229","repo":"RocketChat/Rocket.Chat","slug":"error-not-allowed-d7f221","errorCode":"error-not-allowed","errorMessage":"Not allowed","messagePattern":"Not allowed","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/meteor-methods/saveCannedResponse.ts","lineNumber":23,"sourceCode":"\nimport { hasPermissionAsync } from '../../../server/lib/authorization/hasPermission';\nimport notifications from '../../../server/lib/notifications/core/lib/Notifications';\n\ntype ResponseData = {\n\tshortcut: string;\n\ttext: string;\n\tscope: string;\n\ttags?: string[];\n\tdepartmentId?: string;\n};\n\nexport const saveCannedResponse = async (\n\tuserId: string,\n\tresponseData: ResponseData,\n\t_id?: string,\n): Promise<Omit<IOmnichannelCannedResponse, '_updatedAt' | '_createdAt'> & { _createdAt?: Date }> => {\n\tif (!(await hasPermissionAsync(userId, 'save-canned-responses'))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'saveCannedResponse' });\n\t}\n\n\tcheck(_id, Match.Maybe(String));\n\n\tcheck(responseData, {\n\t\tshortcut: String,\n\t\ttext: String,\n\t\tscope: String,\n\t\ttags: Match.Maybe([String]),\n\t\tdepartmentId: Match.Maybe(String),\n\t});\n\n\tconst canSaveAll = await hasPermissionAsync(userId, 'save-all-canned-responses');\n\tif (!canSaveAll && ['global'].includes(responseData.scope)) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed to modify canned responses on *global* scope', {\n\t\t\tmethod: 'saveCannedResponse',\n\t\t});\n\t}","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/meteor-methods/saveCannedResponse.ts#L5-L41","documentation":"Thrown by saveCannedResponse when hasPermissionAsync(userId, 'save-canned-responses') is false. This is the base permission gate; without it a user cannot create or update any canned response regardless of scope. Code is 'error-not-allowed'.","triggerScenarios":"Calling saveCannedResponse with a userId whose role does not grant 'save-canned-responses'.","commonSituations":"Agent role not granted the save permission; permission was revoked during a role cleanup; new custom role created without the canned-response permission.","solutions":["Grant 'save-canned-responses' to the user's role in Administration > Permissions.","If only certain scopes should be editable, still grant the base permission and rely on the scope-specific checks (canSaveAll / canSaveDepartment).","Verify the userId passed matches the acting user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!(await hasPermissionAsync(userId, 'save-canned-responses'))) {\n  throw new Error('You do not have permission to save canned responses');\n}\nawait saveCannedResponse(userId, responseData, _id);","typeGuard":null,"tryCatchPattern":"try {\n  await saveCannedResponse(userId, responseData, _id);\n} catch (e) {\n  if (isMeteorError(e, 'error-not-allowed')) {\n    notifyUser('You lack the save-canned-responses permission.');\n    return;\n  }\n  throw e;\n}","preventionTips":["Grant 'save-canned-responses' to roles that manage responses.","Hide save UI for users without the permission.","Confirm the userId is the acting user."],"tags":["canned-responses","authorization","permissions"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}