Hi @s-alavi, welcome to the forum.
You can find an example that should suit your needs here:RegisterEventSessionEnd with full functionality - #2 by novabyte
Please be aware, as Chris mentions in the post, that the API is specifically designed in this way to prevent misuse and writing code that is not subject to rate limiting which could negatively impact the performance of your Nakama server, so please use with caution.