How to make a cloud function private

i want to restrict some functions in cloud from being called by users for security reasons how can i do that… also i’m wondering if the functions that run by trigger events are private

If you want your cloud code to be executebale by only authenticated users, you can do this:

Parse.Cloud.define("cloudCode", async (request) => {
 if(!request.user){
   throw "error"
 }
 //Your cloud code
});

You can make a cloud function only callable with the master key by checking whether the master key is provided in the request.

1 Like

i meant that i don’t want any one to call my function even auth users

my function on works on triggers so i suppose that it can’t be called right ?

If you don’t want anyone to call the function, not even with the master key, then I suppose you mean a regular JavaScript method, not a Cloud Code function.

The JavaScript in Cloud Code is not exposed outside Parse Server. Entrance points have to be explicitly defined, such as Cloud Code functions or Cloud Code jobs.

Whatever is in a Cloud Code trigger is also not directly reachable, because a trigger cannot be called manually, it is called by Parse Server on the event that fires the trigger.

I suggest you share an example of your code so that the terminology is not an obstacle when describing the issue.

yes that’s what i meant function called by trigger are only called by parse server thank you