Creating a cloudfunction with an endpoint that doesn't require authentication

Is it possible to create a cloud function that can be accessed by anyone without needing to be authenticated. If so how can i do this?

I have set up a basic cloud function without any validation and tried calling it using ‘postman’ but i always get an ‘unauthorized’ message.

Hey @deadLuchador

Cloud Functions calling is available and without authorisation.
You have message {"error":"unauthorized"} because of incorrect info provided in the API request.
Take a look at Calling Cloud Functions via REST API.

The URL has the following structure:

  1. Full Morlis server url
  2. /functions/
  3. Cloud Function Name
  4. ?_ApplicationId=yourMoralisAppId
  5. (optional) Cloud Function param key/value pairs: &param1=value&param2=value

Hope this will help you :man_mechanic:

3 Likes

Thanks that did help @Yomoo .

Final question on this is, is it possible to define the structure of the returned data so that my data is not nested in an object.

Example

i want this

{"a":"1"}

instead of this

{"result":{"a":"1"}}

API response is an object, so you can get needed data response.result

@Yomoo I understand that but it will be an external system that consumes this data. Therefore it needs to be returned in a predefined format. I need to return the data without it being nested. Is this currently possible?

No, you will have to format the nested data according the requirement of the external system which consumes data.
as @Yomoo said you can use response.result to get the required data or for loop through it

2 Likes