Run cloud code as master

Hi guys,

I would like to know if there is an option to call cloud code with the master key?
I would like to run some initialization on the server each time it’s launched.
Tried to go with:“onStart”);
in the index.js file it works but the cloud code isn’t called as master so actually, everyone can call it from outside.
Maybe there is a better solution to call some cloud code on the server launch?

Thank you.

It’s fine to call cloud functions in index.js, according to my understanding.

You can use:"onStart",null,{useMasterKey:true});


In order to make sure the function cannot be called by any user, add this to the start of the cloud function:

   throw "YouNeedMasterKeyForThis"

Thanks to @uzaysan

1 Like

@dblythy s answer is correct. But if you want your cloud code to run with only with masterkey add this lines to cloud code.

    throw "YouNeedMasterKeyForThis"