{"record":{"id":"f577626d9b77df1d","repo":"appwrite/appwrite","slug":"missing-required-parameter-email","errorCode":null,"errorMessage":"Missing required parameter: \"email\"","messagePattern":"Missing required parameter: \"email\"","errorType":"validation","errorClass":"AppwriteException","httpStatus":null,"severity":"error","filePath":"public/sdk-console/services/teams.ts","lineNumber":235,"sourceCode":"         * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)\n         * the only valid redirect URL's are the once from domains you have set when\n         * adding your platforms in the console interface.\n         *\n         * @param {string} teamId\n         * @param {string} email\n         * @param {string[]} roles\n         * @param {string} url\n         * @param {string} name\n         * @throws {AppwriteException}\n         * @returns {Promise}\n         */\n        async createMembership(teamId: string, email: string, roles: string[], url: string, name?: string): Promise<Models.Membership> {\n            if (typeof teamId === 'undefined') {\n                throw new AppwriteException('Missing required parameter: \"teamId\"');\n            }\n\n            if (typeof email === 'undefined') {\n                throw new AppwriteException('Missing required parameter: \"email\"');\n            }\n\n            if (typeof roles === 'undefined') {\n                throw new AppwriteException('Missing required parameter: \"roles\"');\n            }\n\n            if (typeof url === 'undefined') {\n                throw new AppwriteException('Missing required parameter: \"url\"');\n            }\n\n            let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);\n            let payload: Payload = {};\n\n            if (typeof email !== 'undefined') {\n                payload['email'] = email;\n            }\n\n            if (typeof roles !== 'undefined') {","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/appwrite/appwrite/blob/cd368e707d4b492bc5e8e9c0f8ecbc5b741c4bf4/public/sdk-console/services/teams.ts#L217-L253","documentation":"Thrown by Teams.createMembership when email is undefined. email is the invitee's email address and is required — the SDK validates it after teamId passes. The POST body to /teams/{teamId}/memberships must include email for the invitation.","triggerScenarios":"Calling teams.createMembership(teamId, email, roles, url) with a valid teamId but undefined email — invite form submitted with an empty email field, or the email input was not bound to state.","commonSituations":"Email input left blank; email field name mismatch between form state and the variable passed; form validation not run before submission; copy from a template where the email binding was incomplete.","solutions":["Validate email is a non-empty string (ideally with a format check) before calling createMembership.","Add client-side form validation requiring a valid email address.","Guard: if (email && isValidEmail(email)) { ... }","Confirm the form state key for email matches the variable name passed to createMembership."],"exampleFix":"// before\nawait teams.createMembership(teamId, form.email, roles, url);\n// form.email is undefined (field is 'inviteEmail')\n\n// after\nconst email = form.inviteEmail?.trim();\nif (!email) throw new Error('Email is required');\nawait teams.createMembership(teamId, email, roles, url);","handlingStrategy":"validation","validationCode":"const trimmedEmail = email?.trim();\nif (!trimmedEmail || !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(trimmedEmail)) {\n  throw new Error('A valid email is required');\n}\nawait teams.createMembership(teamId, trimmedEmail, roles, url);","typeGuard":"function isValidEmail(value: unknown): value is string {\n  return typeof value === 'string'\n    && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value);\n}","tryCatchPattern":"try {\n  await teams.createMembership(teamId, email, roles, url);\n} catch (e) {\n  if (e instanceof AppwriteException && e.message.includes('email')) {\n    setFormError('A valid email address is required');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Add email format validation on the invite form before submission.","Confirm the form state key for the email field matches the variable passed.","Trim and lowercase the email before passing to createMembership.","Show inline validation feedback on the email input."],"tags":["sdk","typescript","teams","validation","client-side"],"backgroundTag":null,"analyzedSha":"cd368e707d4b492bc5e8e9c0f8ecbc5b741c4bf4","analyzedAt":"2026-08-12T14:42:48.571Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}