Mergent
Search…
JavaScript / TypeScript

Creating a Task

const Mergent = require("mergent"); // Node.js
// OR
import Mergent from "mergent"; // TypeScript
// set the Mergent API key
const mergent = new Mergent("...");
// create a Task
mergent.tasks
.create({
request: {
headers: { "Authorization": "Bearer ..." }, // Optional
url: "https://example.com/webhook",
body: "..." // Optional
},
scheduled_for: "2021-10-01T15:53:05Z", // Optional: Set an exact time (ISO 8601), OR
delay: "PT5M" // Optional: Set a 5 minute delay (ISO 8601 Duration)
})
.then((task) => console.log(task))
.catch((error) => console.error(error));
For a list of all the available parameters, please visit the API reference.
Copy link