Skip to content
Back

Local appwrite run functions --user-id not generating x-appwrite-user-jwt (self-hosted)

  • 0
  • Self Hosted
  • Functions
Ryosucc Takahashi
13 Mar, 2026, 10:27

Hi, I'm running into an issue when testing Appwrite functions locally with user impersonation.

I'm using a self-hosted Appwrite instance and running functions locally with the CLI: appwrite run functions --function-id <FUNCTION_ID> --user-id <USER_ID>

The function runs correctly, but the impersonation headers are not generated.

Inside the function I logged the headers and I'm getting: log(JSON.stringify({ userId: req.headers['x-appwrite-user-id'] ?? null, hasUserJwt: Boolean(req.headers['x-appwrite-user-jwt']), hasApiKey: Boolean(req.headers['x-appwrite-key']), }, null, 2)); So: { "userId": "6978b6b8003822478082", "hasUserJwt": false, "hasApiKey": false }

The CLI prints the following warning: Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: <email> (role: users) missing scopes (["users.read"])

However the function does have the required scopes in appwrite.config.json, including: "scopes": [ "users.read" ]

Other CLI commands work normally: appwrite push functions appwrite pull deployments etc.

So the CLI login seems valid.

Am I missing something in my setup, or is there any additional configuration required for local user impersonation on self-hosted Appwrite?

TL;DR
Issue: When running Appwrite functions locally with user impersonation on a self-hosted instance, the x-appwrite-user-jwt header is not generating. Solution: Check the user's scopes in the appwrite.config.json file to ensure they include the required scopes. If the scopes are correctly set but the issue persists, additional configuration may be needed for local user impersonation on self-hosted Appwrite.
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