
i want to get the user id of the requestor inside a function. How can i achive this?


You can get it from the header x-appwrite-user-id

Okay, sorry for not reading the docs. does the overlaying framework fill this field?

Not really, if you want the id of the user that triggered the function you can do something like this.
const headers = req.headers
const userId = headers['x-appwrite-user-id'];
...

is this field validated tho? link, can someone just send a request with an existing user id in this field an the function will accept it?

https://discord.com/channels/564160730845151244/564160731327758347/1201964884762558524
Here is a discussion someone else had with the same question earlier today, beyond this I'm not entirely sure if it's validated.

From what I understand from the source code, it's being validated server side to ensure it's not being spoofed: https://github.com/appwrite/appwrite/blob/47ea083ea4bac0b2299b0b8d3fbe7648dac44af7/app/controllers/api/functions.php#L1573
Recommended threads
- deleteDocments is not a function
Hello. At the bottom of my project's console, in the footer, I have `Version 1.7.4`. However, when I run my server side function, I am told that `databases.dele...
- Server Error when updating an existing d...
I am getting "AppwriteException: general_unknown, Server Error (500)" when using UpsertDocument on Appwrite Cloud from a function with Dart 3.5 runtime and dart...
- Random function executions - Bots?
I have custom domains on my functions, they are getting a lot of noisy executions. Scammy looking to me. I've only just added my function subdomains in the last...
