Skip to content
Init is coming / May 19 - 23
Back

Invalid `userId` param: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, peri

  • 0
  • Auth
  • Web
matsyui
11 May, 2025, 14:44

Error: Invalid userId param: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char

This happens when i tried to login, sign up working fine..

this is how i implement the login:

TypeScript
    const login = async (email: string, password: string) => {
        try {
            await account.createSession(email, password)
            const user = await account.get()
            setCurrentUser(user)
            return { email }
        } catch (error) {
            if (error instanceof Error) {
                if (error.message.includes('Invalid credentials')) {
                    throw new Error('Invalid email or password')
                }
            }
            throw error
        }
    }

this is for signup

TypeScript
    const signup = async (email: string, password: string, name: string) => {
        try {
            await account.create(ID.unique(), email, password, name)
            // After successful signup, log the user in
            await login(email, password)
            return { name } // Return data for success message
        } catch (error) {
            if (error instanceof Error) {
                if (error.message.includes('already exists')) {
                    throw new Error(
                        'An account with this email already exists. Please try logging in instead.',
                    )
                }
                // Handle other potential errors
                if (error.message.includes('password')) {
                    throw new Error(
                        'Password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, and one number.',
                    )
                }
                if (error.message.includes('email')) {
                    throw new Error('Please enter a valid email address.')
                }
            }
            throw error
        }
    }
TL;DR
The error `Invalid 'userId' param: Parameter must contain at most 36 chars` occurs during login due to incorrect user ID format. The valid characters allowed are a-z, A-Z, 0-9, period, hyphen, and underscore, and it can't start with a special character. For the signup functionality, errors are handled accordingly, such as existing emails, password requirements not met, and invalid email addresses. Ensure the user ID parameters adhere to the specified format guidelines.
matsyui
11 May, 2025, 14:46

Dependencies:

TypeScript
    "dependencies": {
        "appwrite": "^17.0.2",
        "date-fns": "^4.1.0",
        "lucide-react": "^0.509.0",
        "next": "15.3.2",
        "prettier": "^3.5.3",
        "react": "^19.0.0",
        "react-dom": "^19.0.0",
        "react-hot-toast": "^2.5.2",
        "slugify": "^1.6.6",
        "zustand": "^5.0.4"
    },

Reference: https://appwrite.io/docs/quick-starts/nextjs#step-2

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more