Documentation about master key

On the documentation section Initialize Moralis it says

“If the master key needs to be provided, use the following”

Maybe you could elaborate on this? In what case would the master key be provided?


Which part of the documentation are you referring to? could you provide us with the link?

You will not want to provide the master key in client side javascript. With the master key you can do any updates in the database and any selects. You can use the master key in a cloud function, that is where you’ll use it most of the time, and there you use it with useMasterKey parameter for a query.

1 Like

I also think that the documentation for master key is a bit confusing.
From my understanding master key is used if you have some other backend from where you can safely make the calls. I also assume that master key is available by default in the cloud functions, however, this is not written anywhere.

Moreover, documentation about master key


doesn’t give any info on how to use the master key from a custom backend server that we are controlling and running.
Additionally, it’s not also clear how to pass master key if we are calling the cloud function.

1 Like

We can add an example in documentation on how to use it from backend, for example in this tutorial code you can find an example on how to use it:

Also, now anyone can contribute to Moralis documentation here:

1 Like

Thx, that is quite helpful. I can submit a pr for the documentation. However, can you explain it to me if is master user accessible by default in cloud functions when you use useMasterKey:true or it needs to be set somewhere?

It is accessible by default in a cloud function when you use useMasterKey:true

Hello @cryptokid, I tried using the code from the github link that you sent. However, it doesn’t work!

In the code itself it doesnt seem that start function accepts masterKey as argument (

The error i get is: ParseError: Cannot access 'query' before initialization

1 Like

it looks like I see something different here:

Thx, I fixed it. It seems I was using the query before declaring it.