Skip to content
Back

AppwriteException: Invalid `userId` param: UID must contain at most 36 chars. Valid chars are a-z...

  • 0
  • Functions
  • Cloud
amitrochates
4 Oct, 2025, 06:06

Trying to use the users.listSessions as given here https://appwrite.io/docs/references/cloud/server-nodejs/users#listSessions here's my code

TypeScript
    const result = await users.listSessions({
      userId: userslist.users[0].$id
    });```

I wonder why im getting this error, my userId doesnt exceed 36 chars, nor does it have underscore in the beginning , heres whats logged  in ```userslist.users[0].$id```
```685add06748f633325b0```

Full Error: 
```Error in purge-user-sessions function: AppwriteException: Invalid `userId` param: UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and underscore. Can't start with a leading underscore
    at _Client.call (file:///usr/local/server/src/function/node_modules/node-appwrite/dist/client.mjs:293:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Module.default (file:///usr/local/server/src/function/src/index.js:38:20)
    at async execute (/usr/local/server/src/server.js:220:16)
    at async action (/usr/local/server/src/server.js:237:7)
    at async /usr/local/server/src/server.js:26:5```

Edit: Add full error in the post message
TL;DR
AppwriteException is being thrown due to the `userId` param exceeding 36 chars, even though the length seems valid. The issue might be related to characters other than alphanumerics or incorrect leading underscore. Check code and potential data issues.
amitrochates
4 Oct, 2025, 06:07

AppwriteException: Invalid userId param: UID must contain at most 36 chars. Valid chars are a-z...

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