Mergent
Search…
JavaScript / TypeScript

Creating a Task

1
const Mergent = require("mergent"); // Node.js
2
// OR
3
import Mergent from "mergent"; // TypeScript
4
5
// set the Mergent API key
6
const mergent = new Mergent("...");
7
8
// create a Task
9
mergent.tasks
10
.create({
11
request: {
12
headers: { "Authorization": "Bearer ..." }, // Optional
13
url: "https://example.com/webhook",
14
body: "..." // Optional
15
},
16
scheduled_for: "2021-10-01T15:53:05Z", // Optional: Set an exact time (ISO 8601), OR
17
delay: "PT5M" // Optional: Set a 5 minute delay (ISO 8601 Duration)
18
})
19
.then((task) => console.log(task))
20
.catch((error) => console.error(error));
Copied!
For a list of all the available parameters, please visit the API reference.
Copy link