Mergent
Search…
⌃K
Links

JavaScript / TypeScript

Using Next.js? Check out our Next.js example.

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
},
scheduledFor: new Date(), // Optional: Set an exact time, OR
delay: { minutes: 5 } // Optional: Set a 5 minute delay
})
.then((task) => console.log(task))
.catch((error) => console.error(error));
For a list of all the available parameters, please visit the API reference.