Exposing endpoint on Moralis server

Hello,

Is it possible to expose an endpoint on the moralis server, to receive for example payment confirmations from UTrust?

Thanks

Yes it’s possible, all cloud functions are possible to query through REST

If you have a cloud function named hello you would call it like this:

SERVER_URL/functions/hello

1 Like

REST API docs here (not yet migrated to the Moralis Docs page):

The REST API key is not required.

2 Likes

Great, I will try this out!

Hello mayjer,

I managed to get this working, but it has one drawback: it requires authorization.
What I need is a public callable function.
My use case is that I want to use it as a callback for UTrust.

Is this possible?

Thanks,
Gerald

If you can find a way to set the APP ID in the request header when the webhook is called you’re golden.

I did a bit of testing and doesn’t look like its currently possible to define your own REST routes within Cloud Code- i.e. writing a simple express app with routes. So hopefully you can figure out a way to add the APP ID to the request header and use Cloud Functions as endpoints instead.

I just did some tests, I got mine working the following way

curl --location --request POST 'https://svzayzygttuw.moralis.io:2053/server/functions/hello?message=test' \
--header 'Content-Type: application/json' \
--data-raw '{
    "_ApplicationId": "wxBfC0OKuSn5XjHjTvE1CSOOTkguwpZXgYjWwOlW"
}'

Notice calls to cloud function in moralis are POST and must include _ApplicationId as key in body params.

You can test the above method.

Hope I’m not too late

2 Likes

@ivan sooner than you think maybe

1 Like

fantstic, thanks for sharing, will refer to this when someone asks in the future

For those who can’t wait and need this functionality for their hackathon projects, I built in a scrappy forwarder anyone can run as a middleware.

@nutrina

6 Likes

Thanks,

That’s cool.

Hey guys

You can now do GET request!!

https://docs.moralis.io/moralis-server/cloud-functions#calling-via-rest-api

V 0.0.225 (03-06-2021)

* Calling Cloud Functions via REST API (GET Method)
1 Like