appwrite/appwrite · error · AppwriteException

Missing required parameter: "email"

Error message

Missing required parameter: "email"

What it means

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.

Source

Thrown at public/sdk-console/services/teams.ts:235

         * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
         * the only valid redirect URL's are the once from domains you have set when
         * adding your platforms in the console interface.
         *
         * @param {string} teamId
         * @param {string} email
         * @param {string[]} roles
         * @param {string} url
         * @param {string} name
         * @throws {AppwriteException}
         * @returns {Promise}
         */
        async createMembership(teamId: string, email: string, roles: string[], url: string, name?: string): Promise<Models.Membership> {
            if (typeof teamId === 'undefined') {
                throw new AppwriteException('Missing required parameter: "teamId"');
            }

            if (typeof email === 'undefined') {
                throw new AppwriteException('Missing required parameter: "email"');
            }

            if (typeof roles === 'undefined') {
                throw new AppwriteException('Missing required parameter: "roles"');
            }

            if (typeof url === 'undefined') {
                throw new AppwriteException('Missing required parameter: "url"');
            }

            let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
            let payload: Payload = {};

            if (typeof email !== 'undefined') {
                payload['email'] = email;
            }

            if (typeof roles !== 'undefined') {

View on GitHub (pinned to cd368e707d)

Solutions

  1. Validate email is a non-empty string (ideally with a format check) before calling createMembership.
  2. Add client-side form validation requiring a valid email address.
  3. Guard: if (email && isValidEmail(email)) { ... }
  4. Confirm the form state key for email matches the variable name passed to createMembership.

Example fix

// before
await teams.createMembership(teamId, form.email, roles, url);
// form.email is undefined (field is 'inviteEmail')

// after
const email = form.inviteEmail?.trim();
if (!email) throw new Error('Email is required');
await teams.createMembership(teamId, email, roles, url);
Defensive patterns

Strategy: validation

Validate before calling

const trimmedEmail = email?.trim();
if (!trimmedEmail || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(trimmedEmail)) {
  throw new Error('A valid email is required');
}
await teams.createMembership(teamId, trimmedEmail, roles, url);

Type guard

function isValidEmail(value: unknown): value is string {
  return typeof value === 'string'
    && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
}

Try / catch

try {
  await teams.createMembership(teamId, email, roles, url);
} catch (e) {
  if (e instanceof AppwriteException && e.message.includes('email')) {
    setFormError('A valid email address is required');
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of appwrite/appwrite@cd368e707d (2026-08-12). Data as JSON: /api/errors/f577626d9b77df1d. Report an issue: GitHub.