API for Cloud Function


Do Moralis have any API to schedule call for Cloud Function.
Now it;s possible to do with dialog interface, but I need to do it programmatically.


I’m not sure what you mean.

you can call a cloud function with REST api:

No, I want for example call Cloud Function at 10PM 20th Apr.
How I can schedule this call from my JS program?

you can use jobs directly in your dashboard interface


But I don’t want to use Moralis UI for jobs management. I want to use my own UI and schedule job using JS code. Is it possible?

if you have your own ui, and your own server, you can run a cloud function from your server directly

In my own backend I can run my own code withowt Cloud Function :slight_smile:
Now I have only Vue frontend, so I planned to schedule end game from code that this game starts. I dont’want analyze logs with start game events and manually schedule Cloud Function using Moralis UI.
It could bu much suitable if I could use JS/REST API to schedule cloud functions (your UI uses it :wink:

I don’t know if it is a way to do that programmatically

But this UI (https://docs.moralis.io/moralis-server/cloud-code/jobs) uses some API? Or it works with DB directly?

If you want to schedule tasks in your app, this below code might do it.

// current date
var startDate = new Date(); 
// future date
var endDate   = new Date('Mon Mar 22 2022 10:00:00 GMT+0530 (India Standard Time)')
// difference in milliSec
var millisec = (endDate.getTime() - startDate.getTime())
let eventTime = setTimeout(function () {
  // add your function here and it will run after "millisec" time
}, millisec);
1 Like